Passive filter take a polydata as input and create a dataset as output. More...
#include <SMESH_FaceOrientationFilter.h>

Public Member Functions | |
| vtkTypeRevisionMacro (SMESH_FaceOrientationFilter, vtkPolyDataAlgorithm) | |
| void | SetOrientationScale (vtkFloatingPointType) |
| vtkFloatingPointType | GetOrientationScale () const |
| void | Set3dVectors (bool) |
| bool | Get3dVectors () const |
Static Public Member Functions | |
| static SMESH_FaceOrientationFilter * | New () |
| Create a new SMESH_FaceOrientationFilter. | |
Protected Member Functions | |
| SMESH_FaceOrientationFilter () | |
| virtual | ~SMESH_FaceOrientationFilter () |
| virtual int | RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) |
| Execute method. | |
| virtual int | FillInputPortInformation (int port, vtkInformation *info) |
| vtkPolyData * | CreateArrowPolyData () |
Private Member Functions | |
| SMESH_FaceOrientationFilter (const SMESH_FaceOrientationFilter &) | |
| Not implemented. | |
| void | operator= (const SMESH_FaceOrientationFilter &) |
| Not implemented. | |
Private Attributes | |
| bool | my3dVectors |
| vtkFloatingPointType | myOrientationScale |
| vtkPolyData * | myArrowPolyData |
| vtkPolyData * | myFacePolyData |
| VTKViewer_CellCenters * | myFaceCenters |
| vtkMaskPoints * | myFaceMaskPoints |
| vtkGlyphSource2D * | myGlyphSource |
| vtkGlyph3D * | myBaseGlyph |
Passive filter take a polydata as input and create a dataset as output.
Definition at line 33 of file SMESH_FaceOrientationFilter.h.
| SMESH_FaceOrientationFilter::SMESH_FaceOrientationFilter | ( | ) | [protected] |
Definition at line 53 of file SMESH_FaceOrientationFilter.cxx.
References CreateArrowPolyData(), my3dVectors, myArrowPolyData, myBaseGlyph, myFaceCenters, myFaceMaskPoints, myFacePolyData, myGlyphSource, myOrientationScale, and New().
{
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
myOrientationScale = mgr->doubleValue( "SMESH", "orientation_scale", 0.1 );
my3dVectors = mgr->booleanValue( "SMESH", "orientation_3d_vectors", false );
myArrowPolyData = CreateArrowPolyData();
myFacePolyData = vtkPolyData::New();
myFaceCenters = VTKViewer_CellCenters::New();
myFaceCenters->SetInput(myFacePolyData);
myFaceMaskPoints = vtkMaskPoints::New();
myFaceMaskPoints->SetInput(myFaceCenters->GetOutput());
myFaceMaskPoints->SetOnRatio(1);
myGlyphSource = vtkGlyphSource2D::New();
myGlyphSource->SetGlyphTypeToThickArrow();
myGlyphSource->SetFilled(0);
myGlyphSource->SetCenter(0.5, 0.0, 0.0);
myBaseGlyph = vtkGlyph3D::New();
myBaseGlyph->SetInput(myFaceMaskPoints->GetOutput());
myBaseGlyph->SetVectorModeToUseVector();
myBaseGlyph->SetScaleModeToDataScalingOff();
myBaseGlyph->SetColorModeToColorByScalar();
myBaseGlyph->SetSource(my3dVectors ? myArrowPolyData : myGlyphSource->GetOutput());
}
| SMESH_FaceOrientationFilter::~SMESH_FaceOrientationFilter | ( | ) | [protected, virtual] |
Definition at line 83 of file SMESH_FaceOrientationFilter.cxx.
References myArrowPolyData, myBaseGlyph, myFaceCenters, myFaceMaskPoints, myFacePolyData, and myGlyphSource.
{
myArrowPolyData->Delete();
myFacePolyData->Delete();
myFaceCenters->Delete();
myFaceMaskPoints->Delete();
myGlyphSource->Delete();
myBaseGlyph->Delete();
}
| SMESH_FaceOrientationFilter.SMESH_FaceOrientationFilter | ( | const SMESH_FaceOrientationFilter & | ) | [private] |
Not implemented.
| vtkPolyData * SMESH_FaceOrientationFilter::CreateArrowPolyData | ( | ) | [protected] |
Definition at line 106 of file SMESH_FaceOrientationFilter.cxx.
References SMESH_demo_hexa2_upd.angle, New(), SMESH_fixation.p0, PAL_MESH_041_mesh.p1, PAL_MESH_041_mesh.p2, PI, SMESH_test.r1, and SMESH_test.r2.
Referenced by SMESH_FaceOrientationFilter().
{
vtkPoints* points = vtkPoints::New();
vtkCellArray* polys = vtkCellArray::New();
float l1 = 0.8;
float l2 = 1.0;
int n = 16;
float r1 = 0.04;
float r2 = 0.08;
float angle = 2. * PI / n;
float p[3];
vtkIdType c3[3];
vtkIdType c4[4];
float p0[3] = { 0.0, 0.0, 0.0 };
float p1[3] = { l1, 0.0, 0.0 };
float p2[3] = { l2, 0.0, 0.0 };
points->InsertPoint( 0, p0 );
points->InsertPoint( 1, p1 );
points->InsertPoint( 2, p2 );
// shaft
for( int i = 0; i < n; i++ )
{
p[0] = 0;
p[1] = r1 * sin( i * angle );
p[2] = r1 * cos( i * angle );
points->InsertPoint( i + 3, p );
p[0] = l1;
points->InsertPoint( i + 3 + n, p );
}
// insert the last cells outside a loop
{
c3[0] = 0;
c3[1] = 3;
c3[2] = 3 + n - 1;
polys->InsertNextCell( 3, c3 );
c4[0] = 3;
c4[1] = 3 + n - 1;
c4[2] = 3 + 2 * n - 1;
c4[3] = 3 + n;
polys->InsertNextCell( 4, c4 );
}
for( int i = 0; i < n - 1; i++ )
{
c3[0] = 0;
c3[1] = i + 3;
c3[2] = i + 4;
polys->InsertNextCell( 3, c3 );
c4[0] = i + 3;
c4[1] = i + 4;
c4[2] = i + 4 + n;
c4[3] = i + 3 + n;
polys->InsertNextCell( 4, c4 );
}
// cone
for( int i = 0; i < n; i++ )
{
p[0] = l1;
p[1] = r2 * sin( i * angle );
p[2] = r2 * cos( i * angle );
points->InsertPoint( i + 3 + 2 * n, p );
}
// insert the last cells outside a loop
{
c3[0] = 1;
c3[1] = 3 + 2 * n;
c3[2] = 3 + 2 * n + n - 1;
polys->InsertNextCell( 3, c3 );
c3[0] = 2;
polys->InsertNextCell( 3, c3 );
}
for( int i = 0; i < n - 1; i++ )
{
c3[0] = 1;
c3[1] = 3 + i + 2 * n;
c3[2] = 3 + i + 2 * n + 1;
polys->InsertNextCell( 3, c3 );
c3[0] = 2;
polys->InsertNextCell( 3, c3 );
}
vtkPolyData* aPolyData = vtkPolyData::New();
aPolyData->SetPoints(points);
points->Delete();
aPolyData->SetPolys(polys);
polys->Delete();
return aPolyData;
}
| int SMESH_FaceOrientationFilter::FillInputPortInformation | ( | int | port, |
| vtkInformation * | info | ||
| ) | [protected, virtual] |
Definition at line 318 of file SMESH_FaceOrientationFilter.cxx.
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
return 1;
}
| bool SMESH_FaceOrientationFilter.Get3dVectors | ( | ) | const |
Definition at line 45 of file SMESH_FaceOrientationFilter.h.
{ return my3dVectors; }
| vtkFloatingPointType SMESH_FaceOrientationFilter.GetOrientationScale | ( | ) | const |
Definition at line 42 of file SMESH_FaceOrientationFilter.h.
{ return myOrientationScale; }
| static SMESH_FaceOrientationFilter* SMESH_FaceOrientationFilter.New | ( | ) | [static] |
| void SMESH_FaceOrientationFilter.operator= | ( | const SMESH_FaceOrientationFilter & | ) | [private] |
Not implemented.
| int SMESH_FaceOrientationFilter::RequestData | ( | vtkInformation * | request, |
| vtkInformationVector ** | inputVector, | ||
| vtkInformationVector * | outputVector | ||
| ) | [protected, virtual] |
Execute method.
Output calculation.
Definition at line 231 of file SMESH_FaceOrientationFilter.cxx.
References GetFaceParams(), myBaseGlyph, myFacePolyData, myOrientationScale, and New().
{
// get the info objects
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the input and ouptut
vtkDataSet *input = vtkDataSet::SafeDownCast(
inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkPolyData *output = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
myFacePolyData->Initialize();
myFacePolyData->ShallowCopy(input);
vtkCellArray* aFaces = vtkCellArray::New();
vtkFloatArray* aVectors = vtkFloatArray::New();
aVectors->SetNumberOfComponents(3);
int anAllFaces = 0;
double anAverageSize = 0;
vtkIdList* aNeighborIds = vtkIdList::New();
for(int aCellId = 0, aNbCells = input->GetNumberOfCells(); aCellId < aNbCells; aCellId++)
{
vtkCell* aCell = input->GetCell(aCellId);
if( aCell->GetNumberOfFaces() == 0 && aCell->GetNumberOfPoints() > 2 ) // cell is a face
{
double aSize, aNormal[3];
GetFaceParams( aCell, aNormal, aSize );
aFaces->InsertNextCell(aCell);
aVectors->InsertNextTuple(aNormal);
anAllFaces++;
anAverageSize += aSize;
continue;
}
for(int aFaceId = 0, aNbFaces = aCell->GetNumberOfFaces(); aFaceId < aNbFaces; aFaceId++)
{
vtkCell* aFace = aCell->GetFace(aFaceId);
input->GetCellNeighbors( aCellId, aFace->PointIds, aNeighborIds );
if( aNeighborIds->GetNumberOfIds() > 0 )
continue;
double aSize, aNormal[3];
GetFaceParams( aFace, aNormal, aSize );
aFaces->InsertNextCell(aFace->GetPointIds());
aVectors->InsertNextTuple(aNormal);
anAllFaces++;
anAverageSize += aSize;
}
}
aNeighborIds->Delete();
myFacePolyData->SetPolys(aFaces);
aFaces->Delete();
myFacePolyData->GetCellData()->SetScalars(0);
myFacePolyData->GetCellData()->SetVectors(aVectors);
aVectors->Delete();
if( anAllFaces == 0 )
return 0;
anAverageSize /= anAllFaces;
anAverageSize *= myOrientationScale;
myBaseGlyph->SetScaleFactor( anAverageSize );
myBaseGlyph->Update();
output->ShallowCopy( myBaseGlyph->GetOutput() );
return 1;
}
| void SMESH_FaceOrientationFilter::Set3dVectors | ( | bool | theState | ) |
Definition at line 99 of file SMESH_FaceOrientationFilter.cxx.
References my3dVectors, myArrowPolyData, myBaseGlyph, and myGlyphSource.
{
my3dVectors = theState;
myBaseGlyph->SetSource(my3dVectors ? myArrowPolyData : myGlyphSource->GetOutput());
Modified();
}
| void SMESH_FaceOrientationFilter::SetOrientationScale | ( | vtkFloatingPointType | theScale | ) |
Definition at line 93 of file SMESH_FaceOrientationFilter.cxx.
References myOrientationScale.
{
myOrientationScale = theScale;
Modified();
}
| SMESH_FaceOrientationFilter.vtkTypeRevisionMacro | ( | SMESH_FaceOrientationFilter | , |
| vtkPolyDataAlgorithm | |||
| ) |
bool SMESH_FaceOrientationFilter.my3dVectors [private] |
Definition at line 63 of file SMESH_FaceOrientationFilter.h.
Referenced by Set3dVectors(), and SMESH_FaceOrientationFilter().
vtkPolyData* SMESH_FaceOrientationFilter.myArrowPolyData [private] |
Definition at line 65 of file SMESH_FaceOrientationFilter.h.
Referenced by Set3dVectors(), SMESH_FaceOrientationFilter(), and ~SMESH_FaceOrientationFilter().
vtkGlyph3D* SMESH_FaceOrientationFilter.myBaseGlyph [private] |
Definition at line 70 of file SMESH_FaceOrientationFilter.h.
Referenced by RequestData(), Set3dVectors(), SMESH_FaceOrientationFilter(), and ~SMESH_FaceOrientationFilter().
VTKViewer_CellCenters* SMESH_FaceOrientationFilter.myFaceCenters [private] |
Definition at line 67 of file SMESH_FaceOrientationFilter.h.
Referenced by SMESH_FaceOrientationFilter(), and ~SMESH_FaceOrientationFilter().
vtkMaskPoints* SMESH_FaceOrientationFilter.myFaceMaskPoints [private] |
Definition at line 68 of file SMESH_FaceOrientationFilter.h.
Referenced by SMESH_FaceOrientationFilter(), and ~SMESH_FaceOrientationFilter().
vtkPolyData* SMESH_FaceOrientationFilter.myFacePolyData [private] |
Definition at line 66 of file SMESH_FaceOrientationFilter.h.
Referenced by RequestData(), SMESH_FaceOrientationFilter(), and ~SMESH_FaceOrientationFilter().
vtkGlyphSource2D* SMESH_FaceOrientationFilter.myGlyphSource [private] |
Definition at line 69 of file SMESH_FaceOrientationFilter.h.
Referenced by Set3dVectors(), SMESH_FaceOrientationFilter(), and ~SMESH_FaceOrientationFilter().
vtkFloatingPointType SMESH_FaceOrientationFilter.myOrientationScale [private] |
Definition at line 64 of file SMESH_FaceOrientationFilter.h.
Referenced by RequestData(), SetOrientationScale(), and SMESH_FaceOrientationFilter().