Salome HOME
Merge branch 'OCCT780'
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index c476156c8562fc24451f36ded6724e8d4e496b60..be17fe3c30317da05193bf43c17d083e1e28f2d5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 
 #include "utilities.h"
 
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
 
 using namespace std;
 
@@ -83,7 +78,7 @@ vtkStandardNewMacro(SMESH_DeviceActor)
 SMESH_DeviceActor
 ::SMESH_DeviceActor()
 {
-  if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
+  MESSAGE("SMESH_DeviceActor - "<<this);
 
   myIsShrinkable = false;
   myIsShrunk = false;
@@ -140,7 +135,7 @@ SMESH_DeviceActor
 SMESH_DeviceActor
 ::~SMESH_DeviceActor()
 {
-  if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
+  MESSAGE("~SMESH_DeviceActor - "<<this);
 
   myMapper->Delete();
   // myPlaneCollection->Delete(); -- it is vtkSmartPointer
@@ -509,6 +504,80 @@ SMESH_DeviceActor
       theLookupTable->SetRange(aScalars->GetRange());
       theLookupTable->Build();
 
+      myMergeFilter->SetScalarsData(aDataSet);
+      aDataSet->Delete();
+    }
+    else if (Warping3D* aWarping3D = dynamic_cast<Warping3D*>(theFunctor.get())){
+
+      SMESH::Controls::Warping3D::WValues aValues;
+
+      aWarping3D->GetValues(aValues);
+      vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+      vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+
+      aDataSet->SetPoints(aGrid->GetPoints());
+
+      vtkIdType aNbCells = aValues.size();
+
+      vtkDoubleArray* aScalars = vtkDoubleArray::New();
+      aScalars->SetNumberOfComponents(1);
+      aScalars->SetNumberOfTuples(aNbCells);
+
+      vtkIdType aCellsSize = 3 * aNbCells;
+      vtkCellArray* aConnectivity = vtkCellArray::New();
+      aConnectivity->Allocate(aCellsSize, 0);
+
+      vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+      aCellTypesArray->SetNumberOfComponents(1);
+      aCellTypesArray->Allocate(aNbCells* aCellTypesArray->GetNumberOfComponents());
+
+      Warping3D::WValues::const_iterator anIter = aValues.begin();
+      aNbCells = 0;
+      for (; anIter != aValues.end(); anIter++) {
+
+        const Warping3D::Value& aValue = *anIter;
+        vtkIdList* anIdList = vtkIdList::New();
+        anIdList->SetNumberOfIds(aValue.myPntIds.size());
+        bool isExist = true;
+        for (int i = 0; i < aValue.myPntIds.size(); ++i)
+        {
+          int aVTKId = myVisualObj->GetNodeVTKId(aValue.myPntIds[i]);
+          if (aVTKId < 0)
+          {
+            isExist = false;
+            break;
+          }
+          anIdList->SetId(i, aVTKId);
+        }
+        if (isExist)
+        {
+          aConnectivity->InsertNextCell(anIdList);
+          aCellTypesArray->InsertNextValue(VTK_POLYGON);
+          aScalars->SetValue(aNbCells, aValue.myWarp);
+          aNbCells++;
+        }
+      }
+      aCellTypesArray->SetNumberOfTuples(aNbCells);
+      aScalars->SetNumberOfTuples(aNbCells);
+
+      vtkIdTypeArray* aCellLocationsArray = vtkIdTypeArray::New();
+      aCellLocationsArray->SetNumberOfComponents(1);
+      aCellLocationsArray->SetNumberOfTuples(aNbCells);
+
+      aConnectivity->InitTraversal();
+      vtkIdType const* pts(nullptr);
+      for (vtkIdType idType = 0, npts; aConnectivity->GetNextCell(npts, pts); idType++)
+        aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
+
+      aDataSet->SetCells(aCellTypesArray, aCellLocationsArray, aConnectivity);
+      SetUnstructuredGrid(aDataSet);
+
+      aDataSet->GetCellData()->SetScalars(aScalars);
+      aScalars->Delete();
+
+      theLookupTable->SetRange(aScalars->GetRange());
+      theLookupTable->Build();
+
       myMergeFilter->SetScalarsData(aDataSet);
       aDataSet->Delete();
     }
@@ -851,7 +920,7 @@ SMESH_DeviceActor
     anID = myExtractGeometry->GetNodeObjId(theVtkID);
 
   vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
-  if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
+  MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
   return aRetID;
 }
 
@@ -862,7 +931,7 @@ SMESH_DeviceActor
   vtkDataSet* aDataSet = myMergeFilter->GetOutput();
   vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
   double* aCoord = (anID >=0 && anID < aDataSet->GetNumberOfPoints()) ? aDataSet->GetPoint(anID) : NULL;
-  if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
+  MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
   return aCoord;
 }
 
@@ -892,8 +961,8 @@ SMESH_DeviceActor
     return -1;
 
   vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
-  if(MYDEBUG) 
-     MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
+
+  MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
   return aRetID;
 }
 
@@ -904,8 +973,8 @@ SMESH_DeviceActor
   vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
   vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
   vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
-  if(MYDEBUG) 
-    MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
+
+  MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
   return aCell;
 }