Changeset 239


Ignore:
Timestamp:
06/29/11 07:22:13 (13 years ago)
Author:
hozdoba
Message:
 
Location:
XMLIO_V2/dev/dev_rv/src4/xmlio/vtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src4/xmlio/vtk/lscereader.cpp

    r236 r239  
    2727#include "inetcdf4_impl.hpp" 
    2828#include "inetcdf4_adv_impl.hpp" 
     29 
     30// BibliothÚque C++ 
     31#include <algorithm> 
    2932 
    3033// Type Fortran 
     
    609612                                            const vtkStdString & ycoordinate, 
    610613                                            const vtkStdString & zcoordinate, 
    611                                             bool bounds, bool proj, std::size_t nbvertex, 
     614                                            bool bounds, bool proj, bool clean, std::size_t nbvertex, 
    612615                                            vtkCellArray * cells, vtkPoints * points, 
    613616                                            vtkIntArray * dimensions) 
    614617      { 
    615          float value[3]; 
     618         float  value[3], range[2]; 
    616619         double h = 1.0; 
    617          double cartesianCoord[3]; 
     620         double cartesianCoord[3], vbounds[6]; 
    618621         vtkIdType pts[nbvertex] ; 
    619622         bool is2D = true; 
    620623         ARRAY_CREATE(xvalue, float, 1, [1]); 
    621624         ARRAY_CREATE(yvalue, float, 1, [1]); 
    622          vtkSmartPointer<vtkFloatArray> zspacing = vtkSmartPointer<vtkFloatArray>::New(); 
     625         vtkSmartPointer<vtkPointLocator> locator = vtkSmartPointer<vtkPointLocator>::New(); 
     626         vtkSmartPointer<vtkFloatArray> zspacing  = vtkSmartPointer<vtkFloatArray>::New(); 
     627          
    623628         if (zcoordinate.size() > 0) 
    624629         { 
     
    628633         else 
    629634            zspacing->InsertNextValue(0); 
     635          
     636         zspacing->GetValueRange (range); 
    630637 
    631638         std::size_t size = (*Reader->getDimensions(&xcoordinate).begin()).second; 
     
    634641            vtkStdString boundid = Reader->getBoundsId(xcoordinate); 
    635642            Reader->readData(*xvalue, boundid); 
     643            if (!proj) 
     644            { 
     645               vbounds[0] = *std::min_element(xvalue->begin(), xvalue->end()); 
     646               vbounds[1] = *std::max_element(xvalue->begin(), xvalue->end()); 
     647            } 
     648            else 
     649            { 
     650               vbounds[0] = -h; 
     651               vbounds[1] = h; 
     652            } 
    636653         } 
    637654         if (Reader->hasBounds(ycoordinate)) 
     
    639656            vtkStdString boundid = Reader->getBoundsId(ycoordinate); 
    640657            Reader->readData(*yvalue, boundid); 
    641          } 
    642  
     658            if (!proj) 
     659            { 
     660               vbounds[2] = *std::min_element(yvalue->begin(), yvalue->end()); 
     661               vbounds[3] = *std::max_element(yvalue->begin(), yvalue->end()); 
     662            } 
     663            else 
     664            { 
     665               vbounds[2] = -h; 
     666               vbounds[3] = h; 
     667            } 
     668         } 
     669         if (!proj) 
     670         { 
     671            vbounds[4] = range[0]; 
     672            vbounds[5] = range[1]; 
     673         } 
     674         else 
     675         { 
     676            vbounds[4] = -h; 
     677            vbounds[5] = h; 
     678         } 
     679         locator->InitPointInsertion(points, vbounds, size * zspacing->GetNumberOfTuples() * nbvertex);  
     680          
    643681         for (std::size_t u = 0; u < size; u++) 
    644682         { 
     
    660698                     cartesianCoord[1] = h * sin(value[0]) * cos(value[1]); 
    661699                     cartesianCoord[2] = h * sin(value[1]); 
    662                      points->InsertPoint (pts[w], cartesianCoord); 
     700                     if (clean) locator->InsertUniquePoint (cartesianCoord, pts[w]); 
     701                     else points->InsertPoint (pts[w], cartesianCoord); 
    663702                  } 
    664703                  else 
    665704                  { 
    666                      points->InsertPoint (pts[w], value); 
     705                     cartesianCoord[0] = value[0]; 
     706                     cartesianCoord[1] = value[1]; 
     707                     cartesianCoord[2] = value[2]; 
     708                     if (clean) locator->InsertUniquePoint (cartesianCoord, pts[w]); 
     709                     else points->InsertPoint (pts[w], cartesianCoord); 
    667710                  } 
    668711               } 
     
    780823            //std::cout << Reader->getVertCoordName(*VarNames.begin()) << std::endl; 
    781824             
    782             std::cout << Reader->getNbVertex(*VarNames.begin()) << std::endl; 
    783              
    784825            GetCellsAndPoints(Reader->getLonCoordName(*VarNames.begin()), 
    785826                              Reader->getLatCoordName(*VarNames.begin()), 
    786                               Reader->getVertCoordName(*VarNames.begin()), true, true, 
     827                              Reader->getVertCoordName(*VarNames.begin()), true, false, true, 
    787828                              Reader->getNbVertex(*VarNames.begin()), cells, pts, dims); 
    788829             
  • XMLIO_V2/dev/dev_rv/src4/xmlio/vtk/lscereader.hpp

    r236 r239  
    153153                                   const vtkStdString & ycoordinate, 
    154154                                   const vtkStdString & zcoordinate, 
    155                                    bool bounds, bool proj, std::size_t nbvertex, 
     155                                   bool bounds, bool proj, bool clean, std::size_t nbvertex, 
    156156                                   vtkCellArray * cells, vtkPoints * points, 
    157157                                   vtkIntArray * dimensions); 
Note: See TracChangeset for help on using the changeset viewer.