]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Merge from V5_1_2_BR branch (14 July 2009)
authorvsr <vsr@opencascade.com>
Wed, 15 Jul 2009 08:04:58 +0000 (08:04 +0000)
committervsr <vsr@opencascade.com>
Wed, 15 Jul 2009 08:04:58 +0000 (08:04 +0000)
15 files changed:
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp_msg_en.ts
src/Qtx/QtxWorkstack.cxx
src/Qtx/QtxWorkstack.h
src/SUIT/SUIT_Application.cxx
src/SUIT/SUIT_FileDlg.cxx
src/SUIT/SUIT_FileValidator.cxx
src/SUIT/SUIT_TreeModel.cxx
src/SUIT/resources/SUIT_msg_en.ts
src/SUITApp/Makefile.am
src/SVTK/SALOME_Actor.cxx
src/SalomeApp/SalomeApp_Application.cxx
src/VTKViewer/VTKViewer_ArcBuilder.cxx
src/VTKViewer/VTKViewer_ArcBuilder.h
src/VTKViewer/VTKViewer_GeometryFilter.cxx

index 5f5a86d7359e6bdcec3a644fe5df8abd53ab138d..1c4e5c28a4a626ec940452960ec0eb1a94e0b4bc 100644 (file)
@@ -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,
index 160c1410f3fee8d5e2da1fa3e1016700662f51a2..c8851468187889f0309e743afcb26babc93d23a4 100644 (file)
@@ -30,7 +30,7 @@
     </message>
     <message>
         <source>ABOUT_COPYRIGHT</source>
-        <translation>Copyright (C) 2007-2008 CEA/DEN, EDF R&amp;D, OPEN CASCADE
+        <translation>Copyright (C) 2007-2009 CEA/DEN, EDF R&amp;D, OPEN CASCADE
 
 Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6,
 CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translation>
index 17b981ca90b1aca2de18fa9e3bdd776cf1639f7e..7f62511284179ea69a82d88f9934e5a9a7dba953 100644 (file)
@@ -31,7 +31,6 @@
 #include <QRegExp>
 #include <QLayout>
 #include <QPainter>
-#include <QByteArray>
 #include <QDataStream>
 #include <QFocusEvent>
 #include <QMouseEvent>
index 13ccd06c050cadff96b8a25a847880050c08ea85..fa1ad83c770e920bdc68913010fa8267eb6b918c 100644 (file)
@@ -34,9 +34,9 @@
 #include <QTabBar>
 #include <QPointer>
 #include <QSplitter>
+#include <QByteArray>
 
 class QAction;
-class QByteArray;
 class QDataStream;
 class QRubberBand;
 class QStackedWidget;
index 042b6fc8c11492c3b2bd5bae5c13c2271535d035..204ae53c8f34411ec239c73433920682d1d3005b 100755 (executable)
@@ -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() ) );
index a3cb690f339196b6b9bf9aa4a7591ffdd56bfa49..cadb8fa966792219c62002109665e5c25b709ee3 100755 (executable)
@@ -79,6 +79,7 @@
 #include "SUIT_MessageBox.h"
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_FileValidator.h"
+#include "Qtx.h"
 
 #include <QDir>
 #include <QEvent>
@@ -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() );
 }
index d2afda00ed9c4f00d25d96294bfa3d0698eb7726..ee6c3d2ed447a45be1dd3e4bfd7872c831c6c866 100755 (executable)
@@ -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;
index 10ce1667ebad1d706264e4bffac0c9ce6cf51a0c..dc76e72057321f3f3b73b08b2b8bdc5de37a31ec 100755 (executable)
@@ -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;
 }
index feb7e2a3030e686b04cd5b8f1e981897cc61d36f..62cfc102ace632a460da51ff7ba9f7d56a00aa11 100644 (file)
@@ -76,6 +76,21 @@ Do you want to overwrite it ?</translation>
     <message>
         <source>ERR_PERMISSION_DENIED</source>
         <translation>Can&apos;t save file &quot;%1&quot;.
+Permission denied.</translation>
+    </message>
+    <message>
+        <source>ERR_OPEN_PERMISSION_DENIED</source>
+        <translation>Can&apos;t open file &quot;%1&quot;.
+Permission denied.</translation>
+    </message>
+    <message>
+        <source>ERR_DIR_READ_PERMISSION_DENIED</source>
+        <translation>Can&apos;t read directory &quot;%1&quot;.
+Permission denied.</translation>
+    </message>
+    <message>
+        <source>ERR_DIR_WRITE_PERMISSION_DENIED</source>
+        <translation>Can&apos;t write directory &quot;%1&quot;.
 Permission denied.</translation>
     </message>
     <message>
index 54b198a57da9b1fb8ad7a0718ac8a8105caf4cfc..08eaa3fda446213bf1b56722dceaa1c405e767d1 100644 (file)
@@ -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
index cb64c5e6306462c7b10ca8f6a8c97a1d06040b78..4e5613ee0c5198675076813f7609edb0259c1d91 100644 (file)
@@ -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
 }
 
 /*!
index fcaca8479b579c248fb44a55fc426252c64031e0..dddb815f43e991dd100f28b377bd3ffab2bf2b95 100644 (file)
@@ -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 );
index 0c077bbdc0f6d11c5c046cf850c6e58ee1e3772b..e8cd9e4796f8b6349cc2e8d23ea2e13cb6ebcaca 100644 (file)
@@ -37,6 +37,7 @@
 #include <vtkCellArray.h>
 #include <vtkTriangle.h>
 #include <vtkPolyData.h>
+#include <vtkPointData.h>
 
 #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<double> 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<double>& 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<nbSteps-1;i++){
+    theScalarValues.push_back(myPnt1.GetScalarValue());
+    for(int i=1;i<=nbSteps-1;i++){
       double x = xCenter + aRadius*cos(aCurrentAngle);
       double y = yCenter + aRadius*sin(aCurrentAngle);
-      Pnt aPnt(x,y,z);
+      double value = InterpolateScalarValue(i, nbSteps, myPnt1.GetScalarValue(), myPnt2.GetScalarValue(), myPnt3.GetScalarValue());
+      Pnt aPnt(x,y,z,value);
+
       aList.push_back(aPnt);
+      theScalarValues.push_back(aPnt.GetScalarValue());
       if(aOrder == VTKViewer_ArcBuilder::MINUS)
         aCurrentAngle-=anIncrementAngle;
       else
         aCurrentAngle+=anIncrementAngle;
     }
     aList.push_back(myPnt3);
+    theScalarValues.push_back(myPnt3.GetScalarValue());
     
     aC = BuildGrid(aList);
 #ifdef _MY_DEBUG_
@@ -486,6 +525,10 @@ vtkUnstructuredGrid* VTKViewer_ArcBuilder::BuildArc(){
     aList.push_back(myPnt2);
     aList.push_back(myPnt3);
     aC = BuildGrid(aList);
+
+    theScalarValues.push_back(myPnt1.GetScalarValue());
+    theScalarValues.push_back(myPnt2.GetScalarValue());
+    theScalarValues.push_back(myPnt3.GetScalarValue());
   }
   return aC;
 }
@@ -504,6 +547,11 @@ vtkPoints* VTKViewer_ArcBuilder::GetPoints(){
   return myPoints;
 }
 
+const std::vector<double>& 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<double> 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<vtkPoints*>& theCollection, vtkPoints* thePoints, vtkIdType* &theIds){
+vtkIdType MergevtkPoints(const std::vector<vtkPoints*>& theCollection,
+                        const std::vector< std::vector<double> >& theScalarCollection,
+                        vtkPoints* thePoints,
+                        std::map<int, double>& thePntId2ScalarValue,
+                        vtkIdType* &theIds){
   vtkIdType aNbPoints = 0;
   vtkIdType anIdCounter = 0;
   vtkIdType aNewPntId = 0;
@@ -584,15 +649,18 @@ vtkIdType MergevtkPoints(const std::vector<vtkPoints*>& theCollection, vtkPoints
     }
   }
   it = theCollection.begin();
+  std::vector< std::vector<double> >::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<double> 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++;
       }
     }
index 3ee5acaa1ffac11d2d3e400f2f60304d231a96ec..4ad39dc5f874008015ce6a0690a63d18f0cf4715 100644 (file)
 
 #include "VTKViewer.h"
 #include <list>
+#include <map>
 #include <vector>
 
-class vtkUnstructuredGrid;
+class vtkCell;
+class vtkDataArray;
 class vtkPoints;
 class vtkPolyData;
+class vtkUnstructuredGrid;
 
 class Pnt;
 
 typedef std::list<Pnt> PntList;
 
 vtkIdType MergevtkPoints(const std::vector<vtkPoints*>& theCollection,
-                         vtkPoints* thePoints, 
+                        const std::vector< std::vector<double> >& theScalarCollection,
+                         vtkPoints* thePoints,
+                        std::map<int, double>& 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<double>& 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<double>& 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<double> myScalarValues;
 };
 
 #endif //VTKVIEWER_ARCBUILDER_H 
index 6286b2632b56665c14498975c3f4c063514bf677..be5781ae0489162deb6cdb20f699d35e8381c98b 100755 (executable)
@@ -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<vtkPoints*> aCollection;
+  std::vector< std::vector<double> > 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 !!!"<<endl;
-      }
-      else{
-        cout<<"Triangle arc 1 NOT done !!!"<<endl;
-      }
+      cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-      
-      //Build arc usinf 1, 4 and 2 points
-      VTKViewer_ArcBuilder aBuilder2(P1,P4,P2,myMaxArcAngle);
+
+      VTKViewer_ArcBuilder aBuilder2(P1,P4,P2,myMaxArcAngle); //Build arc using 1, 4 and 2 points
 #ifdef __MYDEBUG__
-      if(aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) {
-        cout<<"Triangle arc 2 done !!!"<<endl;
-      }      
-      else{
-        cout<<"Triangle arc 2 NOT done !!!"<<endl;
-      }
+      cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-      //Build arc usinf 2, 5 and 0 points
-      VTKViewer_ArcBuilder aBuilder3(P2,P5,P0,myMaxArcAngle);
+
+      VTKViewer_ArcBuilder aBuilder3(P2,P5,P0,myMaxArcAngle); //Build arc using 2, 5 and 0 points
 #ifdef __MYDEBUG__
-      if(aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) {
-        cout<<"Triangle arc 3 done !!!"<<endl;
-      }
-      else{
-        cout<<"Triangle arc 3 NOT done !!!"<<endl;
-      }
+      cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-      std::vector<vtkPoints*> 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 !!!"<<endl;
-        }
-        else{
-          cout<<"Quadrangle arc 1 NOT done !!!"<<endl;
-        }
+      cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-        //Build arc usinf 1, 5 and 2 points
-        VTKViewer_ArcBuilder aBuilder2(P1,P5,P2,myMaxArcAngle);
+
+      VTKViewer_ArcBuilder aBuilder2(P1,P5,P2,myMaxArcAngle); //Build arc using 1, 5 and 2 points
 #ifdef __MYDEBUG__
-        if(aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) {
-          cout<<"Quadrangle arc 2 done !!!"<<endl;
-        }      
-        else{
-          cout<<"Quadrangle arc 2 NOT done !!!"<<endl;
-        }
+      cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-        //Build arc usinf 2, 6 and 3 points
-        VTKViewer_ArcBuilder aBuilder3(P2,P6,P3,myMaxArcAngle);
+
+      VTKViewer_ArcBuilder aBuilder3(P2,P6,P3,myMaxArcAngle); //Build arc using 2, 6 and 3 points
 #ifdef __MYDEBUG__
-        if(aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) {
-          cout<<"Quadrangle arc 3 done !!!"<<endl;
-        }
-        else{
-          cout<<"Quadrangle arc 3 NOT done !!!"<<endl;
-        }
+      cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-        //Build arc usinf 3, 7 and 0 points
-        VTKViewer_ArcBuilder aBuilder4(P3,P7,P0,myMaxArcAngle);
+
+      VTKViewer_ArcBuilder aBuilder4(P3,P7,P0,myMaxArcAngle); //Build arc using 3, 7 and 0 points
 #ifdef __MYDEBUG__
-        if(aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done) {
-          cout<<"Quadrangle arc 4 done !!!"<<endl;
-        }
-        else{
-          cout<<"Quadrangle arc 4 NOT done !!!"<<endl;
-        }
+      cout << "Quadrangle arc 4 " << ( aBuilder4.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
 #endif
-        std::vector<vtkPoints*> 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<int, double> 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<int, double> 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;