From a616d40f9eee86639c188d8a115a9a9c85a31e60 Mon Sep 17 00:00:00 2001 From: nri Date: Fri, 16 May 2003 16:55:26 +0000 Subject: [PATCH] NRI : Correction 1.1a version. --- src/VISUGUI/VisuGUI.cxx | 133 ++--- src/VISUGUI/VisuGUI.py | 5 +- src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx | 5 +- src/VISUGUI/VisuGUI_NonIsometricDlg.cxx | 12 +- src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 6 +- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 8 +- src/VISU_I/VISUConfig.hh | 20 +- src/VISU_I/VISU_Convertor.cxx | 145 +---- src/VISU_I/VISU_Convertor.hxx | 22 +- src/VISU_I/VISU_Convertor_impl.cxx | 60 +- src/VISU_I/VISU_Convertor_impl.hxx | 6 + src/VISU_I/VISU_CorbaMedConvertor.cxx | 753 +++++++++--------------- src/VISU_I/VISU_CorbaMedConvertor.hxx | 127 +++- src/VISU_I/VISU_DatConvertor.cxx | 4 +- src/VISU_I/VISU_MedConvertor.cxx | 94 ++- src/VISU_I/VISU_PrsObject_i.cc | 87 +-- src/VISU_I/VISU_PrsObject_i.hh | 1 - src/VISU_I/VISU_Result_i.cc | 382 ++++++------ src/VISU_I/VISU_Result_i.hh | 16 +- src/VISU_I/VISU_Table_i.cc | 2 - src/VISU_I/VISU_TimeAnimation.cxx | 1 + src/VISU_I/VISU_ViewManager_i.cc | 25 +- 22 files changed, 791 insertions(+), 1123 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 573f74b5..b95a9273 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -94,7 +94,6 @@ using namespace std; #include #include #include -#include // Open CASCADE Include #include @@ -218,7 +217,7 @@ CORBA::Object_var GetSelectedObj(string& theComment, Handle(SALOME_InteractiveOb if(!anIOR->_is_nil()){ CORBA::String_var aValue = anIOR->Value(); if(strcmp(aValue,"") != 0){ - CORBA::ORB_ptr anORB = VISU::Base_i::GetORB(); + CORBA::ORB_var anORB = VISU::GetORB(); CORBA::Object_var anObject = anORB->string_to_object(aValue); return anObject; } @@ -298,21 +297,9 @@ VISU::Base_i* GetSelectedVisuObj(){ if (IObject->hasEntry()){ SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(IObject->getEntry()); if(!aSObject->_is_nil()){ - SALOMEDS::SComponent_var comp = aSObject->GetFatherComponent(); - if ( !comp->_is_nil() ) { - SALOMEDS::GenericAttribute_var anAttr; - if (comp->FindAttribute(anAttr, "AttributeName")) { - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - if (QString(aName->Value()) == QString("Visu")) { - CORBA::Object_var aObject = VISU::SObjectToObject(aSObject); - if(!CORBA::is_nil(aObject)) { - PortableServer::Servant aServant = VISU::GetServant(aObject); - if (aServant) - return dynamic_cast(aServant); - } - } - } - } + CORBA::Object_var aObject = VISU::SObjectToObject(aSObject); + if(!CORBA::is_nil(aObject)) + return dynamic_cast(VISU::GetServant(aObject)); } } } @@ -460,7 +447,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 122: { - //visuGUI->ExportToFile(); + visuGUI->ExportToFile(); break; } @@ -1620,7 +1607,7 @@ void VisuGUI::CreateMesh() { timer.Show(); #endif if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ - //vtkRenderer *aRenderer = vf->getRenderer(); + vtkRenderer *aRenderer = vf->getRenderer(); //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); //visuGUI->ShowTrihedron(true); #ifdef CHECKTIME @@ -1628,8 +1615,7 @@ void VisuGUI::CreateMesh() { timer.Start(); #endif vf->AddActor(anActor); - vf->AddActor(anActor->EdgeDevice); - // vf->getRenderer()->AddActor(anActor->EdgeDevice); + vf->getRenderer()->AddActor(anActor->EdgeDevice); vf->getRenderer()->ResetCameraClippingRange(); vf->onViewFitAll(); #ifdef CHECKTIME @@ -1638,7 +1624,7 @@ void VisuGUI::CreateMesh() { timer.Show(); #endif } - //myActiveStudy->updateObjBrowser(); //not necessary + myActiveStudy->updateObjBrowser(); //update Object browser myDesktop->putInfo("Ready"); } @@ -1659,25 +1645,33 @@ static void ShrinkMesh(VISU_Actor *Actor){ shrink->Delete(); Actor->EdgeDevice->VisibilityOff(); }else{ - vtkDataSetMapper* aMapper = vtkDataSetMapper::SafeDownCast(Actor->GetInitialMapper()); - if (aMapper) { - vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); - aTransformFilter->SetInput(aMapper->GetPolyDataMapper()->GetInput()); - aTransformFilter->SetTransform (VisuGUI::GetVtkViewFrame()->getNonIsometricTransform()); - - //create new mapper - aMapper = vtkDataSetMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( Actor->GetMapper()); - Actor->SetMapper (aMapper); - - aTransformFilter->Delete(); - aMapper->Delete(); - } else { - vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - mapper->SetInput(Actor->DataSource); + vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); + // mpv: we wish to remove shrink filter only instead of all filters ignore +// mapper->SetInput(Actor->DataSource); + vtkDataObject* anObject = mapper->GetInput(); + vtkSource* aPrevSource = (vtkSource*)mapper; + while(anObject != Actor->DataSource) { + vtkShrinkFilter* aShrink = vtkShrinkFilter::SafeDownCast(anObject->GetSource()); + if (aShrink) { + vtkSource* aSource = aShrink->GetInput()->GetSource(); + vtkDataObject** Inputs = aPrevSource->GetInputs(); + vtkDataObject** Outputs = aSource->GetOutputs(); + Outputs[0]->UnRegister(aShrink); + Inputs[0]->UnRegister(aShrink); + Outputs[0]->Register(aPrevSource); + Inputs[0]->Register(aSource); + Inputs[0] = aSource->GetOutputs()[0]; + aSource->Modified(); + aSource->Update(); + + mapper->Update(); + break; + } + aPrevSource = anObject->GetSource(); + anObject = aPrevSource->GetInputs()[0]; } - //Actor->GetMapper()->Update(); + + Actor->IsShrunk = false; if ( Actor->GetProperty()->GetRepresentation() == 2 ) Actor->EdgeDevice->VisibilityOn(); @@ -2410,6 +2404,7 @@ void VisuGUI::Sweep() { if (aDefPrs) { float aScale = aDefPrs->GetScale(); bool isColored = aDefPrs->isColored(); + vtkWarpVector* aWarp = vtkWarpVector::New(); if((VISU::Entity)aDefPrs->GetField()->myEntity == VISU::CELL) { vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); @@ -2518,13 +2513,22 @@ void VisuGUI::ImportMedField() { if(!anIOR->_is_nil()){ CORBA::String_var aValue = anIOR->Value(); if(strcmp(aValue,"") != 0){ - CORBA::ORB_ptr anORB = VISU::Base_i::GetORB(); + CORBA::ORB_var anORB = VISU::GetORB(); CORBA::Object_var anObject = anORB->string_to_object(aValue); if ( !CORBA::is_nil( anObject ) ) { - //SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject ); - SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); - if( !CORBA::is_nil( aMED ) ) { - VisuGUI::myComponent->ImportMed( aSObject ); + SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject ); + if( !CORBA::is_nil( aField ) ) { + VisuGUI::myComponent->ImportMed( aField ); + continue; + } + SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject ); + if( !CORBA::is_nil( aMesh ) ) { + VisuGUI::myComponent->ImportMedMesh( aMesh ); + continue; + } + SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject ); + if( !CORBA::is_nil( aSupport ) ) { + VisuGUI::myComponent->ImportMedSupport( aSupport ); continue; } } @@ -2853,7 +2857,7 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri case VISU::TRESULT: //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh())); - //thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile())); + thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile())); //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs())); break; @@ -2942,7 +2946,7 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar())); if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) && isVTKViewer) - thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep())); + thePopup->insertItem("Animate", visuGUI, SLOT(Sweep())); } if (isVTKViewer) { if ( theParent == "Viewer" && @@ -2978,11 +2982,6 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri } else { // possibly this is the MED field/mesh and suppot objects - SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); - if( !CORBA::is_nil( aMED ) ) { - thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) ); - return false; - } /*CORBA::Object_var anObj = SALOME_MED::FIELD::_narrow( anObject ); if( !CORBA::is_nil( anObj ) ) { thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); @@ -3438,7 +3437,7 @@ PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \ if(pResult){ \ if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \ QApplication::setOverrideCursor( Qt::waitCursor ); \ - VISU::VISU_Gen_var aVisuGen = VISU::Base_i::GetVisuGenInter(); \ + VISU::VISU_Gen_var aVisuGen = VISU::GetVisu(); \ CORBA::Object_var anObject = \ aVisuGen->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \ QApplication::restoreOverrideCursor(); \ @@ -3447,7 +3446,7 @@ PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \ } \ } else { \ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \ - tr ("The presentation can't be built."), \ + tr ("The presentation can't be builded."), \ tr ("VISU_BUT_OK") ); \ } \ return NULL; \ @@ -3538,29 +3537,21 @@ void VisuGUI::ImportFromFile(){ //flt.append( "Exportable Files (*.med *.dat)" ); //flt.append( "Dat Files (*.dat)" ); flt.append( "Med Files (*.med)" ); - flt.append( "Dat Files (*.xls)" ); QString aDir = getVisuInputDir(); - QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - aDir,flt,tr("Import From File"),true); - if(aFileInfo.exists()){ - QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); - aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath()); + QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + aDir,flt,tr("Import From File"),true); + if(!aFile.isEmpty()){ + QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." ); + aDir = QAD_Tools::getDirFromPath(aFile); QAD_CONFIG->addSetting("Visu:InputDir",aDir); QApplication::setOverrideCursor( Qt::waitCursor ); - - CORBA::Object_var anObject; - if(aFileInfo.extension(false) == "med") - anObject = myComponent->ImportFile(aFileInfo.filePath()); - else if(aFileInfo.extension(false) == "xls") - anObject = myComponent->ImportTables(aFileInfo.filePath()); - - if(CORBA::is_nil(anObject)) + VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1()); + if(aResult->_is_nil()) QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), tr ("There is an error in imported file"), tr ("VISU_BUT_OK") ); else - QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported."); - + QAD_Application::getDesktop()->putInfo(aFile+" imported."); myActiveStudy->updateObjBrowser(); //update Object browser QApplication::restoreOverrideCursor(); } @@ -3581,7 +3572,7 @@ void VisuGUI::ExportToFile(){ QAD_CONFIG->addSetting("Visu:OutputDir",aDir); if(VISU::Result_i* aResult = dynamic_cast(aBase)){ try{ - //APO - aResult->GetInput()->ToFile(aFile.latin1()); + aResult->GetInput()->ToFile(aFile.latin1()); QAD_Application::getDesktop()->putInfo(aFile+" exported."); }catch(...){ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), diff --git a/src/VISUGUI/VisuGUI.py b/src/VISUGUI/VisuGUI.py index 83c96fb4..5cf88ec8 100644 --- a/src/VISUGUI/VisuGUI.py +++ b/src/VISUGUI/VisuGUI.py @@ -108,12 +108,13 @@ def AddTablesInStudyFromFile(ffile): myBuilder = myStudy.NewBuilder() # >>> Getting (loading) VISU component ======================================= - myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu") + myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") myComponent = myStudy.FindComponent("VISU") if not myComponent: myComponent = myBuilder.NewComponent("VISU") aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") - aName.SetValue("Visu") + #aName.SetValue("Visu") + aName.SetValue( salome.sg.getComponentUserName("VISU") ) myBuilder.DefineComponentInstance(myComponent,myVisu) pass diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index 3e8222a9..a5cc4f61 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -8,7 +8,6 @@ using namespace std; // $Header$ #include "VisuGUI_IsoSurfacesDlg.h" -#include #include #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -37,14 +36,14 @@ VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg() QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" ); TopGroupLayout->addWidget( LabelMin, 0, 0 ); - MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinIso = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 ); MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MinIso->setMinimumSize( 70, 0 ); TopGroupLayout->addWidget( MinIso, 0, 1 ); QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" ); TopGroupLayout->addWidget( LabelMax, 1, 0 ); - MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1); + MaxIso = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1); MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MaxIso->setMinimumSize( 70, 0 ); TopGroupLayout->addWidget( MaxIso, 1, 1 ); diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx index ab983f84..8cf133c2 100644 --- a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx @@ -87,7 +87,7 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n // Create "X" label QLabel* TextLabelX = new QLabel( "X", GroupBox, "TextLabelX" ); TextLabelX->setAlignment( int( QLabel::AlignCenter ) ); - //NRI TextLabelX->setFont( m_font14bi ); + TextLabelX->setFont( m_font14bi ); glGroupBox->addWidget ( TextLabelX, 0, 2 ); // Create combobox for selecting scaling function on a X axis @@ -104,7 +104,7 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n // Create informative label about the applying scaling function on a X axis m_lXFunction = new QLabel( GroupBox, "m_lXFunction" ); - //NRI m_lXFunction->setFont( m_font14bi ); + m_lXFunction->setFont( m_font14bi ); m_lXFunction->setAlignment( int( QLabel::AlignCenter ) ); glGroupBox->addWidget(m_lXFunction, 3, 2 ); @@ -113,7 +113,7 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n // Create "Y" label QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" ); TextLabelY->setAlignment( int( QLabel::AlignCenter ) ); - //NRI TextLabelY->setFont( m_font14bi ); + TextLabelY->setFont( m_font14bi ); glGroupBox->addWidget ( TextLabelY, 0, 3 ); // Create combobox for selecting scaling function on a Y axis @@ -131,7 +131,7 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n // Create informative label about the applying scaling function on a Y axis m_lYFunction = new QLabel( GroupBox, "m_lYFunction" ); m_lYFunction->setAlignment( int( QLabel::AlignCenter ) ); - //NRI m_lYFunction->setFont( m_font14bi ); + m_lYFunction->setFont( m_font14bi ); glGroupBox->addWidget(m_lYFunction, 3, 3 ); FillComboBox( m_cbYfunction ); @@ -139,7 +139,7 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n // Create "Z" label QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" ); TextLabelZ->setAlignment( int( QLabel::AlignCenter ) ); - //NRI TextLabelZ->setFont( m_font14bi ); + TextLabelZ->setFont( m_font14bi ); glGroupBox->addWidget ( TextLabelZ, 0, 4 ); // Create combobox for selecting scaling function on a Z axis @@ -157,7 +157,7 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n // Create informative label about the applying scaling function on a Z axis m_lZFunction = new QLabel( GroupBox, "m_lZFunction" ); m_lZFunction->setAlignment( int( QLabel::AlignCenter ) ); - //NRI m_lZFunction->setFont( m_font14bi ); + m_lZFunction->setFont( m_font14bi ); glGroupBox->addWidget(m_lZFunction, 3, 4 ); FillComboBox( m_cbZfunction ); diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 26be0c44..3b9b32ee 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -8,7 +8,6 @@ using namespace std; // $Header$ #include "VisuGUI_ScalarBarDlg.h" -#include #include #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -16,6 +15,7 @@ using namespace std; #include "VISU_Convertor.hxx" +static double MAXVALUE = 1.0E+300; /*! Constructor */ @@ -58,14 +58,14 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" ); RBIrange->setChecked( true ); - MinSpin = new QAD_SpinBoxDbl( RangeGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinSpin = new QAD_SpinBoxDbl( RangeGroup, -MAXVALUE, MAXVALUE, 0.1 ); MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MinSpin->setMinimumWidth( 70 ); MinSpin->setValue( 0 ); QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" ); MinLabel->setBuddy(MinSpin); - MaxSpin = new QAD_SpinBoxDbl( RangeGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MaxSpin = new QAD_SpinBoxDbl( RangeGroup, -MAXVALUE, MAXVALUE, 0.1 ); MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MaxSpin->setMinimumWidth( 70 ); MaxSpin->setValue( 0 ); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index b7a04f4c..edc926a8 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -63,7 +63,7 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) aRangeLayout->addWidget(aMinLbl, 1, 0); myMinVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); myMinVal->setEnabled(myUseRangeChk->isChecked()); - myMinVal->setValue( myAnimator->getMinRange() ); + myMinVal->setValue( 0 ); connect(myMinVal, SIGNAL( valueChanged(double)), this, SLOT( onMinValue(double) )); aRangeLayout->addWidget(myMinVal, 1, 1); @@ -73,7 +73,7 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) aRangeLayout->addWidget(aMaxLbl, 1, 2); myMaxVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); myMaxVal->setEnabled(myUseRangeChk->isChecked()); - myMaxVal->setValue( myAnimator->getMaxRange() ); + myMaxVal->setValue( 0 ); connect(myMaxVal, SIGNAL( valueChanged(double)), this, SLOT( onMaxValue(double) )); aRangeLayout->addWidget(myMaxVal, 1, 3); @@ -516,9 +516,11 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) TopLayout->addMultiCellWidget(aPropCheck, 5, 5, 0, 3); mySaveCheck = new QCheckBox("Save pictures to directory",myPlayFrame); + mySaveCheck->setChecked(false); TopLayout->addMultiCellWidget(mySaveCheck, 6, 6, 0, 3); QLabel* aPathLbl = new QLabel("Path:", myPlayFrame); + aPathLbl->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), aPathLbl, SLOT( setEnabled(bool) )); TopLayout->addWidget(aPathLbl, 7, 0); @@ -533,8 +535,6 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) aBrowseBtn, SLOT( setEnabled(bool) )); connect(aBrowseBtn, SIGNAL( clicked()), this, SLOT( onBrowse() )); - - mySaveCheck->setChecked(false); TopLayout->addWidget(aBrowseBtn, 7, 3); aMainLayout->addWidget(myPlayFrame); diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index 9b73f059..cb14bd17 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -23,8 +23,6 @@ using namespace std; #include CORBA_SERVER_HEADER(MED) #include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) -#include "SALOME_NamingService.hxx" -#include "SALOME_LifeCycleCORBA.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" @@ -33,7 +31,6 @@ using namespace std; namespace VISU{ //=========================================================================== - class VISU_Gen_i; class Base_i : public virtual POA_VISU::Base, public virtual PortableServer::RefCountServantBase { @@ -45,16 +42,6 @@ namespace VISU{ static QMutex* myMutex; static CORBA::ORB_var myOrb; static PortableServer::POA_var myPOA; - static SALOME_NamingService* myNamingService; - static VISU_Gen_i* myVisuGenImpl; - static SALOME_LifeCycleCORBA* myEnginesLifeCycle; - public: - static CORBA::ORB_ptr GetORB() { return myOrb;} - static PortableServer::POA_ptr GetPOA() { return myPOA;} - static SALOME_NamingService* GetNS() { return myNamingService;} - static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;} - static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;} - static VISU_Gen_var GetVisuGenInter(); }; //=========================================================================== class Mutex{ @@ -70,7 +57,7 @@ namespace VISU{ protected: virtual void ToStream(ostrstream& theStr) = 0; public: - string ToString(); + const char* ToString(); virtual const char* GetComment() const = 0; typedef map TRestoringMap; typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, @@ -89,7 +76,9 @@ namespace VISU{ static void DataToStream(ostrstream& theStr, const QString& theName, const double theVal); }; //=========================================================================== - const CORBA::Boolean IsMultifile(); + CORBA::ORB_var GetORB(); + PortableServer::POA_var GetPOA(); + VISU_Gen_var GetVisu(); PortableServer::Servant GetServant(CORBA::Object_ptr theObject); CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject); SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument); @@ -100,6 +89,7 @@ namespace VISU{ CORBA::Boolean theCreateNew = true); string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry, const char* theComment, int IsAllLevels = true); + const CORBA::Boolean IsMultifile(); } #endif diff --git a/src/VISU_I/VISU_Convertor.cxx b/src/VISU_I/VISU_Convertor.cxx index 46a36f9c..138d3cff 100644 --- a/src/VISU_I/VISU_Convertor.cxx +++ b/src/VISU_I/VISU_Convertor.cxx @@ -7,8 +7,6 @@ using namespace std; #include "VISU_Convertor.hxx" -#include -#include #include #include #include @@ -123,30 +121,26 @@ namespace VISU{ } } -const VISU::TMeshMap& VISU_Convertor::GetMeshMap() throw(std::runtime_error&){ - if(!myIsDone) { myIsDone = true; Build();} - return myMeshMap; +const VISU::TMesh* VISU_Convertor::GetMesh(const string& theMeshName) const { + string aMeshName(theMeshName == ""? myMeshMap.begin()->first: theMeshName); + VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(theMeshName); + if(aMeshMapIter == myMeshMap.end()) return NULL; + return &(aMeshMapIter->second); } -const VISU::TField& VISU_Convertor::GetField(const string& theMeshName, - VISU::TEntity theEntity, - const string& theFieldName) - throw (std::runtime_error&) +const VISU::TField* VISU_Convertor::GetField(const string& theMeshName, VISU::TEntity theEntity, + const string& theFieldName) const { - if(!myIsDone) { myIsDone = true; Build();} VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(theMeshName); - if(aMeshMapIter == myMeshMap.end()) - throw std::runtime_error("GetField >> There is no mesh with the name !!!"); + if(aMeshMapIter == myMeshMap.end()) return NULL; const VISU::TMesh& aMesh = aMeshMapIter->second; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMesh.myMeshOnEntityMap.find(theEntity); - if(aMeshOnEntityMapIter == aMesh.myMeshOnEntityMap.end()) - throw std::runtime_error("GetField >> There is no mesh with the entity !!!"); + if(aMeshOnEntityMapIter == aMesh.myMeshOnEntityMap.end()) return NULL; const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(theFieldName); - if(aFieldMapIter == aFieldMap.end()) - throw std::runtime_error("GetField >> There is no field with the name !!!"); - return aFieldMapIter->second; + if(aFieldMapIter == aFieldMap.end()) return NULL; + return &(aFieldMapIter->second); } string VISU_Convertor::GenerateName(const VISU::TField::TTime& aTime){ @@ -180,7 +174,7 @@ string VISU_Convertor::GenerateName(const string& theName, unsigned int theTimeI void parseFile(const char* theFileName) throw(std::runtime_error&){ try{ auto_ptr aCon(CreateConvertor(theFileName)); - const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap(); + const VISU::TMeshMap& aMeshMap = *(aCon->GetMeshMap()); VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; @@ -239,106 +233,9 @@ void parseFile(const char* theFileName) throw(std::runtime_error&){ } } -struct TRow{ - string myTitle; - string myUnit; - vector myValues; -}; - -struct TTable2D{ - string myTitle; - vector myColumnUnits; - vector myColumnTitles; - vector myRows; -}; - -vector aTables; - -int GetLine(ifstream& theStmIn, QString& theString){ - char tmp; - ostrstream aStrOut; - while(theStmIn.get(tmp)){ - aStrOut< aRet(aStrOut.str()); - theString = aRet.get(); - return !theStmIn.eof(); -} - int main(int argc, char** argv){ try{ if(argc > 1){ - ifstream aStmIn; - aStmIn.open(argv[1]); - QString aTmp; - while(!aStmIn.eof()){ - //Find beginning of Table - while(GetLine(aStmIn,aTmp) && aTmp.find("#TITLE:") != 0); - if(aStmIn.eof()) return 0; - cout<<"\n There is new Table2D with Title = "; - TTable2D aTable2D; - while(!aStmIn.eof() && aTmp != "\n"){ - if(aTmp.find("#TITLE:") == 0){ - int aLen = aTmp.find(":") + 1; - aTmp.remove(0,aLen); - QString aTitle = aTmp.stripWhiteSpace(); - aTable2D.myTitle = aTitle; - cout< 0){ - QStringList aStrList = QStringList::split("#TITLE:",aTmp); - QString aTitle = aStrList[1].stripWhiteSpace(); - TRow aRow; - aRow.myTitle = aTitle; - cout<ToString(); + aCon->ToFile((aDir+"a.med").c_str()); + aCon.reset(CreateConvertor((aDir+"a.med").c_str())); + aCon->ToFile((aDir+"a.dat").c_str()); + auto_ptr aCon(CreateConvertor(argv[1])); + aCon->ToFile((aDir+"a.med").c_str()); + aCon.reset(CreateConvertor((aDir+"a.med").c_str())); + aCon->ToFile((aDir+"a.med").c_str()); + aCon.reset(CreateConvertor((aDir+"b.med").c_str())); + aCon->ToFile((aDir+"c.dat").c_str()); */ - aStmIn.close(); return 0; } }catch(std::runtime_error& exc){ - cout<<"Follow exception was accured :\n"< class vtk_ptr { private: _Tp* _M_ptr; @@ -163,29 +162,34 @@ class VISU_Convertor{ protected: std::string myName; VISU::TMeshMap myMeshMap; - int myIsDone; public: virtual ~VISU_Convertor(){}; - virtual const string& GetName() { return myName;} - virtual int IsDone() const { return myIsDone;} typedef vtkUnstructuredGridReader OutputType; - virtual VISU_Convertor* Build() throw (std::runtime_error&) = 0; + const char* GetName() { return myName.c_str();} + virtual OutputType* GetMeshOnEntity(const string& theMeshName, const VISU::TEntity& theEntity, const string& theFamilyName = "") throw(std::runtime_error&) = 0; + virtual OutputType* GetMeshOnGroup(const string& theMeshName, const string& theGroupName) throw(std::runtime_error&) = 0; + virtual OutputType* GetFieldOnMesh(const string& theMeshName, const VISU::TEntity& theEntity, const string& theFieldName, int theStampsNum) throw(std::runtime_error&) = 0; - virtual const VISU::TMeshMap& GetMeshMap() throw(std::runtime_error&); - virtual const VISU::TField& GetField(const string& theMeshName, VISU::TEntity theEntity, - const string& theFieldName) - throw(std::runtime_error&); + + virtual int ToMedFile(const string& theFileName) throw(std::runtime_error&) = 0; + virtual int ToDatFile(const string& theFileName) throw(std::runtime_error&) = 0; + virtual int ToFile(const string& theFileName) throw(std::runtime_error&) = 0; + + const VISU::TMeshMap* GetMeshMap() const { return &myMeshMap;} + const VISU::TMesh* GetMesh(const string& theMeshName = "") const; + const VISU::TField* GetField(const string& theMeshName, VISU::TEntity theEntity, + const string& theFieldName) const; static string GenerateName(const VISU::TField::TTime& aTime); static string GenerateName(const string& theName, unsigned int theTimeId); }; diff --git a/src/VISU_I/VISU_Convertor_impl.cxx b/src/VISU_I/VISU_Convertor_impl.cxx index a8f0dcb1..308434d2 100644 --- a/src/VISU_I/VISU_Convertor_impl.cxx +++ b/src/VISU_I/VISU_Convertor_impl.cxx @@ -71,10 +71,15 @@ extern "C" { } } -VISU_Convertor_impl::VISU_Convertor_impl() { - myIsDone = false; +int VISU_Convertor_impl::ToFile(const string& theFileName) throw(std::runtime_error&){ + if(QFileInfo(theFileName.c_str()).extension(false) == "med") + return ToMedFile(theFileName); + else + return ToDatFile(theFileName); } +VISU_Convertor_impl::VISU_Convertor_impl() : myIsDone(false) {} + VISU_Convertor_impl::~VISU_Convertor_impl() {} VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName, @@ -82,7 +87,6 @@ VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& t const string& theFamilyName) throw (std::runtime_error&) { - if(!myIsDone) { myIsDone = true; Build();} if(MYDEBUG) MESSAGE("GetMeshOnEntity - theMeshName = '"< aRet(strCellsOut.str()); - strOut<DebugOn(); aReader->ReadFromInputStringOn(); - aRet.reset(strOut.str()); - aReader->SetInputString(aRet.get()); + aReader->SetInputString(strOut.str()); //aReader->Update(); //aReader->Print(cout); if(MYDEBUGWITHFILES){ @@ -134,7 +135,7 @@ VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& t string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",theEntity) + aFamilyName + "-Conv.vtk"; ofstream stmOut(aFileName.c_str(),ios::out); - stmOut< aRet(strCellsOut.str()); - strOut<ReadFromInputStringOn(); - aRet.reset(strOut.str()); - aReader->SetInputString(aRet.get()); + aReader->SetInputString(strOut.str()); if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk"; ofstream stmOut(aFileName.c_str(),ios::out); - stmOut< aRet(strCellsOut.str()); - strOut<ReadFromInputStringOn(); - aRet.reset(strOut.str()); - aReader->SetInputString(aRet.get()); + aReader->SetInputString(strOut.str()); if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",theEntity) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; ofstream stmOut(aFileName.c_str(),ios::out); - stmOut<second; + if(MYDEBUG) MESSAGE("GetCells - anArray.size() = "<first; - if(MYDEBUG) MESSAGE("GetCells - aVtkType = "<> There is no elements on the family !!!"); VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); - if(aSubMeshIter == aSubMesh.end()) continue; const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(MYDEBUG) MESSAGE("GetCells - aSubMeshOnCellType.size() = "< aRet(strOut.str()); - return aRet.get(); + return strOut.str(); } string VISU_Convertor_impl::GetPoints(const VISU::TMesh& theMesh) const @@ -368,8 +356,7 @@ string VISU_Convertor_impl::GetPoints(const VISU::TMesh& theMesh) const break; } strOut< aRet(strOut.str()); - return aRet.get(); + return strOut.str(); } string VISU_Convertor_impl::GetField(const VISU::TField& theField, @@ -422,6 +409,5 @@ string VISU_Convertor_impl::GetField(const VISU::TField& theField, throw std::runtime_error("GetField - There is algorithm for representation the field !!!"); } strOut< aRet(strOut.str()); - return aRet.get(); + return strOut.str(); } diff --git a/src/VISU_I/VISU_Convertor_impl.hxx b/src/VISU_I/VISU_Convertor_impl.hxx index 68b69e1b..0d8b8f16 100644 --- a/src/VISU_I/VISU_Convertor_impl.hxx +++ b/src/VISU_I/VISU_Convertor_impl.hxx @@ -21,6 +21,8 @@ extern "C"{ using namespace std; class VISU_Convertor_impl: public VISU_Convertor{ + protected: + bool myIsDone; private: string GetHead(const string& theMeshName) const throw (std::runtime_error&); string GetPoints(const VISU::TMesh& theMesh) const throw (std::runtime_error&); @@ -35,6 +37,10 @@ class VISU_Convertor_impl: public VISU_Convertor{ VISU_Convertor_impl(); virtual ~VISU_Convertor_impl(); virtual VISU_Convertor* Build() throw (std::runtime_error&) { return this;}; + virtual int ToMedFile(const string& theFileName) throw(std::runtime_error&); + virtual int ToDatFile(const string& theFileName) throw(std::runtime_error&); + virtual int ToFile(const string& theFileName) throw(std::runtime_error&); + virtual OutputType* GetMeshOnEntity(const string& theMeshName, const VISU::TEntity& theEntity, const string& theFamilyName = "") diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 46ccae6c..29eab3d0 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -18,29 +18,16 @@ static int MYDEBUG = 1; static int MYDEBUG = 0; #endif static med_err ret = 0; - -extern "C" - VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) throw(std::runtime_error&){ - return new VISU_MEDConvertor(theMedSObject); - } - +/* typedef map TVisu2MedEntity; static TVisu2MedEntity aVisu2MedEntity; -typedef map TMed2VisuEntity; -static TMed2VisuEntity aMed2VisuEntity; static int INIT = ( aVisu2MedEntity[VISU::CELL_ENTITY] = SALOME_MED::MED_CELL, aVisu2MedEntity[VISU::FACE_ENTITY] = SALOME_MED::MED_FACE, aVisu2MedEntity[VISU::EDGE_ENTITY] = SALOME_MED::MED_EDGE, aVisu2MedEntity[VISU::NODE_ENTITY] = SALOME_MED::MED_NODE, - - aMed2VisuEntity[SALOME_MED::MED_CELL] = VISU::CELL_ENTITY, - aMed2VisuEntity[SALOME_MED::MED_FACE] = VISU::FACE_ENTITY, - aMed2VisuEntity[SALOME_MED::MED_EDGE] = VISU::EDGE_ENTITY, - aMed2VisuEntity[SALOME_MED::MED_NODE] = VISU::NODE_ENTITY, - 1); - +*/ static int CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = { SALOME_MED::MED_POINT1, SALOME_MED::MED_SEG2, @@ -87,19 +74,26 @@ static int NODEGEOM[1] = { SALOME_MED::MED_POINT1, }; -void GetEntity2Geom(const VISU::TEntity& theEntity, int*& theVector, int* theEnd) - throw (std::runtime_error&) -{ +void Entity2Geom(const VISU::TEntity& theEntity, int* theVector, int* theEnd) { switch(theEntity){ case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break; case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break; case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break; case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break; - default: - throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect !!!"); } } +typedef pair TEntity2Geom; +typedef map TEntity2GeomMap; +static TEntity2GeomMap anEntity2GeomMap; +static int INIT = ( + anEntity2GeomMap[SALOME_MED::MED_CELL] = TEntity2Geom(CELLGEOM,MED_NBR_GEOMETRIE_MAILLE), + anEntity2GeomMap[SALOME_MED::MED_FACE] = TEntity2Geom(FACEGEOM,MED_NBR_GEOMETRIE_FACE), + anEntity2GeomMap[SALOME_MED::MED_EDGE] = TEntity2Geom(EDGEGEOM,MED_NBR_GEOMETRIE_ARETE), + anEntity2GeomMap[SALOME_MED::MED_NODE] = TEntity2Geom(NODEGEOM,1), + 1 +); + struct SalomeMed2vtk { SALOME_MED::medGeometryElement medType; char *medName; @@ -131,505 +125,306 @@ static SalomeMed2vtk salome_med2vtk[SALOME_MED::MED_ALL_ELEMENTS] = { }; #undef CORBAMED2VTK -int GetIdMEDType(int medType){ +int FindIdMEDType(int medType){ for(int i = 0; i < SALOME_MED::MED_ALL_ELEMENTS; i++) if(salome_med2vtk[i].medType == medType) return i; return -1; } -string GetName(SALOMEDS::SObject_ptr aSObject){ - SALOMEDS::GenericAttribute_var anAttr; - if (aSObject->FindAttribute(anAttr,"AttributeName")) { - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - CORBA::String_var aString = aName->Value(); - return aString.in(); - } - return ""; +void VISU_MedMeshConvertor::SetMedMesh(SALOME_MED::MESH_ptr theMedMesh) { + myMedMesh = SALOME_MED::MESH::_duplicate(theMedMesh); } -VISU_Convertor* VISU_MEDConvertor::Build() throw (std::runtime_error&){ - if(mySObject->_is_nil()) - throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!"); - myStudy = mySObject->GetStudy(); - CORBA::Short aTag = mySObject->Tag(); - SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather(); - SALOMEDS::SObject_var aMeshSObj; - CORBA::Boolean aBool = aMedCompSObj->FindSubObject(aTag+1,aMeshSObj); - if(!aBool) throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!"); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found."); - SALOMEDS::ChildIterator_var aMeshIterator = myStudy->NewChildIterator(aMeshSObj); - for(; aMeshIterator->More(); aMeshIterator->Next()){ - aMeshSObj = aMeshIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<<::GetName(aMeshSObj)<<"'"); - CORBA::Object_var aMedMesh = SObjectToObject(aMeshSObj); - if(CORBA::is_nil(aMedMesh)) continue; - SALOME_MED::MESH_var aMEDMesh = SALOME_MED::MESH::_narrow(aMedMesh); - if(aMEDMesh->_is_nil()) continue; - CORBA::String_var aMeshName = aMEDMesh->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myName = aMeshName.in(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<NewChildIterator(aFieldSObj); - for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){ - aFieldSObj = aFieldIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'"); - SALOMEDS::ChildIterator_var aTimeStampIterator = myStudy->NewChildIterator(aFieldSObj); - for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){ - SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'"); - CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj); - if(CORBA::is_nil(aMedField)) continue; - SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField); - if(aMEDField->_is_nil()) continue; - SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); - if(aMEDSupport->_is_nil()) continue; - SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; - SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); - if(aMEDMesh->_is_nil()) continue; - CORBA::String_var aMeshName = aMEDMesh->getName(); - CORBA::String_var aFieldName = aMEDField->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()]; - aField.myId = iField; - aField.myName = aFieldName.in(); - aField.myEntity = anEntity; - aField.myMeshName = aMeshName.in(); - aField.myNbComp = aMEDField->getNumberOfComponents(); - //int iTimeStamp = aMEDField->getOrderNumber(); - int iTimeStamp = aMEDField->getIterationNumber(); - VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp]; - aValForTime.myId = iTimeStamp; - double dt = aMEDField->getTime(); - aValForTime.myTime = VISU::TField::TTime(dt,""); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity]; - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp]; - aValForTime2.myField = aMEDField; - if(MYDEBUG) - MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<getSpaceDimension(); - int iNumElemEnd = aMedMesh->getNumberOfNodes(); +/* + if(MYDEBUG) MESSAGE("ImportPoints - beginning"); + theMesh.myDim = theMESH->getMeshDimension(); + int aNbPoints = theMESH->getNumberOfNodes(); VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; - if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<> There is no points in the mesh !!!"); - aPointsCoord.resize(theMesh.myDim*iNumElemEnd,0.0); - Engines::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); - if(!isPointsLoaded){ - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++) - aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim]; - if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; - aConnForCellType.resize(iNumElemEnd); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem); - } - if(isFamilyPresent){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); - VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName]; - SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily; - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; - SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); - Engines::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); - int iNumElemEndTmp = iNumElemEnd; - iNumElemEnd = aCellNumForType->length(); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { - int tmp = aCellNumForType[iNumElem]-1; - if(0 > tmp || tmp >= iNumElemEndTmp) { - static QString aString; - aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp); - throw std::runtime_error(aString.latin1()); - } - aSubMeshOnCellType.insert(tmp); - } - } + aPointsCoord.resize(theMesh.myDim*aNbPoints,0.0); + Engines::double_array_var coord = theMESH->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); + for (int i = 0 ; i < aNbPoints; i++) + for(int j = 0, ij = theMesh.myDim*i; j < theMesh.myDim; j++) + aPointsCoord[ij+j] = coord[ij+j]; + if(MYDEBUG) + MESSAGE("ImportPoints - End : theDim = "<> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]); - throw std::runtime_error(aString.latin1()); - } - aConnForCellType.push_back(anArray); + anArray[k] = aConnect[k]; } - //Workaround for MED Component data structure - int aSize = aConnForCellType.size(); - aMeshOnEntity2.myCellsFirstIndex[aMedType] = VISUMED::TMeshOnEntity::TIndexAndSize(aCounter,aSize); - aCounter += aSize; + for (int k = 0; k < nbVtkNodes; k++) + if(anArray[k] < 0 || aNbPoints <= anArray[k]) + throw std::runtime_error("ImportCells >> anArray[k] < 0 || aNbPoints <= anArray[k]"); } + if(MYDEBUG) + MESSAGE("ImportCells - aMeshOnEntity.myCellsConn.size() = "<getTypes(); - iGeomElemEnd = aGeom->length(); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomElemEnd = "<getNumber(aGeomType); - int medId = GetIdMEDType(aGeomType); - int aVtkType = salome_med2vtk[medId].vtkType; - SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType; - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; - med_int iNumElemEndTmp = theMeshOnEntity.myCellsConn[aVtkType].size(); - med_int iNumElemEnd = aCellNumForType->length(); - int aCounter = aMeshOnEntity2.myCellsFirstIndex[aMedType].first; - if(MYDEBUG) - MESSAGE("LoadCellsOnEntity - medName = "<> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp); - throw std::runtime_error(aString.latin1()); - } - aSubMeshOnCellType.insert(tmp); - } - } - } - return 1; +*/ +} + +VISU_Convertor* VISU_MedMeshConvertor::Build() throw (std::runtime_error&) { +/* + if(myMedMesh->_is_nil()) + throw std::runtime_error("VISU_MedMeshConvertor::Build >> myMesh->_is_nil()"); + CORBA::String_var aName = myMedMesh->getName(); + myName = aName; + TMesh& aMesh = myMeshMap[myName]; + if(MYDEBUG) MESSAGE("MedInfo - aMeshName = "<first); + ::ImportPoints(aMesh,myMedMesh); + TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin(); + for(; aVisu2MedEntityIter != aVisu2MedEntity.end(); aVisu2MedEntityIter++) + ::ImportCells(aMesh,myMedMesh,aVisu2MedEntityIter->second); + myIsDone = true; + return this; +*/ } template int ImportField(TArray& theArray, - const VISU::TMesh& theMesh, - const VISU::TField& theField, - VISU::TField::TValForTime& theValForTime, const VISU::TMeshOnEntity& theMeshOnEntity, - const VISUMED::TMeshOnEntity& theMeshOnEntity2) + VISU::TField& theField, + const SALOME_MED::medEntityMesh& theEntity, + const VISU::TField::TTime& theTime) { - if(theField.myEntity == VISU::NODE_ENTITY){ - VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[VTK_VERTEX]; - int iNumElemEnd = theMesh.myPointsCoord.size()/theMesh.myDim*theField.myNbComp; - if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<second; + int jEnd = aConnForCellType.size(); + if(MYDEBUG) MESSAGE("ImportField - medName = "<> myField->_is_nil()"); + if(VISU_MedMeshConvertor::Build() == NULL) return NULL; + CORBA::String_var aName = myMedField->getName(); + myName = aName; + TMeshMap::const_iterator aMeshIter = myMeshMap.begin(); + const TMesh& aMesh = aMeshIter->second; + int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim; + int aNbCells = aMesh.GetCellsDims().first; + aName = myMedField->getName(); + aMeshOnEntity.myEntity = theEntity; + aMeshOnEntity.myMeshName = theMesh.myName; + TField& aField = myFieldMap[aName.in()]; + aField.myMeshName = aMeshIter->first; + SALOME_MED::SUPPORT_var aSupport = myMedField->getSupport(); + SALOME_MED::medEntityMesh anEntity = aSupport->getEntity(); + int aSize; + if(anEntity == SALOME_MED::MED_NODE){ + aSize = aNbPoints; + aField.myTypeConn = POINT_DATA; + if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - POINT_DATA = "<_is_nil()){ + if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - There is FIELDDOUBLE"); Engines::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<length()); - ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2); + ::ImportField(anArray,aMesh,aField,anEntity,aTime); } - SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField); + SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(myMedField); if(!aFieldInt->_is_nil()){ + if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - There is FIELDINT"); Engines::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<length()); - ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2); + ::ImportField(anArray,aMesh,aField,anEntity,aTime); + } + myIsDone = true; + return this; +*/ +} + +int ImportCellsOfSupport(VISU::TMesh& theMesh, SALOME_MED::SUPPORT_ptr theSUPPORT) + throw (std::runtime_error&) +{ +/* + if(MYDEBUG) MESSAGE("ImportCellsOfSupport - beginning"); + SALOME_MED::medEntityMesh anEntity = theSUPPORT->getEntity(); + med_int nmailles[SALOME_MED::MED_ALL_ELEMENTS]; + if(MYDEBUG) MESSAGE("ImportCellsOfSupport - anEntity = "<isOnAllElements()){ + int jEnd = theMesh.myPointsCoord.size()/theMesh.myDim; + if(MYDEBUG) MESSAGE("ImportCellsOfSupport - isOnAllElements - "<(1,j); + }else{ + SALOME_MED::medGeometryElement_array_var aGeom = theSUPPORT->getTypes(); + Engines::long_array_var aCellNumForType = theSUPPORT->getNumber(aGeom[0]); + int jEnd = aCellNumForType->length(); + aConnForCellType.resize(jEnd); + for (int j = 0; j < jEnd; j++) + aConnForCellType[j] = vector(1,aCellNumForType[j]-1); + } + }else{ + VISU::TMesh aBaseMesh; + SALOME_MED::MESH_var aMedMesh = theSUPPORT->getMesh(); + ::ImportPoints(aBaseMesh,aMedMesh); + ::ImportCells(aBaseMesh,aMedMesh,anEntity); + if(theSUPPORT->isOnAllElements()){ + if(MYDEBUG) MESSAGE("ImportCellsOfSupport - isOnAllElements"); + }else{ + SALOME_MED::medGeometryElement_array_var aGeom = theSUPPORT->getTypes(); + int iEnd = aGeom->length(); + if(MYDEBUG) MESSAGE("ImportCellsOfSupport - aGeom->length() = "<getNumber(aGeom[i]); + int medId = FindIdMEDType(aGeom[i]); + int aVtkType = salome_med2vtk[medId].vtkType; + med_int jEnd = aCellNumForType->length(); + if(MYDEBUG) MESSAGE("ImportCellsOfSupport - medName = "<getMesh()"); + if(mySupport->_is_nil()) + throw std::runtime_error("VISU_CorbaMedConvertor::Build >> mySupport->_is_nil()"); + SALOME_MED::GROUP_var aGroup = SALOME_MED::GROUP::_narrow(mySupport); + int aNbCells = 0; + if(!aGroup->_is_nil()){ + CORBA::String_var aName = aGroup->getName(); + myName = aName; + if(MYDEBUG) MESSAGE("BuildSupport aGroup->getName() = "<getFamilies(); + med_int iEnd = anArray->length(); + TMesh& aMesh = myMeshMap[myName]; + if(MYDEBUG) MESSAGE("BuildSupport - aGroup->getFamilies()->length() = "<> aNbCells == 0"); + if(MYDEBUG) MESSAGE("BuildSupport - aNbCells = "< } -namespace VISUMED{ + +class VISU_MEDConvertor: public VISU_Convertor_impl{ + protected: + /* struct TFamily{ SALOME_MED::FAMILY_var myFamily; + int myId; + string myName; + VISU::TEntity myEntity; + TBindGroups myGroups; + TSubMesh mySubMesh; }; typedef std::map TFamilyMap; - + struct TField{ + SALOME_MED::FIELD_var myField; + int myId; + string myName; + VISU::TEntity myEntity; + string myMeshName; + int myNbComp; + typedef std::pair TTime; struct TValForTime{ - SALOME_MED::FIELD_var myField; + int myId; + TTime myTime; }; typedef std::map TValField; TValField myValField; + void ShallowCopy(const TField& aField); }; typedef map TFieldMap; struct TMeshOnEntity{ SALOME_MED::SUPPORT_var mySupport; - typedef pair TIndexAndSize; - typedef map TCellsFirstIndex; - TCellsFirstIndex myCellsFirstIndex; + string myMeshName; + VISU::TEntity myEntity; TFamilyMap myFamilyMap; TFieldMap myFieldMap; }; - typedef std::map TMeshOnEntityMap; - + typedef std::map TMeshOnEntityMap; + const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, + const string& theFamilyName) + throw(std::runtime_error&); + TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, + const string& theFamilyName) + throw(std::runtime_error&); + + typedef std::pair TFamilyAndEntity; + typedef std::set TFamilyAndEntitySet; struct TGroup{ - SALOME_MED::GROUP_var myGroup; + TVTKReader myStorage; + string myName; + string myMeshName; + TFamilyAndEntitySet myFamilyAndEntitySet; }; typedef std::map TGroupMap; struct TMesh{ - SALOME_MED::MESH_var myMesh; + int myDim; + string myName; + typedef vector TPointsCoord; + TPointsCoord myPointsCoord; TMeshOnEntityMap myMeshOnEntityMap; TGroupMap myGroupMap; + void CreateMeshOnNodes(); + const TField* GetField(const string& theFieldName) const; }; typedef std::map TMeshMap; -} - - -class VISU_MEDConvertor: public VISU_Convertor_impl{ - protected: - VISUMED::TMeshMap myMeshMap2; + */ SALOMEDS::SObject_var mySObject; - SALOMEDS::Study_var myStudy; public: - VISU_MEDConvertor(SALOMEDS::SObject_ptr theMedSObject) : mySObject(SALOMEDS::SObject::_duplicate(theMedSObject)) {} + void SetMedField(SALOME_MED::FIELD_ptr theMedField); virtual VISU_Convertor* Build() throw (std::runtime_error&); protected: virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName = "") - throw (std::runtime_error&); + throw (std::runtime_error&) {return 1;} virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) - throw (std::runtime_error&); + throw (std::runtime_error&) {return 1;} virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, VISU::TMeshOnEntity& theMeshOnEntity, VISU::TField& theField, VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&); - int LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName = "") - throw (std::runtime_error&); - int LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName = "") - throw (std::runtime_error&); - int LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&); + throw (std::runtime_error&) {return 1;} }; -extern "C" - VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) throw(std::runtime_error&); -#endif +class VISU_MedMeshConvertor: public VISU_Convertor_impl{ +protected: + SALOME_MED::MESH_var myMedMesh; +public: + void SetMedMesh(SALOME_MED::MESH_ptr theMedMesh); + virtual VISU_Convertor* Build() throw (std::runtime_error&); + protected: + virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + const string& theFamilyName = "") + throw (std::runtime_error&) {return 1;} + virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) + throw (std::runtime_error&) {return 1;} + virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, + VISU::TMeshOnEntity& theMeshOnEntity, + VISU::TField& theField, + VISU::TField::TValForTime& theValForTime) + throw (std::runtime_error&) {return 1;} +}; + +class VISU_CorbaMedConvertor: public VISU_MedMeshConvertor{ +protected: + SALOME_MED::FIELD_var myMedField; +public: + void SetMedField(SALOME_MED::FIELD_ptr theMedField); + virtual VISU_Convertor* Build() throw (std::runtime_error&); +}; + +class VISU_CorbaMedSupportConvertor: public VISU_Convertor_impl{ +protected: + SALOME_MED::SUPPORT_var mySupport; + SALOME_MED::MESH_var myMedMesh; +public: + void SetSupport(SALOME_MED::SUPPORT_ptr theSupport); + virtual VISU_Convertor* Build() throw (std::runtime_error&); + protected: + virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + const string& theFamilyName = "") + throw (std::runtime_error&) {return 1;} + virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) + throw (std::runtime_error&) {return 1;} + virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, + VISU::TMeshOnEntity& theMeshOnEntity, + VISU::TField& theField, + VISU::TField::TValForTime& theValForTime) + throw (std::runtime_error&) {return 1;} +}; +#endif diff --git a/src/VISU_I/VISU_DatConvertor.cxx b/src/VISU_I/VISU_DatConvertor.cxx index 2fb3b149..8b424270 100644 --- a/src/VISU_I/VISU_DatConvertor.cxx +++ b/src/VISU_I/VISU_DatConvertor.cxx @@ -152,8 +152,8 @@ int VISU_DatConvertor::ImportCells(ifstream* pStmIn, vector* pCellsType) return 0; } -/* int VISU_Convertor_impl::ToDatFile(const string& theFileName) throw(std::runtime_error&){ + /* if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - "< TVisu2MedEntity; static TVisu2MedEntity aVisu2MedEntity; static int INIT = ( @@ -41,22 +44,20 @@ static med_geometrie_element CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = { MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10, MED_PYRA13, MED_PENTA15, MED_HEXA20 }; -void GetEntity2Geom(const VISU::TEntity& theEntity, med_geometrie_element*& theVector, int* theEnd) - throw (std::runtime_error&) -{ +void GetEntity2Geom(const VISU::TEntity& theEntity, med_geometrie_element*& theVector, int* theEnd) { switch(theEntity){ case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break; case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break; case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break; case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break; - default: - throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect"); } } extern "C" VISU_Convertor* CreateMedConvertor(const string& theFileName) throw(std::runtime_error&){ - return new VISU_MedConvertor(theFileName); + VISU_MedConvertor* aConvertor = new VISU_MedConvertor(theFileName); + aConvertor->Build(); + return aConvertor; } int med2vtkCellType(int medType){ @@ -103,7 +104,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { MedFile aMedFile(myFileInfo.absFilePath()); med_idt fid = aMedFile.GetFid(); med_int iMeshEnd = MEDnMaa(fid); //Get number of meshes - if(MYDEBUG) MESSAGE("ImportInfo - MEDnMaa = "< TFamily2EntityMap; TFamily2EntityMap aFamily2EntityMap; TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin(); @@ -125,51 +130,35 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { int medId = getIdMedType(aGeomElemVector[iGeomElem]); int aVtkType = med2vtk[medId].vtkType; med_geometrie_element aMedType = med2vtk[medId].medType; - if(aMedEntity == MED_NOEUD){ - med_geometrie_element typgeo = (med_geometrie_element)0; - med_connectivite typco = (med_connectivite)0; - med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,typgeo,typco); - if(iNumElemEnd > 0){ - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - aMeshOnEntity.myEntity = anEntity; - aMeshOnEntity.myMeshName = aMeshName; - if(MYDEBUG) - MESSAGE("ImportInfo -\t anEntity = "<> MEDnoeudsLire(...)"); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] != 0) - aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity; - } - } //Get number of connectivities med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aMedType,MED_NOD); if (iNumElemEnd > 0) { VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; aMeshOnEntity.myEntity = anEntity; aMeshOnEntity.myMeshName = aMeshName; + if(MYDEBUG) + MESSAGE("ImportInfo -\t anEntity = "<> MEDelementsLire(...)"); + if(aMedEntity == MED_NOEUD){ + med_repere rep; + valarray name_coord('\0',aMesh.myDim*MED_TAILLE_PNOM+1); + valarray unit_coord('\0',aMesh.myDim*MED_TAILLE_PNOM+1); + valarray coord(aMesh.myDim*iNumElemEnd); + ret = MEDnoeudsLire(fid,aMeshName,aMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep, + &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem, + &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd); + if(ret < 0) throw std::runtime_error("ImportInfo >> MEDnoeudsLire(...)"); + }else{ + med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim); + valarray conn(aNbConnForElem*iNumElemEnd); + ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE, + &name_elem[0],&iname_elem,&num_elem[0],&inum_elem, + &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD); + if (ret < 0) throw std::runtime_error("ImportInfo >> MEDelementsLire(...)"); + } for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) if(num_fam_elem[iNumElem] != 0) aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity; @@ -192,9 +181,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { &anAttId[0],&anAttVal[0],&anAttDesc[0],&aNbAttrib, &aGroupNames[0],&aNbGroup); if(ret < 0) throw std::runtime_error("ImportInfo >> MEDfamInfo"); - if(0 && MYDEBUG) - MESSAGE("ImportInfo - aFamilyNum = "<> MEDnEntMaa(...)"); if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "< 0){ + if(isFamilyPresent){ if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) @@ -452,6 +435,7 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity const string& theFamilyName) throw (std::runtime_error&) { + if(MYDEBUG) MESSAGE("LoadCellsOnEntity - beginning"); //Check on existing family VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); bool isFamilyPresent = (pFamily != NULL); @@ -470,7 +454,7 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity med_geometrie_element* aGeomElemVector; const VISU::TEntity& anEntity = theMeshOnEntity.myEntity; GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd); - const med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; + med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; char aMeshName[MED_TAILLE_NOM+1] = ""; strcpy(aMeshName,theMeshOnEntity.myMeshName.c_str()); if(MYDEBUG) @@ -623,3 +607,5 @@ int VISU_MedConvertor::LoadField(const med_idt& fid, const VISU::TMeshOnEntity& } return 1; } + +int VISU_Convertor_impl::ToMedFile(const string& theFileName) throw(std::runtime_error&){} diff --git a/src/VISU_I/VISU_PrsObject_i.cc b/src/VISU_I/VISU_PrsObject_i.cc index 5faaa071..8803a71c 100644 --- a/src/VISU_I/VISU_PrsObject_i.cc +++ b/src/VISU_I/VISU_PrsObject_i.cc @@ -43,7 +43,7 @@ using namespace VISU; #include -//#define CHECKTIME +#define CHECKTIME #ifdef CHECKTIME #include #endif @@ -132,11 +132,11 @@ VISU_Actor* VISU::Prs3d_i::CreateActor(const Handle(SALOME_InteractiveObject)& t float bounds[6]; static float eps = VTK_LARGE_FLOAT * 0.1 ; myMapper->GetBounds(bounds); - for (int i = 0; i < 6; ++i) { + for (int i =0; i <6; ++i) { if (fabs (bounds[i] - myBounds[i]) > eps ) { - MESSAGE("Prs3d_i::CreateActor >> Boundaries of actor do not coincide with boundaries of initial shape !!!"); - return NULL; - } + MESSAGE(" Boundaries of actor do not coincide with boundaries of initial shape : \ + error finish of VISU::Prs3d_i::CreateActor"); + return NULL;} } VISU_Actor* aActor = VISU_Actor::New(); if(myMapper->GetInput()->GetNumberOfCells() < 10) @@ -170,7 +170,7 @@ VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap, in myColorRGB[0] = myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); myColorRGB[1] = myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); myColorRGB[2] = myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); - return this; + return NULL; } void VISU::Prs3d_i::ToStream(ostrstream& theStr){ @@ -312,8 +312,6 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ OSD_Timer timer; timer.Start(); #endif - if(myResult->GetInput() == NULL) - throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); if(!theRestoring) myName = GenerateName(); if(myEntity >= 0) if(mySubMeshName == "") @@ -328,18 +326,18 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ switch(myType){ case VISU::TENTITY : myInput = myResult->GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity); - aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY,myMeshName.c_str(),myEntity); + aComment.sprintf("myComment=ENTITY;myType=%d;myResultName=%s;myMeshName=%s;myId=%d", + VISU::TENTITY,myResult->GetName(),myMeshName.c_str(),myEntity); break; case VISU::TFAMILY : myInput = myResult->GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity,mySubMeshName); - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,myMeshName.c_str(),myEntity,mySubMeshName.c_str()); + aComment.sprintf("myComment=FAMILY;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s", + VISU::TFAMILY,myResult->GetName(),myMeshName.c_str(),myEntity,mySubMeshName.c_str()); break; case VISU::TGROUP : myInput = myResult->GetInput()->GetMeshOnGroup(myMeshName,mySubMeshName); - aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", - VISU::TGROUP,myMeshName.c_str(),mySubMeshName.c_str()); + aComment.sprintf("myComment=GROUP;myType=%d;myResultName=%s;myMeshName=%s;myName=%s", + VISU::TGROUP,myResult->GetName(),myMeshName.c_str(),mySubMeshName.c_str()); break; } if(myInput == NULL) throw std::runtime_error("Mesh_i::Build - myInput == NULL !!!"); @@ -404,9 +402,6 @@ VISU_Actor* VISU::Mesh_i::CreateActor(const Handle(SALOME_InteractiveObject)& th aActor->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer(); aActor->GetMapper()->SetResolveCoincidentTopologyZShift(0.02); - aActor->EdgeDevice = VISU_Actor::New(); - aActor->EdgeDevice->PickableOff(); - aActor->EdgeDevice->SetMapper(edgeMapper); edgeMapper->Update(); @@ -422,16 +417,11 @@ VISU_Actor* VISU::Mesh_i::CreateActor(const Handle(SALOME_InteractiveObject)& th //============================================================================== int VISU::ScalarMap_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, double theIteration){ - try{ - const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - const VISU::TField::TValField& aValField = aField.myValField; - return aValField.find((int)theIteration) != aValField.end(); - }catch(std::runtime_error& exc){ - MESSAGE("Follow exception was accured :\n"<GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); + if(aField == NULL) return 0; + const VISU::TField::TValField& aValField = aField->myValField; + if(aValField.find((int)theIteration) == aValField.end()) return 0; + return 1; } int VISU::ScalarMap_i::myNbPresent = 0; @@ -653,7 +643,7 @@ void VISU::ScalarMap_i::SetRange(CORBA::Double theMin, CORBA::Double theMax) { void VISU::ScalarMap_i::CalculateRange() { - //myIsFixedRange = false; + myIsFixedRange = false; myInput->GetUnstructuredGridOutput()->GetScalarRange(myScalarRange); if(MYDEBUG) MESSAGE("ScalarMap_i::CalculateRange - myScalarRange[0] = "<GetInput() == NULL !!!"); - myField = &(myResult->GetInput()->GetField(myMeshName,(VISU::TEntity)myEntity,myFieldName)); + myField = myResult->GetInput()->GetField(myMeshName,(VISU::TEntity)myEntity,myFieldName); if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!"); SetScalarMode(myScalarMode); if(myInput->GetInput() == NULL) throw std::runtime_error("Can't build build vtk representation !!!"); @@ -726,14 +708,14 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ myTitle = aComment.simplifyWhiteSpace(); if (myAddToStudy) { myName = GenerateName(); - aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp); + aComment.sprintf("myComment=TIMESTAMP;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + VISU::TTIMESTAMP,myResult->GetName(),myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp); string aResultEntry = myResult->GetEntry(); string aRefFatherEntry = myResult->GetRefFatherEntry(); string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!"); - aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d;myComponentId=%d", - GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp,myScalarMode); + aComment.sprintf("myComment=%s;myResultName=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d;myComponentId=%d", + GetComment(),myResult->GetName(),myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp,myScalarMode); CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(), anIOR,myName.c_str(),"",aComment.latin1(),true); } @@ -767,10 +749,7 @@ VISU::ScalarMap_i::DataType* VISU::ScalarMap_i::DoHook(int theRestoring){ VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { - //Update(); - VISU_Actor* aActor = VISU::Prs3d_i::CreateActor(theIO); - if ( !aActor ) return NULL; - + Update(); VISU_LookupTable* aActorLookupTbl = VISU_LookupTable::New(); if(GetScaling() == VISU::LOGARITHMIC) aActorLookupTbl->SetLog(true); @@ -787,6 +766,8 @@ VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject myMapper->SetScalarRange(myScalarRange); aActorLookupTbl->Delete(); + VISU_Actor* aActor = VISU::Prs3d_i::CreateActor(theIO); + if ( !aActor ) return NULL; VISU_ScalarBarActor* aBar = VISU_ScalarBarActor::New(); VISU_LookupTable* aBarLookupTbl = VISU_LookupTable::New(); @@ -823,19 +804,13 @@ VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject return aActor; } + //============================================================================== int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, double theIteration){ - try{ - if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration)) return 0; - const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - return aField.myNbComp > 1; - }catch(std::runtime_error& exc){ - MESSAGE("Follow exception was accured :\n"<GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); + return aField->myNbComp > 1; } int VISU::DeformedShape_i::myNbPresent = 0; @@ -1185,7 +1160,7 @@ void VISU::CutPlanes_i::SetPlane(int theId){ vtkPlane *aPlane = vtkPlane::New(); float aOrig[3]; Mul(aOrig,myDir,myBoundPrj[0] + theId*myDBPrj); - if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); if(theId == 0) aPlane->SetNormal(myInvDir); else aPlane->SetNormal(myDir); diff --git a/src/VISU_I/VISU_PrsObject_i.hh b/src/VISU_I/VISU_PrsObject_i.hh index 842ec89e..189ec3ab 100644 --- a/src/VISU_I/VISU_PrsObject_i.hh +++ b/src/VISU_I/VISU_PrsObject_i.hh @@ -246,7 +246,6 @@ namespace VISU{ const char* theFieldName, double theIteration); InputType* GetInput() { return myInput;} - virtual void Update(); const VISU::TField* GetField() const { return myField;} const string& GetFieldName() const { return myFieldName;} int GetScalarMode() const { return myScalarMode;} diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index dc9f2505..b5f2d3b8 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -89,12 +89,6 @@ void CreateReference(SALOMEDS::Study_ptr theStudyDocument, aStudyBuilder->Addreference(newObj,aRefSObj); } -string GetComponentDataType(SALOMEDS::SObject_ptr theSObject){ - SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent(); - CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); - return aDataType.in(); -} - //============================================================================== const string VISU::Result_i::myComment = "RESULT"; @@ -102,149 +96,133 @@ const char* VISU::Result_i::GetComment() const { return myComment.c_str();} VISU::Result_i::Result_i(SALOMEDS::Study_ptr theStudy) { myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); - myInput = NULL; } -VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) - throw (std::runtime_error&) -{ +VISU::Storable* VISU::Result_i::Build() { if(MYDEBUG) MESSAGE("Result_i::Build"); - mySComponent = FindOrCreateVisuComponent(myStudyDocument); - CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID()); - string aRefFatherEntry = GetRefFatherEntry(); - QString aComment; - aComment.sprintf("myComment=%s;myType=%d;myFileName=%s", - GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1()); - string aResultEntry = CreateAttributes(myStudyDocument,aSComponentEntry,aRefFatherEntry.c_str(), - anIOR,myName.c_str(),"",aComment.latin1(),true); - mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); - if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!"); - if(theSObject != NULL){ - CORBA::String_var aString = theSObject->GetID(); - CreateReference(myStudyDocument,aResultEntry,aString.in()); - } - const TMeshMap& aMeshMap = myInput->GetMeshMap(); - if(!aMeshMap.empty()) {//apo - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(),aMesh.myDim); - string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), - "",aMeshName.c_str(),"",aComment.latin1(),true); - if(aMeshOnEntityMap.empty()) continue; - aComment.sprintf("myComment=FAMILIES;myMeshName=%s",aMeshName.c_str()); - string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Families","",aComment.latin1(),true); - //Import entities and according families - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - typedef map TEntity2Entry; - TEntity2Entry aEntity2Entry; - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY,aMeshName.c_str(),anEntity); - string anEntityName; - switch(anEntity){ - case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; - case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break; - case VISU::FACE_ENTITY : anEntityName = "onFaces"; break; - case VISU::CELL_ENTITY : anEntityName = "onCells"; break; - default: - throw std::runtime_error("Build >> Value of entity is incorrect!"); - } - aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), - "",anEntityName.c_str(),"",aComment.latin1(),true); - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); - CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), - "",aFamilyName.c_str(),"",aComment.latin1(),true); - } - } - //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; - if(aGroupMap.size() > 0){ - aComment.sprintf("myComment=GROUPS;myMeshName=%s",aMeshName.c_str()); - string aGroupsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Groups","",aComment.latin1(),true); - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", - VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str()); - string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), - "",aGroupName.c_str(),"",aComment.latin1(),true); - const VISU::TGroup& aGroup = aGroupMapIter->second; - const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; - VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); - for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ - const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; - const string& aFamilyName = aFamilyAndEntity.first; - const VISU::TEntity& anEntity = aFamilyAndEntity.second; - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); - string anEntry = FindEntryWithComment(myStudyDocument,aEntity2Entry[anEntity].c_str(),aComment); - CreateReference(myStudyDocument,aGroupEntry,anEntry); + try{ + mySComponent = FindOrCreateVisuComponent(myStudyDocument); + CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID()); + string aRefFatherEntry = GetRefFatherEntry(); + QString aComment; + aComment.sprintf("myComment=%s;myType=%d;myName=%s;myFileName=%s", + GetComment(),VISU::TRESULT,myName.c_str(),myFileInfo.filePath().latin1()); + string aResultEntry = CreateAttributes(myStudyDocument,aSComponentEntry,aRefFatherEntry.c_str(), + anIOR,myName.c_str(),"",aComment.latin1(),true); + mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); + if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for hte Result !!!"); + const TMeshMap& aMeshMap = *(myInput->GetMeshMap()); + if( &aMeshMap != NULL) {//apo + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const VISU::TMesh& aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; + aComment.sprintf("myComment=MESH;myResultName=%s;myName=%s;myDim=%d", + myName.c_str(),aMeshName.c_str(),aMesh.myDim); + string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), + "",aMeshName.c_str(),"",aComment.latin1(),true); + if(aMeshOnEntityMap.empty()) continue; + aComment.sprintf("myComment=FAMILIES;myResultName=%s;myMeshName=%s",myName.c_str(),aMeshName.c_str()); + string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), + "","Families","",aComment.latin1(),true); + //Import entities and according families + aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + typedef map TEntity2Entry; + TEntity2Entry aEntity2Entry; + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; + aComment.sprintf("myComment=ENTITY;myType=%d;myResultName=%s;myMeshName=%s;myId=%d", + VISU::TENTITY,myName.c_str(),aMeshName.c_str(),anEntity); + string anEntityName; + switch(anEntity){ + case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; + case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break; + case VISU::FACE_ENTITY : anEntityName = "onFaces"; break; + case VISU::CELL_ENTITY : anEntityName = "onCells"; break; + default: + throw std::runtime_error("Build >> Value of entity is incorrect!"); + } + aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), + "",anEntityName.c_str(),"",aComment.latin1(),true); + const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + aComment.sprintf("myComment=FAMILY;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s", + VISU::TFAMILY,myName.c_str(),aMeshName.c_str(),anEntity,aFamilyName.c_str()); + CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), + "",aFamilyName.c_str(),"",aComment.latin1(),true); } } - } - //Import fields - string aFieldsEntry; - bool isFieldEntryCreated = 0; - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; - VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - if(!isFieldEntryCreated){ - aComment.sprintf("myComment=FIELDS;myMeshName=%s",aMeshName.c_str()); - aFieldsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Fields","",aComment.latin1(),true); - isFieldEntryCreated = true; + //Importing groups + const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + if(aGroupMap.size() > 0){ + aComment.sprintf("myComment=GROUPS;myResultName=%s;myMeshName=%s",myName.c_str(),aMeshName.c_str()); + string aGroupsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), + "","Groups","",aComment.latin1(),true); + VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); + for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ + const string& aGroupName = aGroupMapIter->first; + aComment.sprintf("myComment=GROUP;myType=%d;myResultName=%s;myMeshName=%s;myName=%s", + VISU::TGROUP,myName.c_str(),aMeshName.c_str(),aGroupName.c_str()); + string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), + "",aGroupName.c_str(),"",aComment.latin1(),true); + const VISU::TGroup& aGroup = aGroupMapIter->second; + const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; + VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); + for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ + const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; + const string& aFamilyName = aFamilyAndEntity.first; + const VISU::TEntity& anEntity = aFamilyAndEntity.second; + aComment.sprintf("myComment=FAMILY;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s", + VISU::TFAMILY,myName.c_str(),aMeshName.c_str(),anEntity,aFamilyName.c_str()); + string anEntry = FindEntryWithComment(myStudyDocument,aEntity2Entry[anEntity].c_str(),aComment); + CreateReference(myStudyDocument,aGroupEntry,anEntry); + } } - const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField.myNbComp); - string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), - "",aFieldName.c_str(),"",aComment.latin1(),true); - CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); - for(; aValFieldIter != aValField.end(); aValFieldIter++){ - int aTimeStamp = aValFieldIter->first; - const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; - aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); - string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); - CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), - "",aTimeStampId.c_str(),"",aComment.latin1(),true); + } + //Import fields + string aFieldsEntry; + bool isFieldEntryCreated = 0; + aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; + const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ + if(!isFieldEntryCreated){ + aComment.sprintf("myComment=FIELDS;myResultName=%s;myMeshName=%s",myName.c_str(),aMeshName.c_str()); + aFieldsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), + "","Fields","",aComment.latin1(),true); + isFieldEntryCreated = true; + } + const string& aFieldName = aFieldMapIter->first; + const VISU::TField& aField = aFieldMapIter->second; + const VISU::TField::TValField& aValField = aField.myValField; + aComment.sprintf("myComment=FIELD;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", + VISU::TFIELD,myName.c_str(),aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField.myNbComp); + string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), + "",aFieldName.c_str(),"",aComment.latin1(),true); + CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); + VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + for(; aValFieldIter != aValField.end(); aValFieldIter++){ + int aTimeStamp = aValFieldIter->first; + const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; + aComment.sprintf("myComment=TIMESTAMP;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + VISU::TTIMESTAMP,myName.c_str(),aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); + CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), + "",aTimeStampId.c_str(),"",aComment.latin1(),true); + } } } } } - } - return this; -} - -VISU::Storable* VISU::Result_i::Create(const char* theFileName){ - try{ - mySourceId = eFile; - myInput = CreateConvertor(theFileName); - if(myInput == NULL) return NULL; - myFileInfo.setFile(theFileName); - myName = ::GenerateName(myFileInfo.fileName().latin1()); - return Build(); + return this; }catch(std::runtime_error& exc){ MESSAGE("Follow exception was accured :\n"<SetMedMesh(theMesh); + myInput = aInput; + //if(myInput->GetOutput() == NULL) return NULL; + TMeshMap::const_iterator aMeshMapIter = myInput->GetMeshMap()->begin(); + myName = ::GenerateName((aMeshMapIter->first).c_str()); + return Build(); +} + +VISU::Storable* VISU::Result_i::Create(SALOME_MED::SUPPORT_ptr theSupport){ + if(MYDEBUG) MESSAGE("Result_i::Create Mesh from MED::SUPPORT"); + VISU_CorbaMedSupportConvertor* aInput = new VISU_CorbaMedSupportConvertor(); + aInput->SetSupport(theSupport); + myInput = aInput; + //if(myInput->GetOutput() == NULL) return NULL; + TMeshMap::const_iterator aMeshMapIter = myInput->GetMeshMap()->begin(); + myName = ::GenerateName((aMeshMapIter->first).c_str()); + return Build(); +} + +VISU::Storable* VISU::Result_i::Create(SALOME_MED::FIELD_ptr theField){ + if(MYDEBUG) MESSAGE("Result_i::Create MedObject from Field"); + VISU_CorbaMedConvertor* aInput = new VISU_CorbaMedConvertor(); + aInput->SetMedField(theField); + myInput = aInput; + //if(myInput->GetOutput() == NULL) return NULL; + TMeshMap::const_iterator aMeshMapIter = myInput->GetMeshMap()->begin(); + myName = ::GenerateName((aMeshMapIter->first).c_str()); + return Build(); } VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, @@ -277,55 +279,31 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, { if(MYDEBUG) MESSAGE("Result_i::Restore - "<GetStudy(); mySComponent = mySObject->GetFatherComponent(); myName = VISU::Storable::FindValue(theMap,"myName"); - SALOMEDS::SObject_var aRefSObj, aTargetRefSObj; - if(mySObject->FindSubObject(1,aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)){ - mySourceId = eRestoredComponent; - if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference."); - SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent(); - CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); - myFileInfo.setFile(aDataType.in()); - if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = "<FindOrLoad_Component("FactoryServer", aDataType.in()); - if (CORBA::is_nil(aEngComp)) - throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!"); - SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); - SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp); - aStudyBuilder->LoadWith(aCompRefSObj,aDriver); - if(strcmp(aDataType,"Med") == 0){ - myInput = CreateMEDConvertor(aTargetRefSObj); - }else - throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!"); - }else{ - mySourceId = eRestoredFile; - myFileInfo.setFile(thePrefix.c_str()); - string aStudyPrefix(SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL())); - string aTmpDir(SALOMEDS_Tool::GetDirFromPath(myStudyDocument->URL())); - if(!myFileInfo.isFile()){ - string aFileName = thePrefix + aStudyPrefix + "_" + myName; - myFileInfo.setFile(aFileName.c_str()); - } - if(MYDEBUG) - MESSAGE("Result_i::Restore - aFileName = "<FindAttribute(anAttr, "AttributeComment")) - throw std::runtime_error("Build - There is no AttributeComment for the SObject !!!"); - SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); - aCmnt->SetValue(aComment.latin1()); - // remove temporary file, if it's not multifile mode - if (false || !IsMultifile()) { - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(1); - aSeq[0]=(aStudyPrefix + myName).c_str(); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); - } + string aFileName(thePrefix); + string aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL()); + aFileName += aStudyPrefix + "_" + myName; + if(MYDEBUG) MESSAGE("Result_i::Restore - aFileName = "<FindAttribute(anAttr, "AttributeComment")) + throw std::runtime_error("Build - There is no AttributeComment for the SObject !!!"); + SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); + aCmnt->SetValue(aComment.latin1()); + // remove temporary file, if it's not multifile mode + if (false || !IsMultifile()) { + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(1); + aSeq[0]=(aStudyPrefix + myName).c_str(); + SALOMEDS_Tool::RemoveTemporaryFiles(thePrefix.c_str(), aSeq.in(), true); } return this; }catch(std::runtime_error& exc){ @@ -336,10 +314,6 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, return NULL; } -VISU::Result_i::InputType* VISU::Result_i::GetInput() { - return myInput; -} - void VISU::Result_i::ToStream(ostrstream& theStr){ if(MYDEBUG) MESSAGE(GetComment()); Storable::DataToStream(theStr,"myName",myName.c_str()); diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index 441e8260..4b5a30b1 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -28,28 +28,28 @@ namespace VISU{ typedef VISU_Convertor InputType; typedef vtkUnstructuredGridReader OutputType; - enum TSourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2}; private: - TSourceId mySourceId; InputType *myInput; string myName; QFileInfo myFileInfo; + int myIsRestored; protected: - virtual Storable* Build(SALOMEDS::SObject_ptr theSObject = NULL) - throw (std::runtime_error&); + virtual Storable* Build(); public: virtual Storable* Create(const char* theFileName); - virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject); + virtual Storable* Create(SALOME_MED::FIELD_ptr theField); + virtual Storable* Create(SALOME_MED::MESH_ptr theMesh); + virtual Storable* Create(SALOME_MED::SUPPORT_ptr theSupport); virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, const string& thePrefix, const Storable::TRestoringMap& theMap) throw(std::logic_error&); virtual void ToStream(ostrstream& theStr); virtual const char* GetComment() const; static const string myComment; - InputType* GetInput(); - const string& GetName() const { return myName;} + InputType* GetInput() { return myInput;} + const char* GetName() const { return myName.c_str();} const QFileInfo& GetFileInfo() const { return myFileInfo;} - Result_i::TSourceId GetSourceId() const { return mySourceId;} + int IsRestored() const { return myIsRestored;} private: SALOMEDS::SObject_var mySObject; SALOMEDS::Study_var myStudyDocument; diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index ba5dda37..1aba7769 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -886,8 +886,6 @@ int getLine(ifstream& theStmIn, QString& theString){ void ImportTables(const char* theFileName, TTableCont& theTableCont){ ifstream aStmIn; - QFileInfo aFileInfo(theFileName); - if(!aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size()) return; aStmIn.open(theFileName); QString aTmp; do{ diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index f475f1a5..2f481591 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -385,6 +385,7 @@ void VISU_TimeAnimation::run() { aName.replace(aPos, 1, "_"); aFile += aName; aFile += ".jpeg"; + //cout<<"### save:"<unlock(); diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index f7d2de23..82df8ba5 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -767,7 +767,7 @@ namespace VISU{ string aComm(aString); if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<= 0){ - aCmnt->SetValue(ToString().c_str()); + aCmnt->SetValue(ToString()); return 1; } } @@ -781,7 +781,7 @@ namespace VISU{ SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudy->getStudyDocument()); CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID()); - string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str()); + string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString()); return 1; } @@ -1108,23 +1108,14 @@ namespace VISU{ vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); aTransformFilter->SetInput ( mapper->GetInput() ); aTransformFilter->SetTransform (aTransform); - //create new mapper - vtkMapper* aIMapper = pSA->GetInitialMapper(); - if ((aIMapper != NULL) && aIMapper->IsA("vtkDataSetMapper")) { - vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( actor->GetMapper()); - actor->SetMapper (aMapper); - aMapper->Delete(); - } else { - vtkPolyDataMapper *aMapper = vtkPolyDataMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( actor->GetMapper()); - actor->SetMapper (aMapper); - aMapper->Delete(); - } + vtkPolyDataMapper *aMapper = vtkPolyDataMapper::New(); + aMapper->SetInput (aTransformFilter->GetOutput()); + aMapper->ShallowCopy ( actor->GetMapper()); + //set new mapper + actor->SetMapper (aMapper); aTransformFilter->Delete(); + aMapper->Delete(); changed = true; } } -- 2.39.2