From: vsr Date: Wed, 15 Jul 2009 08:04:58 +0000 (+0000) Subject: Merge from V5_1_2_BR branch (14 July 2009) X-Git-Tag: V5_1_3rc1~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=df1faca696439c283079e894409f5c369673d537;p=modules%2Fgui.git Merge from V5_1_2_BR branch (14 July 2009) --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 5f5a86d73..1c4e5c28a 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1958,6 +1958,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec, LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" ); +#ifdef FEATURE_19818 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup, LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" ); pref->setItemProperty( "columns", 2, vtkGN ); @@ -1970,6 +1971,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "min", 0.0, transPref ); pref->setItemProperty( "max", 1.0, transPref ); pref->setItemProperty( "step", 0.1, transPref ); +#endif // Plot2d pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup, diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 160c1410f..c88514681 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -30,7 +30,7 @@ ABOUT_COPYRIGHT - Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE + Copyright (C) 2007-2009 CEA/DEN, EDF R&D, OPEN CASCADE Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 17b981ca9..7f6251128 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 13ccd06c0..fa1ad83c7 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -34,9 +34,9 @@ #include #include #include +#include class QAction; -class QByteArray; class QDataStream; class QRubberBand; class QStackedWidget; diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index 042b6fc8c..204ae53c8 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -257,7 +257,9 @@ void SUIT_Application::setDesktop( SUIT_Desktop* desk ) if ( myDesktop == desk ) return; - delete myDesktop; + // >> VSR 09/06/2009: workaround about the Qt 4.5.0 bug: SIGSEGV on desktop delete + myDesktop->deleteLater(); // delete myDesktop; + // << VSR 09/06/2009 myDesktop = desk; if ( myDesktop ) { connect( myDesktop, SIGNAL( activated() ), this, SLOT( onDesktopActivated() ) ); diff --git a/src/SUIT/SUIT_FileDlg.cxx b/src/SUIT/SUIT_FileDlg.cxx index a3cb690f3..cadb8fa96 100755 --- a/src/SUIT/SUIT_FileDlg.cxx +++ b/src/SUIT/SUIT_FileDlg.cxx @@ -79,6 +79,7 @@ #include "SUIT_MessageBox.h" #include "SUIT_ResourceMgr.h" #include "SUIT_FileValidator.h" +#include "Qtx.h" #include #include @@ -497,6 +498,9 @@ QString SUIT_FileDlg::addExtension( const QString& fileName ) const QRegExp r( QString::fromLatin1("\\(?[a-zA-Z0-9.*? +;#|]*\\)?$") ); int index = r.indexIn( selectedFilter().trimmed() ); + if ( QFileInfo( fileName ).exists() ) + return fileName; // if file exists return as is + if ( index >= 0 ) { // Create wildcard regular expression basing on selected filter // in order to validate a file extension. @@ -981,5 +985,6 @@ QString SUIT_FileDlg::getLastVisitedPath() void SUIT_FileDlg::selectFile( const QString& f ) { QFileDialog::selectFile( QFileInfo( f ).baseName() ); - setDirectory( QFileInfo( f ).absoluteDir() ); + if ( !Qtx::dir( f, false ).isEmpty() ) + setDirectory( QFileInfo( f ).absolutePath() ); } diff --git a/src/SUIT/SUIT_FileValidator.cxx b/src/SUIT/SUIT_FileValidator.cxx index d2afda00e..ee6c3d2ed 100755 --- a/src/SUIT/SUIT_FileValidator.cxx +++ b/src/SUIT/SUIT_FileValidator.cxx @@ -66,7 +66,7 @@ bool SUIT_FileValidator::canOpen( const QString& fileName, bool checkPermission if ( checkPermission && !QFileInfo( fileName ).isReadable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); + QObject::tr( "ERR_OPEN_PERMISSION_DENIED" ).arg( fileName ) ); return false; } return true; @@ -105,6 +105,11 @@ bool SUIT_FileValidator::canSave( const QString& fileName, bool checkPermission } else { QString dirName = SUIT_Tools::dir( fileName ); + if ( !QFile::exists( dirName ) ) { + SUIT_MessageBox::critical( parent(), QObject::tr( "WRN_WARNING" ), + QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); + return false; + } if ( checkPermission && !QFileInfo( dirName ).isWritable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), @@ -144,7 +149,7 @@ bool SUIT_FileValidator::canReadDir( const QString& dirName, bool checkPermissio if ( checkPermission && !info.isReadable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( dirName ) ); + QObject::tr( "ERR_DIR_READ_PERMISSION_DENIED" ).arg( dirName ) ); return false; } return true; @@ -179,7 +184,7 @@ bool SUIT_FileValidator::canWriteDir( const QString& dirName, bool checkPermissi if ( checkPermission && !info.isWritable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( dirName ) ); + QObject::tr( "ERR_DIR_WRITE_PERMISSION_DENIED" ).arg( dirName ) ); return false; } return true; diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index 10ce1667e..dc76e7205 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -1676,6 +1676,8 @@ void SUIT_ItemDelegate::paint( QPainter* painter, QSize SUIT_ItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const { QSize size = QItemDelegate::sizeHint ( option, index ); +#if QT_VERSION >= 0x040500 size.setHeight( size.height() + 1 ); +#endif return size; } diff --git a/src/SUIT/resources/SUIT_msg_en.ts b/src/SUIT/resources/SUIT_msg_en.ts index feb7e2a30..62cfc102a 100644 --- a/src/SUIT/resources/SUIT_msg_en.ts +++ b/src/SUIT/resources/SUIT_msg_en.ts @@ -76,6 +76,21 @@ Do you want to overwrite it ? ERR_PERMISSION_DENIED Can't save file "%1". +Permission denied. + + + ERR_OPEN_PERMISSION_DENIED + Can't open file "%1". +Permission denied. + + + ERR_DIR_READ_PERMISSION_DENIED + Can't read directory "%1". +Permission denied. + + + ERR_DIR_WRITE_PERMISSION_DENIED + Can't write directory "%1". Permission denied. diff --git a/src/SUITApp/Makefile.am b/src/SUITApp/Makefile.am index 54b198a57..08eaa3fda 100644 --- a/src/SUITApp/Makefile.am +++ b/src/SUITApp/Makefile.am @@ -62,7 +62,7 @@ libSUITApp_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../Style/libSalomeS if ENABLE_PYCONSOLE libSUITApp_la_LDFLAGS += -Xlinker -export-dynamic $(PYTHON_LIBS) -CPPFLAGS+=-DSUIT_ENABLE_PYTHON +AM_CPPFLAGS=-DSUIT_ENABLE_PYTHON endif # Executable diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index cb64c5e63..4e5613ee0 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -805,8 +805,13 @@ SALOME_Actor } } } - mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); - mySelector->AddIObject( this ); + if( !anIndexes.IsEmpty() ) { + mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); + mySelector->AddIObject( this ); + anIndexes.Clear(); + } + else + mySelector->RemoveIObject( this ); } default: break; @@ -884,6 +889,8 @@ void SALOME_Actor ::UpdateNameActors() { + // the code is temporarily disabled due to bug 20383 +#ifdef FEATURE_19818 if( vtkRenderer* aRenderer = GetRenderer() ) { int anOffset[2] = { 0, 0 }; @@ -907,6 +914,7 @@ SALOME_Actor } } myNameActor->SetVisibility( GetVisibility() && IsDisplayNameActor() ); +#endif } /*! diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index fcaca8479..dddb815f4 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -1215,7 +1215,8 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) if ( aComponent->ComponentDataType() == "Interface Applicative" ) continue; // skip the magic "Interface Applicative" component - getWindow( WT_ObjectBrowser ); + if ( !objectBrowser() ) + getWindow( WT_ObjectBrowser ); const bool isAutoUpdate = objectBrowser()->autoUpdate(); objectBrowser()->setAutoUpdate( false ); SalomeApp_DataModel::synchronize( aComponent, study ); diff --git a/src/VTKViewer/VTKViewer_ArcBuilder.cxx b/src/VTKViewer/VTKViewer_ArcBuilder.cxx index 0c077bbdc..e8cd9e479 100644 --- a/src/VTKViewer/VTKViewer_ArcBuilder.cxx +++ b/src/VTKViewer/VTKViewer_ArcBuilder.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #define PRECISION 10e-4 #define ANGLE_PRECISION 0.5 @@ -87,16 +88,23 @@ double XYZ::Modulus () const { */ Pnt::Pnt(double X, double Y, - double Z): - coord(X,Y,Z) {} + double Z, + double ScalarValue): + coord(X,Y,Z), + scalarValue(ScalarValue) +{ +} +Pnt::Pnt() +{ +} -Pnt::Pnt(){} /*! * Destructor */ Pnt::~Pnt() -{} +{ +} //------------------------------------------------------------------------ /*! @@ -129,7 +137,12 @@ double Vec::AngleBetween(const Vec & Other) double res; double numerator = GetXYZ().X()*Other.GetXYZ().X()+GetXYZ().Y()*Other.GetXYZ().Y()+GetXYZ().Z()*Other.GetXYZ().Z(); double denumerator = GetXYZ().Modulus()*Other.GetXYZ().Modulus(); - res = acos(numerator/denumerator); + double d = numerator/denumerator; + if( d < -1 && d > -1 - PRECISION ) + d = -1; + else if( d > 1 && d < 1 + PRECISION ) + d = 1; + res = acos( d ); return res; } @@ -294,12 +307,13 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, double coords[3]; aTransformedGrid->GetPoint(0,coords); - myPnt1 = Pnt(coords[0],coords[1],coords[2]); + myPnt1 = Pnt(coords[0],coords[1],coords[2], thePnt1.GetScalarValue()); aTransformedGrid->GetPoint(1,coords); - myPnt2 = Pnt(coords[0],coords[1],coords[2]); + myPnt2 = Pnt(coords[0],coords[1],coords[2], thePnt2.GetScalarValue()); aTransformedGrid->GetPoint(2,coords); - myPnt3 = Pnt(coords[0],coords[1],coords[2]); - vtkUnstructuredGrid* anArc = BuildArc(); + myPnt3 = Pnt(coords[0],coords[1],coords[2], thePnt3.GetScalarValue()); + std::vector aScalarValues; + vtkUnstructuredGrid* anArc = BuildArc(aScalarValues); vtkUnstructuredGrid* anTransArc; if(needRotation) { anTransArc = TransformGrid(anArc,aAxis,-anAngle); @@ -309,6 +323,7 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, anTransArc = anArc; myPoints = anTransArc->GetPoints(); + myScalarValues = aScalarValues; myStatus = Arc_Done; } } @@ -323,6 +338,12 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, vtkUnstructuredGrid* aGrid = BuildGrid(aList); aGrid->Update(); myPoints = aGrid->GetPoints(); + + myScalarValues.clear(); + myScalarValues.push_back(thePnt1.GetScalarValue()); + myScalarValues.push_back(thePnt2.GetScalarValue()); + myScalarValues.push_back(thePnt3.GetScalarValue()); + myStatus = Arc_Done; } } @@ -387,12 +408,25 @@ void VTKViewer_ArcBuilder::GetAngle(const double theAngle){ myAngle = theAngle; } -vtkUnstructuredGrid* VTKViewer_ArcBuilder::BuildArc(){ +double InterpolateScalarValue(int index, int count, double firstValue, double middleValue, double lastValue) +{ + bool isFirstHalf = index <= count / 2; + double first = isFirstHalf ? firstValue : lastValue; + double last = isFirstHalf ? middleValue : middleValue; + double ratio = (double)index / (double)count; + double position = isFirstHalf ? ratio * 2 : ( 1 - ratio ) * 2; + double value = first + (last - first) * position; + return value; +} + +vtkUnstructuredGrid* VTKViewer_ArcBuilder::BuildArc(std::vector& theScalarValues){ double x1 = myPnt1.GetXYZ().X(); double x2 = myPnt2.GetXYZ().X(); double x3 = myPnt3.GetXYZ().X(); double y1 = myPnt1.GetXYZ().Y(); double y2 = myPnt2.GetXYZ().Y(); double y3 = myPnt3.GetXYZ().Y(); double z = myPnt1.GetXYZ().Z(); //Points on plane || XOY - + + theScalarValues.clear(); + double K1; double K2; K1 = (y2 - y1)/(x2 - x1); @@ -461,17 +495,22 @@ vtkUnstructuredGrid* VTKViewer_ArcBuilder::BuildArc(){ PntList aList; aList.push_back(myPnt1); - for(int i=0;i& VTKViewer_ArcBuilder::GetScalarValues() +{ + return myScalarValues; +} + VTKViewer_ArcBuilder::IncOrder VTKViewer_ArcBuilder::GetArcAngle( const double& P1, const double& P2, const double& P3,double* Ang){ IncOrder aResult; if(P1 < P2 && P2 < P3){ @@ -525,23 +573,33 @@ VTKViewer_ArcBuilder::IncOrder VTKViewer_ArcBuilder::GetArcAngle( const double& return aResult; } +//------------------------------------------------------------------------ +Pnt CreatePnt(vtkCell* cell, vtkDataArray* scalars, vtkIdType index) +{ + vtkFloatingPointType coord[3]; + cell->GetPoints()->GetPoint(index, coord); + vtkIdType pointId = cell->GetPointId(index); + double scalarValue = scalars ? scalars->GetTuple1(pointId) : 0; + Pnt point(coord[0], coord[1], coord[2], scalarValue); + return point; +} + //------------------------------------------------------------------------ vtkIdType Build1DArc(vtkIdType cellId, vtkUnstructuredGrid* input, vtkPolyData *output,vtkIdType *pts, vtkFloatingPointType myMaxArcAngle){ - vtkFloatingPointType coord[3]; vtkIdType aResult = -1; vtkIdType *aNewPoints; + vtkDataArray* inputScalars = input->GetPointData()->GetScalars(); + vtkDataArray* outputScalars = output->GetPointData()->GetScalars(); + vtkCell* aCell = input->GetCell(cellId); //Get All points from input cell - aCell->GetPoints()->GetPoint(0,coord); - Pnt P0(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(1,coord); - Pnt P1(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(2,coord); - Pnt P2(coord[0],coord[1],coord[2]); + Pnt P0 = CreatePnt( aCell, inputScalars, 0 ); + Pnt P1 = CreatePnt( aCell, inputScalars, 1 ); + Pnt P2 = CreatePnt( aCell, inputScalars, 2 ); VTKViewer_ArcBuilder aBuilder(P0,P2,P1,myMaxArcAngle); if (aBuilder.GetStatus() != VTKViewer_ArcBuilder::Arc_Done) { @@ -549,6 +607,7 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkUnstructuredGrid* input, } else{ vtkPoints* aPoints = aBuilder.GetPoints(); + std::vector aScalarValues = aBuilder.GetScalarValues(); vtkIdType aNbPts = aPoints->GetNumberOfPoints(); aNewPoints = new vtkIdType[aNbPts]; vtkIdType curID; @@ -557,6 +616,8 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkUnstructuredGrid* input, aNewPoints[0] = pts[0]; for(vtkIdType idx = 1; idx < aNbPts-1;idx++) { curID = output->GetPoints()->InsertNextPoint(aPoints->GetPoint(idx)); + if( outputScalars ) + outputScalars->InsertNextTuple1(aScalarValues[idx]); aNewPoints[idx] = curID; } aNewPoints[aNbPts-1] = pts[1]; @@ -570,7 +631,11 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkUnstructuredGrid* input, * Add all points from the input vector theCollection into thePoints. * Array theIds - it is array with ids of added points. */ -vtkIdType MergevtkPoints(const std::vector& theCollection, vtkPoints* thePoints, vtkIdType* &theIds){ +vtkIdType MergevtkPoints(const std::vector& theCollection, + const std::vector< std::vector >& theScalarCollection, + vtkPoints* thePoints, + std::map& thePntId2ScalarValue, + vtkIdType* &theIds){ vtkIdType aNbPoints = 0; vtkIdType anIdCounter = 0; vtkIdType aNewPntId = 0; @@ -584,15 +649,18 @@ vtkIdType MergevtkPoints(const std::vector& theCollection, vtkPoints } } it = theCollection.begin(); + std::vector< std::vector >::const_iterator itScalar = theScalarCollection.begin(); theIds = new vtkIdType[aNbPoints]; // ..and add all points - for(;it != theCollection.end();it++){ + for(;it != theCollection.end() && itScalar != theScalarCollection.end(); it++, itScalar++){ vtkPoints* aPoints = *it; + std::vector aScalarValues = *itScalar; if(aPoints){ for(vtkIdType idx = 0;idx < aPoints->GetNumberOfPoints()-1;idx++){ aNewPntId = thePoints->InsertNextPoint(aPoints->GetPoint(idx)); theIds[anIdCounter] = aNewPntId; + thePntId2ScalarValue[ aNewPntId ] = aScalarValues[idx]; anIdCounter++; } } diff --git a/src/VTKViewer/VTKViewer_ArcBuilder.h b/src/VTKViewer/VTKViewer_ArcBuilder.h index 3ee5acaa1..4ad39dc5f 100644 --- a/src/VTKViewer/VTKViewer_ArcBuilder.h +++ b/src/VTKViewer/VTKViewer_ArcBuilder.h @@ -24,18 +24,23 @@ #include "VTKViewer.h" #include +#include #include -class vtkUnstructuredGrid; +class vtkCell; +class vtkDataArray; class vtkPoints; class vtkPolyData; +class vtkUnstructuredGrid; class Pnt; typedef std::list PntList; vtkIdType MergevtkPoints(const std::vector& theCollection, - vtkPoints* thePoints, + const std::vector< std::vector >& theScalarCollection, + vtkPoints* thePoints, + std::map& thePntId2ScalarValue, vtkIdType* &theIds); vtkIdType Build1DArc(vtkIdType cellId, @@ -44,6 +49,9 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkIdType *pts, vtkFloatingPointType myMaxArcAngle); +Pnt CreatePnt(vtkCell* cell, + vtkDataArray* scalars, + vtkIdType index); /*! * Class for represenation coordinates X,Y,Z @@ -79,14 +87,16 @@ class XYZ{ class Pnt{ public: Pnt(); - Pnt(double , double , double ); + Pnt(double, double, double, double); ~Pnt(); void Coord (double& X, double& Y, double& Z) const {coord.Coord(X,Y,Z);} XYZ GetXYZ() const {return coord;} + double GetScalarValue() const { return scalarValue; } private: XYZ coord; + double scalarValue; }; /*! @@ -154,6 +164,7 @@ class VTKViewer_ArcBuilder{ const double theXPoint, const double theYPoint); vtkPoints* GetPoints(); + const std::vector& GetScalarValues(); private: @@ -161,7 +172,7 @@ class VTKViewer_ArcBuilder{ vtkUnstructuredGrid* BuildGrid(const PntList& theList) const; vtkUnstructuredGrid* TransformGrid(vtkUnstructuredGrid* theGrid, const Vec& theAxis, const double angle) const; - vtkUnstructuredGrid* BuildArc(); + vtkUnstructuredGrid* BuildArc(std::vector& theScalarValues); IncOrder GetArcAngle( const double& P1, const double& P2, const double& P3, double* Ang); @@ -174,6 +185,7 @@ class VTKViewer_ArcBuilder{ double myAngle; ArcStatus myStatus; vtkPoints* myPoints; + std::vector myScalarValues; }; #endif //VTKVIEWER_ARCBUILDER_H diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index 6286b2632..be5781ae0 100755 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -198,8 +198,13 @@ VTKViewer_GeometryFilter cellVis = new char[numCells]; } - // Just pass points through, never merge - output->SetPoints(input->GetPoints()); + // Issue 0020115: [CEA 308] Quadratic elements visualization + // Fix of remark described in note 0005222 - SIGSEGV + vtkPoints* outputPoints = vtkPoints::New(); + outputPoints->DeepCopy(input->GetPoints()); + output->SetPoints(outputPoints); + outputPoints->Delete(); + outputPD->PassData(pd); outputCD->CopyAllocate(cd,numCells,numCells/2); @@ -595,8 +600,12 @@ VTKViewer_GeometryFilter aNewPts[3] = pts[4]; aNewPts[4] = pts[2]; aNewPts[5] = pts[5]; - + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); } else BuildArcedPolygon(cellId,input,output); @@ -615,7 +624,12 @@ VTKViewer_GeometryFilter aNewPts[5] = pts[6]; aNewPts[6] = pts[3]; aNewPts[7] = pts[7]; + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); } else BuildArcedPolygon(cellId,input,output); @@ -1030,234 +1044,157 @@ vtkIdType VTKViewer_GeometryFilter::GetElemObjId( int theVtkID ) void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId, vtkUnstructuredGrid* input, vtkPolyData *output, bool triangulate){ - vtkFloatingPointType coord[3]; vtkIdType aCellType = VTK_POLYGON; - vtkIdType *aNewPoints; + vtkIdType *aNewPoints = NULL; vtkIdType aNbPoints = 0; vtkIdType newCellId; //Input and output cell data vtkCellData *cd = input->GetCellData(); vtkCellData *outputCD = output->GetCellData(); - + + //Input and output scalars on point data + vtkDataArray* inputScalars = input->GetPointData()->GetScalars(); + vtkDataArray* outputScalars = output->GetPointData()->GetScalars(); + + std::vector aCollection; + std::vector< std::vector > aScalarCollection; + vtkCell* aCell = input->GetCell(cellId); switch(aCell->GetCellType()) { - case VTK_QUADRATIC_TRIANGLE: + case VTK_QUADRATIC_TRIANGLE: { //Get All points from input cell - aCell->GetPoints()->GetPoint(0,coord); - Pnt P0(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(1,coord); - Pnt P1(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(2,coord); - Pnt P2(coord[0],coord[1],coord[2]); - - aCell->GetPoints()->GetPoint(3,coord); - Pnt P3(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(4,coord); - Pnt P4(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(5,coord); - Pnt P5(coord[0],coord[1],coord[2]); - - //Build arc usinf 0, 3 and 1 points - VTKViewer_ArcBuilder aBuilder1(P0,P3,P1,myMaxArcAngle); + Pnt P0 = CreatePnt( aCell, inputScalars, 0 ); + Pnt P1 = CreatePnt( aCell, inputScalars, 1 ); + Pnt P2 = CreatePnt( aCell, inputScalars, 2 ); + Pnt P3 = CreatePnt( aCell, inputScalars, 3 ); + Pnt P4 = CreatePnt( aCell, inputScalars, 4 ); + Pnt P5 = CreatePnt( aCell, inputScalars, 5 ); + + VTKViewer_ArcBuilder aBuilder1(P0,P3,P1,myMaxArcAngle); //Build arc using 0, 3 and 1 points #ifdef __MYDEBUG__ - if(aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) { - cout<<"Triangle arc 1 done !!!"< aCollection; + aCollection.push_back(aBuilder1.GetPoints()); aCollection.push_back(aBuilder2.GetPoints()); aCollection.push_back(aBuilder3.GetPoints()); - - - //----------------------------------------------------------------------------------------- - if(triangulate){ - const vtkIdType numFacePts = 3; - vtkIdList *pts = vtkIdList::New(); - vtkPoints *coords = vtkPoints::New(); - aCellType = VTK_TRIANGLE; - vtkIdType aNewPts[numFacePts]; - vtkIdType aTriangleId; - - vtkPolygon *aPlg = vtkPolygon::New(); - aNbPoints = MergevtkPoints(aCollection, aPlg->GetPoints(), aNewPoints); - aPlg->GetPointIds()->SetNumberOfIds(aNbPoints); - - for(vtkIdType i = 0; i < aNbPoints;i++) { - aPlg->GetPointIds()->SetId(i, aNewPoints[i]); - } - - aPlg->Triangulate(0,pts,coords); - - for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) { - aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i)); - aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1)); - aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2)); - - aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - outputCD->CopyData(cd,cellId,aTriangleId); - } - pts->Delete(); - coords->Delete(); - aPlg->Delete(); - } - //--------------------------------------------------------------------------------------------------- - else { - aNbPoints = MergevtkPoints(aCollection, output->GetPoints(), aNewPoints); - newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints); - outputCD->CopyData(cd,cellId,newCellId); - - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - } + + aScalarCollection.push_back(aBuilder1.GetScalarValues()); + aScalarCollection.push_back(aBuilder2.GetScalarValues()); + aScalarCollection.push_back(aBuilder3.GetScalarValues()); break; - } //VTK_QUADRATIC_TRIANGLE - + } case VTK_QUADRATIC_QUAD: - { - //Get All points from input cell - aCell->GetPoints()->GetPoint(0,coord); - Pnt P0(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(1,coord); - Pnt P1(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(2,coord); - Pnt P2(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(3,coord); - Pnt P3(coord[0],coord[1],coord[2]); - - aCell->GetPoints()->GetPoint(4,coord); - Pnt P4(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(5,coord); - Pnt P5(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(6,coord); - Pnt P6(coord[0],coord[1],coord[2]); - aCell->GetPoints()->GetPoint(7,coord); - Pnt P7(coord[0],coord[1],coord[2]); - - //Build arc usinf 0, 4 and 1 points - VTKViewer_ArcBuilder aBuilder1(P0,P4,P1,myMaxArcAngle); + { + //Get All points from input cell + Pnt P0 = CreatePnt( aCell, inputScalars, 0 ); + Pnt P1 = CreatePnt( aCell, inputScalars, 1 ); + Pnt P2 = CreatePnt( aCell, inputScalars, 2 ); + Pnt P3 = CreatePnt( aCell, inputScalars, 3 ); + Pnt P4 = CreatePnt( aCell, inputScalars, 4 ); + Pnt P5 = CreatePnt( aCell, inputScalars, 5 ); + Pnt P6 = CreatePnt( aCell, inputScalars, 6 ); + Pnt P7 = CreatePnt( aCell, inputScalars, 7 ); + + VTKViewer_ArcBuilder aBuilder1(P0,P4,P1,myMaxArcAngle); //Build arc using 0, 4 and 1 points #ifdef __MYDEBUG__ - if(aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) { - cout<<"Quadrangle arc 1 done !!!"< aCollection; - aCollection.push_back(aBuilder1.GetPoints()); - aCollection.push_back(aBuilder2.GetPoints()); - aCollection.push_back(aBuilder3.GetPoints()); - aCollection.push_back(aBuilder4.GetPoints()); - - //----------------------------------------------------------------------------------------- - if(triangulate){ - const vtkIdType numFacePts = 3; - vtkIdList *pts = vtkIdList::New(); - vtkPoints *coords = vtkPoints::New(); - aCellType = VTK_TRIANGLE; - vtkIdType aNewPts[numFacePts]; - vtkIdType aTriangleId; - - vtkPolygon *aPlg = vtkPolygon::New(); - aNbPoints = MergevtkPoints(aCollection, aPlg->GetPoints(), aNewPoints); - aPlg->GetPointIds()->SetNumberOfIds(aNbPoints); - - for(vtkIdType i = 0; i < aNbPoints;i++) { - aPlg->GetPointIds()->SetId(i, aNewPoints[i]); - } - - aPlg->Triangulate(0,pts,coords); - - for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) { - aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i)); - aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1)); - aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2)); - - aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - outputCD->CopyData(cd,cellId,aTriangleId); - } - pts->Delete(); - coords->Delete(); - aPlg->Delete(); - } - else { - aNbPoints = MergevtkPoints(aCollection, output->GetPoints(), aNewPoints); - newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints); - outputCD->CopyData(cd,cellId,newCellId); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - } - break; - } //VTK_QUADRATIC_QUAD - - //Unsupported cell type - default: - break; - } //switch + aCollection.push_back(aBuilder1.GetPoints()); + aCollection.push_back(aBuilder2.GetPoints()); + aCollection.push_back(aBuilder3.GetPoints()); + aCollection.push_back(aBuilder4.GetPoints()); + + aScalarCollection.push_back(aBuilder1.GetScalarValues()); + aScalarCollection.push_back(aBuilder2.GetScalarValues()); + aScalarCollection.push_back(aBuilder3.GetScalarValues()); + aScalarCollection.push_back(aBuilder4.GetScalarValues()); + break; + } + default: //Unsupported cell type + return; + } + + if(triangulate){ + const vtkIdType numFacePts = 3; + vtkIdList *pts = vtkIdList::New(); + vtkPoints *coords = vtkPoints::New(); + aCellType = VTK_TRIANGLE; + vtkIdType aNewPts[numFacePts]; + vtkIdType aTriangleId; + + vtkPolygon *aPlg = vtkPolygon::New(); + std::map aPntId2ScalarValue; + aNbPoints = MergevtkPoints(aCollection, aScalarCollection, aPlg->GetPoints(), aPntId2ScalarValue, aNewPoints); + aPlg->GetPointIds()->SetNumberOfIds(aNbPoints); + + for(vtkIdType i = 0; i < aNbPoints;i++) { + aPlg->GetPointIds()->SetId(i, aNewPoints[i]); + } + + aPlg->Triangulate(0,pts,coords); + + for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) { + aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i)); + aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1)); + aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2)); + + if(outputScalars) { + outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]); + outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]); + outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]); + } + + aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,aTriangleId); + } + pts->Delete(); + coords->Delete(); + aPlg->Delete(); + } + else { + std::map aPntId2ScalarValue; + aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints); + if(outputScalars) + for(vtkIdType i = 0; i < aNbPoints; i++) + outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]); + newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints); + outputCD->CopyData(cd,cellId,newCellId); + + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + } if (aNewPoints) delete [] aNewPoints;