Salome HOME
updated copyright message
[modules/gui.git] / src / VTKViewer / VTKViewer_ConvexTool.cxx
index 735ee583cf862a9fb34b834aceeca96f79adc520..62d3709ba38baa7b408a0d365226461c3bf31de5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  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
@@ -81,9 +81,9 @@ namespace
 VTKViewer_Triangulator
 ::VTKViewer_Triangulator():
   myCellIds(vtkIdList::New()),
+  myPointIds(NULL),
   myFaceIds(vtkIdList::New()),
-  myPoints(vtkPoints::New()),
-  myPointIds(NULL)
+  myPoints(vtkPoints::New())
 {}
 
 
@@ -107,12 +107,14 @@ VTKViewer_Triangulator
   myPoints->Modified(); // the VTK bug
 
   vtkIdType aNumPts;
-  theInput->GetCellPoints(theCellId, aNumPts, myPointIds); 
+  vtkIdType const *tmp;
+  theInput->GetCellPoints(theCellId, aNumPts, tmp);
+  myPointIds = const_cast<vtkIdType*>( tmp );
   if ( aNumPts > 0 ) {
     double anAbsoluteCoord[3];
     myPoints->SetNumberOfPoints(aNumPts);
     vtkPoints *anInputPoints = theInput->GetPoints();
-    for (int aPntId = 0; aPntId < aNumPts; aPntId++) {
+    for (auto aPntId = 0; aPntId < aNumPts; aPntId++) {
       anInputPoints->GetPoint(myPointIds[aPntId], anAbsoluteCoord);
       myPoints->SetPoint(aPntId, anAbsoluteCoord);
     }
@@ -200,7 +202,7 @@ VTKViewer_Triangulator
           vtkCellData* theOutputCD,
           int theStoreMapping,
           std::vector<vtkIdType>& theVTK2ObjIds,
-          std::map< vtkIdType, std::vector<vtkIdType> >& theDimension2VTK2ObjIds,
+          std::vector< std::vector<vtkIdType> >& theDimension2VTK2ObjIds,
           bool theIsCheckConvex)
 {
   vtkPoints *aPoints = InitPoints(theInput, theCellId);
@@ -214,7 +216,7 @@ VTKViewer_Triangulator
   double aCellCenter[3] = {0.0, 0.0, 0.0};
   {
     double aPntCoord[3];
-    for (int aPntId = 0; aPntId < aNumPts; aPntId++) {
+    for (auto aPntId = 0; aPntId < aNumPts; aPntId++) {
       aPoints->GetPoint(GetPointId(aPntId),aPntCoord);
       if(DEBUG_TRIA_EXECUTE) cout<<"\taPntId = "<<GetPointId(aPntId)<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}\n";
       aCellCenter[0] += aPntCoord[0];
@@ -227,7 +229,7 @@ VTKViewer_Triangulator
   }
 
   double aCellLength = GetCellLength();
-  int aNumFaces = GetNumFaces();
+  vtkIdType aNumFaces = GetNumFaces();
 
   static double EPS = 1.0E-2;
   double aDistEps = aCellLength/3.0 * EPS;
@@ -246,7 +248,7 @@ VTKViewer_Triangulator
   typedef std::set<TPointIds> TFace2PointIds;
   TFace2PointIds aFace2PointIds;
 
-  for (int aFaceId = 0; aFaceId < aNumFaces; aFaceId++) {
+  for (auto aFaceId = 0; aFaceId < aNumFaces; aFaceId++) {
     vtkCell* aFace = GetFace(aFaceId);
     
     GetCellNeighbors(theInput, theCellId, aFace, myCellIds);
@@ -268,7 +270,7 @@ VTKViewer_Triangulator
 
   ::TPolygons aPolygons;
 
-  for (int aFaceId = 0; aFaceId < aNumFaces; aFaceId++) {
+  for (auto aFaceId = 0; aFaceId < aNumFaces; aFaceId++) {
     if(aFace2Visibility.find(aFaceId) == aFace2Visibility.end())
       continue;
 
@@ -403,7 +405,7 @@ VTKViewer_Triangulator
             if(DEBUG_TRIA_EXECUTE) cout  << "; Added = FALSE" << endl;
           }
         }
-        int aNbPoints = aPointIds.size();
+        size_t aNbPoints = aPointIds.size();
         aCenter[0] /= aNbPoints;
         aCenter[1] /= aNbPoints;
         aCenter[2] /= aNbPoints;
@@ -521,7 +523,7 @@ VTKViewer_Triangulator
         }
 
         if(!aSortedPointIds.empty()){
-          int aNumFacePts = aSortedPointIds.size();
+          size_t aNumFacePts = aSortedPointIds.size();
           ::TConnectivities aConnectivities(aNumFacePts);
           TSortedPointIds::const_iterator anIter = aSortedPointIds.begin();
           TSortedPointIds::const_iterator anEndIter = aSortedPointIds.end();
@@ -542,8 +544,8 @@ VTKViewer_Triangulator
 
   // To check, whether the polygons give a convex polyhedron or not
   if(theIsCheckConvex){
-    int aNbPolygons = aPolygons.size();
-    for (int aPolygonId = 0; aPolygonId < aNbPolygons; aPolygonId++) {
+    size_t aNbPolygons = aPolygons.size();
+    for (size_t aPolygonId = 0; aPolygonId < aNbPolygons; aPolygonId++) {
       ::TPolygon& aPolygon = aPolygons[aPolygonId];
       double* aNormal = aPolygon.myNormal;
       double* anOrigin = aPolygon.myOrigin;
@@ -567,17 +569,17 @@ VTKViewer_Triangulator
 
   // To pass resulting set of the polygons to the output
   {
-    int aNbPolygons = aPolygons.size();
-    for (int aPolygonId = 0; aPolygonId < aNbPolygons; aPolygonId++) {
+    size_t aNbPolygons = aPolygons.size();
+    for (size_t aPolygonId = 0; aPolygonId < aNbPolygons; aPolygonId++) {
       ::TPolygon& aPolygon = aPolygons[aPolygonId];
       if(DEBUG_TRIA_EXECUTE) cout << "PoilygonId="<<aPolygonId<<" | ";
       TConnectivities& aConnectivities = aPolygon.myConnectivities;
       if(DEBUG_TRIA_EXECUTE) {
-        for(int i=0;i<aConnectivities.size();i++)
+        for(size_t i=0;i<aConnectivities.size();i++)
           cout << aConnectivities[i] << ",";
         cout << endl;
       }
-      int aNbPoints = aConnectivities.size();
+      int aNbPoints = (int)aConnectivities.size();
       vtkIdType aNewCellId = theOutput->InsertNextCell(VTK_POLYGON,aNbPoints,&aConnectivities[0]);
       if(theStoreMapping)
         VTKViewer_GeometryFilter::InsertId( theCellId, VTK_POLYGON, theVTK2ObjIds, theDimension2VTK2ObjIds );
@@ -634,7 +636,7 @@ VTKViewer_OrderedTriangulator
     zSize = aBounds[5] - aBounds[4];
     double anAbsoluteCoord[3];
     double aParamentrucCoord[3];
-    for (int aPntId = 0; aPntId < aNumPts; aPntId++) {
+    for (auto aPntId = 0; aPntId < aNumPts; aPntId++) {
       myPoints->GetPoint(aPntId, anAbsoluteCoord);
       aParamentrucCoord[0] = xSize==0. ? 0. : ((anAbsoluteCoord[0] - aBounds[0]) / xSize);
       aParamentrucCoord[1] = ySize==0. ? 0. : ((anAbsoluteCoord[1] - aBounds[2]) / ySize);
@@ -668,7 +670,7 @@ VTKViewer_OrderedTriangulator
   if ( theFaceId < 0 || theFaceId >= aNumCells ) 
     return NULL;
 
-  vtkIdType *aCells = myBoundaryTris->GetPointer();
+  vtkIdType *aCells = myBoundaryTris->GetData()->GetPointer(0);
 
   // Each triangle has three points plus number of points
   vtkIdType *aCellPtr = aCells + 4*theFaceId;