Back to index

salome-gui  6.5.0
Classes | Typedefs | Functions
VTKViewer_ArcBuilder.h File Reference
#include "VTKViewer.h"
#include <list>
#include <map>
#include <vector>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  XYZ
 Class for represenation coordinates X,Y,Z. More...
class  Pnt
 Class for the representation point in the 3D space. More...
class  Vec
 Class for the representation Vector in the 3D space. More...
class  Plane
 Class for the representation plane in the 3D. More...
class  VTKViewer_ArcBuilder

Typedefs

typedef std::list< PntPntList

Functions

vtkIdType MergevtkPoints (const std::vector< vtkPoints * > &theCollection, const std::vector< std::vector< double > > &theScalarCollection, vtkPoints *thePoints, std::map< int, double > &thePntId2ScalarValue, vtkIdType *&theIds)
 Add all points from the input vector theCollection into thePoints.
vtkIdType Build1DArc (vtkIdType cellId, vtkUnstructuredGrid *input, vtkPolyData *output, vtkIdType *pts, vtkFloatingPointType myMaxArcAngle)
Pnt CreatePnt (vtkCell *cell, vtkDataArray *scalars, vtkIdType index)

Typedef Documentation

typedef std::list<Pnt> PntList

Definition at line 34 of file VTKViewer_ArcBuilder.h.


Function Documentation

vtkIdType Build1DArc ( vtkIdType  cellId,
vtkUnstructuredGrid *  input,
vtkPolyData *  output,
vtkIdType *  pts,
vtkFloatingPointType  myMaxArcAngle 
)

Definition at line 591 of file VTKViewer_ArcBuilder.cxx.

                                                        {
  
  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
  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) {
    return aResult;
  }
  else{
    vtkPoints* aPoints = aBuilder.GetPoints();
    std::vector<double> aScalarValues = aBuilder.GetScalarValues();
    vtkIdType aNbPts = aPoints->GetNumberOfPoints();
    aNewPoints = new vtkIdType[aNbPts];
    vtkIdType curID;
    vtkIdType aCellType = VTK_POLY_LINE;
    
    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];
    
    aResult = output->InsertNextCell(aCellType,aNbPts,aNewPoints);
    return aResult;
  } 
}

Here is the call graph for this function:

Pnt CreatePnt ( vtkCell *  cell,
vtkDataArray *  scalars,
vtkIdType  index 
)

Definition at line 580 of file VTKViewer_ArcBuilder.cxx.

{
  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;
}

Here is the caller graph for this function:

vtkIdType MergevtkPoints ( const std::vector< vtkPoints * > &  theCollection,
const std::vector< std::vector< double > > &  theScalarCollection,
vtkPoints *  thePoints,
std::map< int, double > &  thePntId2ScalarValue,
vtkIdType *&  theIds 
)

Add all points from the input vector theCollection into thePoints.

Array theIds - it is array with ids of added points.

Definition at line 637 of file VTKViewer_ArcBuilder.cxx.

                                            {
  vtkIdType aNbPoints = 0;
  vtkIdType anIdCounter = 0;
  vtkIdType aNewPntId = 0;
  
  //Compute number of points
  std::vector<vtkPoints*>::const_iterator it = theCollection.begin();
  for(;it != theCollection.end();it++){
    vtkPoints* aPoints = *it;
    if(aPoints) { 
      aNbPoints += aPoints->GetNumberOfPoints()-1; //Because we add all points except last
    }
  }
  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() && 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++;
      }
    }
  }
  return aNbPoints;
}