import and export XAO with Fields

This commit is contained in:
fps 2013-11-12 16:32:55 +00:00
parent 1ccc5a5f3f
commit 6f7151b5d7
14 changed files with 367 additions and 106 deletions

View File

@ -3743,7 +3743,7 @@ module GEOM
* \return boolean indicating if export was successful. * \return boolean indicating if export was successful.
*/ */
boolean ExportXAO(in GEOM_Object shape, boolean ExportXAO(in GEOM_Object shape,
in ListOfGO groups, in ListOfGO fields, in ListOfGO groups, in ListOfFields fields,
in string author, in string fileName); in string author, in string fileName);
/*! /*!
@ -3756,7 +3756,7 @@ module GEOM
* \return boolean indicating if import was successful. * \return boolean indicating if import was successful.
*/ */
boolean ImportXAO(in string fileName, out GEOM_Object shape, boolean ImportXAO(in string fileName, out GEOM_Object shape,
out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields); out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
}; };
// # GEOM_IKindOfShape: // # GEOM_IKindOfShape:

View File

@ -269,10 +269,10 @@ module GEOM
void ExportTranslators (out string_array theFormats, void ExportTranslators (out string_array theFormats,
out string_array thePatterns) ; out string_array thePatterns) ;
boolean ExportXAO(in GEOM_Object shape, boolean ExportXAO(in GEOM_Object shape,
in ListOfGO groups, in ListOfGO fields, in ListOfGO groups, in ListOfFields fields,
in string author, in string fileName); in string author, in string fileName);
boolean ImportXAO(in string fileName, out GEOM_Object shape, boolean ImportXAO(in string fileName, out GEOM_Object shape,
out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields); out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
//-----------------------------------------------------------// //-----------------------------------------------------------//
// TransformOperations // // TransformOperations //

View File

@ -216,6 +216,7 @@ namespace GEOM
}; };
typedef GenericObjPtr<GEOM::GEOM_Object> GeomObjPtr; typedef GenericObjPtr<GEOM::GEOM_Object> GeomObjPtr;
typedef GenericObjPtr<GEOM::GEOM_Field> GeomFieldPtr;
typedef GenericObjPtr<GEOM::GEOM_IBasicOperations> BasicOpPtr; typedef GenericObjPtr<GEOM::GEOM_IBasicOperations> BasicOpPtr;
typedef GenericObjPtr<GEOM::GEOM_ITransformOperations> TransformOpPtr; typedef GenericObjPtr<GEOM::GEOM_ITransformOperations> TransformOpPtr;
typedef GenericObjPtr<GEOM::GEOM_I3DPrimOperations> I3DPrimOpPtr; typedef GenericObjPtr<GEOM::GEOM_I3DPrimOperations> I3DPrimOpPtr;

View File

@ -32,6 +32,7 @@
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include "GEOMImpl_IShapesOperations.hxx" #include "GEOMImpl_IShapesOperations.hxx"
#include "GEOMImpl_IGroupOperations.hxx" #include "GEOMImpl_IGroupOperations.hxx"
#include "GEOMImpl_IFieldOperations.hxx"
#include "GEOMImpl_XAODriver.hxx" #include "GEOMImpl_XAODriver.hxx"
#include "GEOMImpl_IImportExportXAO.hxx" #include "GEOMImpl_IImportExportXAO.hxx"
@ -45,6 +46,14 @@
#include <XAO_Group.hxx> #include <XAO_Group.hxx>
#include <XAO_Field.hxx> #include <XAO_Field.hxx>
#include <XAO_XaoUtils.hxx> #include <XAO_XaoUtils.hxx>
#include <XAO_BooleanField.hxx>
#include <XAO_IntegerField.hxx>
#include <XAO_DoubleField.hxx>
#include <XAO_StringField.hxx>
#include <XAO_BooleanStep.hxx>
#include <XAO_IntegerStep.hxx>
#include <XAO_DoubleStep.hxx>
#include <XAO_StringStep.hxx>
#include <Basics_OCCTVersion.hxx> #include <Basics_OCCTVersion.hxx>
@ -67,6 +76,7 @@
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
#include <TColStd_HArray1OfByte.hxx> #include <TColStd_HArray1OfByte.hxx>
#include <TColStd_HArray1OfReal.hxx>
#else #else
#include <TDataStd_HArray1OfByte.hxx> #include <TDataStd_HArray1OfByte.hxx>
#endif #endif
@ -100,6 +110,7 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations"); MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID()); myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
myFieldOperations = new GEOMImpl_IFieldOperations(GetEngine(), GetDocID());
} }
//============================================================================= //=============================================================================
@ -112,6 +123,7 @@ GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations"); MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
delete myShapesOperations; delete myShapesOperations;
delete myGroupOperations; delete myGroupOperations;
delete myFieldOperations;
} }
//============================================================================= //=============================================================================
@ -837,7 +849,9 @@ XAO::Dimension shapeEnumToDimension(const TopAbs_ShapeEnum& shape)
return dim; return dim;
} }
void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry) void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList,
XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry)
{ {
// add the groups // add the groups
std::list<Handle(GEOM_Object)>::iterator groupIterator = groupList.begin(); std::list<Handle(GEOM_Object)>::iterator groupIterator = groupList.begin();
@ -888,9 +902,96 @@ void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> gro
} }
} }
void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry) void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Field)> fieldList,
XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry)
{ {
// TODO std::list<Handle(GEOM_Field)>::iterator fieldIterator = fieldList.begin();
while (fieldIterator != fieldList.end())
{
Handle(GEOM_Field) currField = (*fieldIterator++);
int fdim = currField->GetDimension();
int ftype = currField->GetDataType();
int nbComponents = currField->GetNbComponents();
std::string name = currField->GetName().ToCString();
XAO::Field* field = xaoObject->addField((XAO::Type)ftype, (XAO::Dimension)fdim, nbComponents, name);
Handle(TColStd_HArray1OfExtendedString) components = currField->GetComponents();
std::cout << "nb comp " << nbComponents << std::endl;
std::cout << components->Lower() << " - " << components->Upper() << std::endl;
for (int i = components->Lower(), j = 0; i <= components->Upper(); ++i, ++j)
{
field->setComponentName(j, TCollection_AsciiString(components->Value(i)).ToCString());
}
std::list< Handle(GEOM_FieldStep)> steps = currField->GetSteps();
std::list<Handle(GEOM_FieldStep)>::iterator stepIterator = steps.begin();
while (stepIterator != steps.end())
{
Handle(GEOM_FieldStep) currStep = (*stepIterator++);
XAO::Step* step = field->addNewStep(currStep->GetID());
step->setStamp(currStep->GetStamp());
switch (ftype)
{
case 0: // bool
{
XAO::BooleanStep* bs = (XAO::BooleanStep*)step;
Handle(TColStd_HArray1OfInteger) bvalues = currStep->GetIntValues();
std::vector<bool> bv;
bv.reserve(bvalues->Upper());
for ( int i = bvalues->Lower(), nb = bvalues->Upper(); i <= nb; ++i )
{
bv.push_back(bvalues->Value(i) != 0);
}
bs->setValues(bv);
break;
}
case 1: // integer
{
XAO::IntegerStep* is = (XAO::IntegerStep*)step;
Handle(TColStd_HArray1OfInteger) ivalues = currStep->GetIntValues();
std::vector<int> iv;
iv.reserve(ivalues->Upper());
for ( int i = ivalues->Lower(), nb = ivalues->Upper(); i <= nb; ++i )
{
iv.push_back(ivalues->Value(i));
}
is->setValues(iv);
break;
}
case 2: // double
{
XAO::DoubleStep* ds = (XAO::DoubleStep*)step;
Handle(TColStd_HArray1OfReal) dvalues = currStep->GetDoubleValues();
std::vector<double> dv;
dv.reserve(dvalues->Upper());
for ( int i = dvalues->Lower(), nb = dvalues->Upper(); i <= nb; ++i )
{
dv.push_back(dvalues->Value(i));
}
ds->setValues(dv);
break;
}
case 3: // string
{
XAO::StringStep* ss = (XAO::StringStep*)step;
Handle(TColStd_HArray1OfExtendedString) svalues = currStep->GetStringValues();
std::vector<std::string> sv;
sv.reserve(svalues->Upper());
for ( int i = svalues->Lower(), nb = svalues->Upper(); i <= nb; ++i )
{
sv.push_back(TCollection_AsciiString(svalues->Value(i)).ToCString());
}
ss->setValues(sv);
break;
}
}
}
}
} }
void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry) void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry)
@ -939,7 +1040,7 @@ void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shap
//============================================================================= //=============================================================================
bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape, bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
std::list<Handle(GEOM_Object)> groupList, std::list<Handle(GEOM_Object)> groupList,
std::list<Handle(GEOM_Object)> fieldList, std::list<Handle(GEOM_Field)> fieldList,
const char* author, const char* author,
const char* fileName) const char* fileName)
{ {
@ -1000,7 +1101,7 @@ bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
pd << "], ["; pd << "], [";
if (fieldList.size() > 0) if (fieldList.size() > 0)
{ {
std::list<Handle(GEOM_Object)>::iterator itField = fieldList.begin(); std::list<Handle(GEOM_Field)>::iterator itField = fieldList.begin();
pd << (*itField++); pd << (*itField++);
while (itField != fieldList.end()) while (itField != fieldList.end())
{ {
@ -1158,7 +1259,102 @@ bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
function = group->GetLastFunction(); function = group->GetLastFunction();
} }
// TODO: create the fields // create the fields
int nbFields = xaoObject->countFields();
for (int i = 0; i < nbFields; ++i)
{
XAO::Field* xaoField = xaoObject->getField(i);
Handle(TColStd_HArray1OfExtendedString) components = new TColStd_HArray1OfExtendedString(0, xaoField->countComponents());
for (int j = 0; j < xaoField->countComponents(); ++j)
{
components->SetValue(j, (TCollection_ExtendedString)xaoField->getComponentName(j).c_str());
}
Handle(GEOM_Field) field = myFieldOperations->CreateField(shape,
xaoField->getName().c_str(),
(int)xaoField->getType(),
(int)xaoField->getDimension(),
components);
switch (xaoField->getType())
{
case XAO::BOOLEAN:
{
XAO::BooleanField* bfield = (XAO::BooleanField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::BooleanStep* bstep = bfield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(bstep->getStep(), bstep->getStamp());
Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, bstep->countValues());
std::vector<bool> bvalues = bstep->getValues();
for (int k = 0; k < bstep->countValues(); ++k)
{
values->SetValue(0, bvalues[k] ? 1 : 0);
}
step->SetValues(values);
}
break;
}
case XAO::INTEGER:
{
XAO::IntegerField* ifield = (XAO::IntegerField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::IntegerStep* istep = ifield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(istep->getStep(), istep->getStamp());
Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, istep->countValues());
std::vector<int> ivalues = istep->getValues();
for (int k = 0; k < istep->countValues(); ++k)
{
values->SetValue(0, ivalues[k]);
}
step->SetValues(values);
}
break;
}
case XAO::DOUBLE:
{
XAO::DoubleField* dfield = (XAO::DoubleField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::DoubleStep* dstep = dfield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(dstep->getStep(), dstep->getStamp());
Handle(TColStd_HArray1OfReal) values = new TColStd_HArray1OfReal(0, dstep->countValues());
std::vector<double> dvalues = dstep->getValues();
for (int k = 0; k < dstep->countValues(); ++k)
{
values->SetValue(0, dvalues[k]);
}
step->SetValues(values);
}
break;
}
case XAO::STRING:
{
XAO::StringField* sfield = (XAO::StringField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::StringStep* sstep = sfield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(sstep->getStep(), sstep->getStamp());
Handle(TColStd_HArray1OfExtendedString) values = new TColStd_HArray1OfExtendedString(0, sstep->countValues());
std::vector<std::string> svalues = sstep->getValues();
for (int k = 0; k < sstep->countValues(); ++k)
{
values->SetValue(0, TCollection_ExtendedString(svalues[k].c_str()));
}
step->SetValues(values);
}
break;
}
}
fields->Append(field);
}
// make a Python command // make a Python command
GEOM::TPythonDump pd(function); GEOM::TPythonDump pd(function);

View File

@ -26,6 +26,7 @@
#include "GEOM_IOperations.hxx" #include "GEOM_IOperations.hxx"
#include "GEOM_Engine.hxx" #include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx" #include "GEOM_Object.hxx"
#include "GEOM_Field.hxx"
#include <Basics_OCCTVersion.hxx> #include <Basics_OCCTVersion.hxx>
@ -40,6 +41,7 @@
class GEOMImpl_IShapesOperations; class GEOMImpl_IShapesOperations;
class GEOMImpl_IGroupOperations; class GEOMImpl_IGroupOperations;
class GEOMImpl_IFieldOperations;
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
class Handle_TColStd_HArray1OfByte; class Handle_TColStd_HArray1OfByte;
@ -104,7 +106,7 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape, Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape,
std::list<Handle(GEOM_Object)> groupList, std::list<Handle(GEOM_Object)> groupList,
std::list<Handle(GEOM_Object)> fieldList, std::list<Handle(GEOM_Field)> fieldList,
const char* author, const char* author,
const char* fileName); const char* fileName);
@ -121,7 +123,7 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
int shapeType, int dim, int shapeType, int dim,
Handle(TColStd_HSequenceOfTransient)& subshapeList); Handle(TColStd_HSequenceOfTransient)& subshapeList);
void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry); void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry);
void exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject, void exportFields(std::list<Handle(GEOM_Field)> fieldList, XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry); XAO::BrepGeometry* geometry);
void exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject, void exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry); XAO::BrepGeometry* geometry);
@ -131,6 +133,7 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Handle(Resource_Manager) myResMgrUser; Handle(Resource_Manager) myResMgrUser;
GEOMImpl_IShapesOperations* myShapesOperations; GEOMImpl_IShapesOperations* myShapesOperations;
GEOMImpl_IGroupOperations* myGroupOperations; GEOMImpl_IGroupOperations* myGroupOperations;
GEOMImpl_IFieldOperations* myFieldOperations;
}; };
#endif #endif

View File

@ -373,8 +373,10 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape, CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields, const GEOM::ListOfGO& groups,
const char* author, const char* fileName) const GEOM::ListOfFields& fields,
const char* author,
const char* fileName)
{ {
bool isGood = false; bool isGood = false;
// Set a not done flag // Set a not done flag
@ -395,10 +397,10 @@ CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
// Get the reference fields // Get the reference fields
ind = 0; ind = 0;
std::list<Handle(GEOM_Object)> fieldsObj; std::list<Handle(GEOM_Field)> fieldsObj;
for (; ind < fields.length(); ind++) for (; ind < fields.length(); ind++)
{ {
Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]); Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind]));
if (fobj.IsNull()) return false; if (fobj.IsNull()) return false;
fieldsObj.push_back(fobj); fieldsObj.push_back(fobj);
} }
@ -427,14 +429,14 @@ CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
GEOM::GEOM_Object_out shape, GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out subShapes,
GEOM::ListOfGO_out groups, GEOM::ListOfGO_out groups,
GEOM::ListOfGO_out fields) GEOM::ListOfFields_out fields)
{ {
GEOM::GEOM_Object_var vshape; GEOM::GEOM_Object_var vshape;
shape = vshape._retn(); shape = vshape._retn();
subShapes = new GEOM::ListOfGO; subShapes = new GEOM::ListOfGO;
groups = new GEOM::ListOfGO; groups = new GEOM::ListOfGO;
fields = new GEOM::ListOfGO; fields = new GEOM::ListOfFields;
// Set a not done flag // Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
@ -469,7 +471,8 @@ CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
fields->length(n); fields->length(n);
for (int i = 1; i <= n; i++) for (int i = 1; i <= n; i++)
{ {
(*fields)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedFields->Value(i))); // TODO: FPS
//(*fields)[i - 1] = GetObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i)));
} }
shape = GetObject(hshape); shape = GetObject(hshape);

View File

@ -75,7 +75,7 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape, CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& groups,
const GEOM::ListOfGO& fields, const GEOM::ListOfFields& fields,
const char* author, const char* author,
const char* fileName); const char* fileName);
@ -83,7 +83,7 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
GEOM::GEOM_Object_out shape, GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out subShapes,
GEOM::ListOfGO_out groups, GEOM::ListOfGO_out groups,
GEOM::ListOfGO_out fields); GEOM::ListOfFields_out fields);
::GEOMImpl_IInsertOperations* GetOperations() ::GEOMImpl_IInsertOperations* GetOperations()
{ return (::GEOMImpl_IInsertOperations*)GetImpl(); } { return (::GEOMImpl_IInsertOperations*)GetImpl(); }

View File

@ -3332,7 +3332,7 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup)
// ExportXAO // ExportXAO
//============================================================================= //=============================================================================
CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape, CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields, const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
const char* author, const char* fileName) const char* author, const char* fileName)
{ {
beginService( " GEOM_Superv_i::ExportXAO" ); beginService( " GEOM_Superv_i::ExportXAO" );
@ -3347,7 +3347,7 @@ CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
// ImportXAO // ImportXAO
//============================================================================= //=============================================================================
CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape, CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields) GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields)
{ {
return false; return false;
} }

View File

@ -692,10 +692,10 @@ public:
// ImportExport Operations // // ImportExport Operations //
//-----------------------------------------------------------// //-----------------------------------------------------------//
CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape, CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields, const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
const char* author, const char* fileName); const char* author, const char* fileName);
CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape, CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields); GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields);
//-----------------------------------------------------------// //-----------------------------------------------------------//
// Advanced Operations // // Advanced Operations //

View File

@ -22,8 +22,10 @@
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SUIT_OverrideCursor.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <SalomeApp_Study.h> #include <SalomeApp_Study.h>
#include <SalomeApp_Tools.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <QLabel> #include <QLabel>
@ -32,7 +34,6 @@
#include <QListWidget> #include <QListWidget>
#include <QFileDialog> #include <QFileDialog>
#include <QMap> #include <QMap>
//#include <ui_ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.h>
// OCCT Includes // OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
@ -43,7 +44,6 @@
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include "ImportExportGUI_ExportXAODlg.h" #include "ImportExportGUI_ExportXAODlg.h"
//#include "ImportExportGUI_Widgets.h"
//================================================================================= //=================================================================================
// Constructor // Constructor
@ -137,7 +137,7 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometry
lstGroups = new QListWidget(gbxFilter); lstGroups = new QListWidget(gbxFilter);
lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection); lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection);
lstFields = new QListWidget(gbxFilter); lstFields = new QListWidget(gbxFilter);
lstFields ->setSelectionMode(QAbstractItemView::ExtendedSelection); lstFields->setSelectionMode(QAbstractItemView::ExtendedSelection);
line++; col = 0; line++; col = 0;
gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1); gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1);
@ -184,7 +184,6 @@ void ImportExportGUI_ExportXAODlg::Init()
connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked()));
initName(tr("GEOM_EXPORTXAO")); initName(tr("GEOM_EXPORTXAO"));
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -217,11 +216,25 @@ void ImportExportGUI_ExportXAODlg::processObject()
item->setData(Qt::UserRole, QVariant(i)); item->setData(Qt::UserRole, QVariant(i));
item->setText(GEOMBase::GetName(groups[i])); item->setText(GEOMBase::GetName(groups[i]));
lstGroups->addItem(item); lstGroups->addItem(item);
item->setSelected(true);
m_groups.append(GEOM::GeomObjPtr(groups[i].in())); m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
} }
lstGroups->sortItems(Qt::AscendingOrder); lstGroups->sortItems(Qt::AscendingOrder);
// TODO: add fields // add fields
GEOM::GEOM_IFieldOperations_var fieldOp = getGeomEngine()->GetIFieldOperations(getStudyId());
GEOM::ListOfFields_var fields = fieldOp->GetFields(m_mainObj);
for (int i = 0, n = fields->length(); i < n; i++)
{
QListWidgetItem* item = new QListWidgetItem();
item->setData(Qt::UserRole, QVariant(i));
item->setText(fields[i]->GetName());
lstFields->addItem(item);
item->setSelected(true);
m_fields.append(GEOM::GeomFieldPtr(fields[i].in()));
}
lstFields->sortItems(Qt::AscendingOrder);
} }
} }
@ -231,8 +244,10 @@ void ImportExportGUI_ExportXAODlg::processObject()
//================================================================================= //=================================================================================
void ImportExportGUI_ExportXAODlg::ClickOnOk() void ImportExportGUI_ExportXAODlg::ClickOnOk()
{ {
setIsApplyAndClose(true);
if (ClickOnApply()) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
setIsApplyAndClose(false);
} }
//================================================================================= //=================================================================================
@ -241,10 +256,46 @@ void ImportExportGUI_ExportXAODlg::ClickOnOk()
//================================================================================= //=================================================================================
bool ImportExportGUI_ExportXAODlg::ClickOnApply() bool ImportExportGUI_ExportXAODlg::ClickOnApply()
{ {
if (!onAccept()) if (!isApplyAndClose())
return false; {
setIsDisableBrowsing(true);
setIsDisplayResult(false);
}
initName(); QString msg;
if (!isValid(msg))
{
showError(msg);
return false;
}
SUIT_OverrideCursor wc;
SUIT_Session::session()->activeApplication()->putInfo("");
try
{
if (openCommand())
if (!execute(/*isApplyAndClose()*/))
{
abortCommand();
showError();
return false;
}
}
catch (const SALOME::SALOME_Exception& e)
{
SalomeApp_Tools::QtCatchCorbaException(e);
abortCommand();
return false;
}
commitCommand();
if (!isApplyAndClose())
{
setIsDisableBrowsing(false);
setIsDisplayResult(true);
}
processObject();
return true; return true;
} }
@ -343,7 +394,7 @@ bool ImportExportGUI_ExportXAODlg::isValid(QString& msg)
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects) bool ImportExportGUI_ExportXAODlg::execute()
{ {
bool res = false; bool res = false;
@ -364,8 +415,9 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
// get selected fields // get selected fields
QList<QListWidgetItem*> selFields = lstFields->selectedItems(); QList<QListWidgetItem*> selFields = lstFields->selectedItems();
GEOM::ListOfGO_var fields = new GEOM::ListOfGO(); GEOM::ListOfFields_var fields = new GEOM::ListOfFields();
fields->length(m_fields.count()); fields->length(m_fields.count());
i = 0;
for (QList<QListWidgetItem*>::iterator it = selFields.begin(); it != selFields.end(); ++it) for (QList<QListWidgetItem*>::iterator it = selFields.begin(); it != selFields.end(); ++it)
{ {
QListWidgetItem* item = (*it); QListWidgetItem* item = (*it);

View File

@ -44,7 +44,7 @@ protected:
// redefined from GEOMBase_Helper // redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid(QString&); virtual bool isValid(QString&);
virtual bool execute(ObjectList&); virtual bool execute();
private: private:
void Init(); void Init();
@ -54,7 +54,7 @@ private:
private: private:
GEOM::GEOM_Object_var m_mainObj; GEOM::GEOM_Object_var m_mainObj;
QList<GEOM::GeomObjPtr> m_groups; QList<GEOM::GeomObjPtr> m_groups;
QList<GEOM::GeomObjPtr> m_fields; QList<GEOM::GeomFieldPtr> m_fields;
QLineEdit* ledShape; QLineEdit* ledShape;
QLineEdit* ledFileName; QLineEdit* ledFileName;
QLineEdit* ledAuthor; QLineEdit* ledAuthor;
@ -67,7 +67,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
// void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void btnFileSelectClicked(); void btnFileSelectClicked();

View File

@ -214,7 +214,8 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
QString fileName = ledFileName->text(); QString fileName = ledFileName->text();
GEOM::GEOM_Object_var shape; GEOM::GEOM_Object_var shape;
GEOM::ListOfGO_var groups, fields, subShapes; GEOM::ListOfGO_var groups, subShapes;
GEOM::ListOfFields_var fields;
GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation()); GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
res = ieOp->ImportXAO(fileName.toStdString().c_str(), shape, subShapes, groups, fields); res = ieOp->ImportXAO(fileName.toStdString().c_str(), shape, subShapes, groups, fields);
@ -239,7 +240,7 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
} }
for (int i = 0; i < fields->length(); i++) for (int i = 0; i < fields->length(); i++)
{ {
objects.push_back(GEOM::GEOM_Object::_duplicate(fields[i])); //objects.push_back(GEOM::GEOM_Field::_duplicate(fields[i]));
} }
return res; return res;

View File

@ -67,6 +67,8 @@ throw (XAO_Exception)
return countFaces(); return countFaces();
if (dim == XAO::SOLID) if (dim == XAO::SOLID)
return countSolids(); return countSolids();
if (dim == XAO::WHOLE)
return 1;
throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim); throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
} }

View File

@ -592,12 +592,16 @@ namespace {
int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1); int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1);
xmlChar* data = xmlNodeGetContent(valNode->children); xmlChar* data = xmlNodeGetContent(valNode->children);
if (data == NULL) std::string value = (char*)data;
if (data != NULL)
{
value = (char*)data;
}
else if (step->getType() != XAO::STRING)
{ {
throw XAO_Exception(MsgBuilder() << "Line " << valNode->line << ": no content for value."); throw XAO_Exception(MsgBuilder() << "Line " << valNode->line << ": no content for value.");
} }
std::string value = (char*)data;
step->setStringValue(index, component, value); step->setStringValue(index, component, value);
} }
} }