#include "vtkwtIsobaric.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" #include "vtkStructuredGridAlgorithm.h" #include "vtkStructuredGrid.h" #include "vtkCompositeDataSet.h" // vtk include files needed for this plugin #include "vtkPVContourFilter.h" #include "vtkArrowSource.h" #include "vtkLookupTable.h" #include "vtkPVGlyphFilter.h" #include "vtkInformationStringKey.h" #include "vtkPolyData.h" #include "vtkPointData.h" #include "vtkFloatArray.h" #include "vtkSMObject.h" #include "vtkSMProxyManager.h" #include "vtkSMProxy.h" #include "vtkSMProperty.h" #include "vtkSMDoubleVectorProperty.h" #include "pqView.h" #include "pqActiveObjects.h" vtkCxxRevisionMacro(vtkwtIsobaric, "$Revision: 1.0 $"); vtkStandardNewMacro(vtkwtIsobaric); vtkwtIsobaric::vtkwtIsobaric() { this->SetNumberOfInputPorts(1); this->SetNumberOfOutputPorts(3); } vtkwtIsobaric::~vtkwtIsobaric() { } int vtkwtIsobaric::FillInputPortInformation(int port, vtkInformation *info) { // modified to accept only vtkStructuredGrid info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkStructuredGrid"); return 1; } int vtkwtIsobaric::FillOutputPortInformation(int port, vtkInformation *info) { // modified to indicate that only produce vtkPolyData, such as isovalue surfaces, wind glyphs, etc. info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkPolyData"); return 1; } int vtkwtIsobaric::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { vtkSMObject *SMObj = vtkSMObject::New(); vtkSMProxyManager *SMPxyMgr; vtkSMProxy *SMProxy; vtkSMProperty *SMProperty,*SMProperty2; SMPxyMgr = SMObj->GetProxyManager(); // there is one vtkSMProxyManager for an instance of ParaView, it is a static object (a singleton) // get the input and output information vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); vtkInformation *outInfo0 = outputVector->GetInformationObject(0); vtkInformation *outInfo1 = outputVector->GetInformationObject(1); vtkInformation *outInfo2 = outputVector->GetInformationObject(2); vtkStructuredGrid *input = vtkStructuredGrid::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData *output0 = vtkPolyData::SafeDownCast( outInfo0->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData *output1 = vtkPolyData::SafeDownCast( outInfo1->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData *output2 = vtkPolyData::SafeDownCast( outInfo2->Get(vtkDataObject::DATA_OBJECT())); if (!input) { vtkErrorMacro( "empty input" ); return 0; } // Pressure contour through 3D volume vtkContourFilter *pressLevel = vtkContourFilter::New(); pressLevel->SetInput( input ); pressLevel->ComputeNormalsOn(); pressLevel->SetInputArrayToProcess( 0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, "Pressure" ); pressLevel->SetInputArrayToProcess( 1,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, "Wind" ); //pressLevel->SetInputArrayToProcess( 2,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataSetAttributes::NORMALS); //pressLevel->SetInputArrayToProcess( 3,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, "Temperature"); pressLevel->SetValue(0, pressureLevel ); pressLevel->Update(); SMProxy = SMPxyMgr->GetProxy( "wtIsobaric" ); pqActiveObjects *pqA; pqView *theView = pqA->activeView(); vtkSMProxy *viewProxy; //viewProxy = theView->getProxy(); // is this the view proxy? char *cmd, *cmd2; if ( SMProxy != 0 ) { SMProperty = SMProxy->GetProperty("pressureLevel"); vtkSMDoubleVectorProperty *prop = 0; prop = vtkSMDoubleVectorProperty::SafeDownCast( SMProxy->GetProperty("pressureLevel") ); double temp = prop->GetElement(0); cmd = SMProperty->GetCommand(); SMProperty2 = SMProxy->GetProperty("numberMaxPoints"); cmd2 = SMProperty2->GetCommand(); } int numProxies = SMPxyMgr->GetNumberOfProxies("sources"); char msg[128]; sprintf(msg,"SMPxyMgr %x SMProxy %x Number of proxies %d", SMPxyMgr, SMProxy, numProxies); vtkErrorMacro( <GetOutput()->GetPointData(); vtkFloatArray *heights = static_cast (pd->GetAbstractArray( "Height" )); double range[2]; heights->GetRange( range ); if ( output0 == 0 ) { vtkErrorMacro( <<"output pointer is NULL!"); return 1; } output0->ShallowCopy( pressLevel->GetOutput() ); //output0->SetActiveAttributeInfo( outInfo0, vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataObject::POINT, "Pressure surface", 0, //contour1d->GetOutput()->GetCellData()->GetScalars()->GetRange()); const int numContours = 15; // Contour within pressure slice within volume vtkPVContourFilter *rings = vtkPVContourFilter::New(); rings->SetInput( pressLevel->GetOutput() ); rings->SetInputArrayToProcess( 0,0,0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Height" ); rings->ComputeNormalsOn(); rings->SetNumberOfContours( numContours ); double htDelta; htDelta = (range[1] - range[0]) / (numContours-1); for ( int i=0; iSetValue( i, range[0] + i * htDelta ); } rings->Update(); if ( output1 == 0 ) { vtkErrorMacro( <<"output pointer is NULL!"); return 1; } output1->ShallowCopy( rings->GetOutput() ); // arrows for wind glyphs on this level vtkArrowSource *arrows = vtkArrowSource::New(); vtkPVGlyphFilter * windGlyphs = vtkPVGlyphFilter::New(); windGlyphs->SetInput( pressLevel->GetOutput() ); windGlyphs->SetSourceConnection( arrows->GetOutputPort() ); // active point scalars windGlyphs->SetInputArrayToProcess( 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Temperature" ); // active point vectors windGlyphs->SetInputArrayToProcess( 1, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Wind" ); windGlyphs->ScalingOn(); windGlyphs->SetScaleFactor( 0.15 ); windGlyphs->SetMaximumNumberOfPoints( numberMaxPoints ); windGlyphs->SetRandomMode( 1 ); windGlyphs->OrientOn(); windGlyphs->SetVectorModeToUseVector(); windGlyphs->SetColorModeToColorByVector(); windGlyphs->SetScaleModeToScaleByVector(); windGlyphs->Update(); output2->ShallowCopy( windGlyphs->GetOutput() ); return 1; } int vtkwtIsobaric::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { return 1; } void vtkwtIsobaric::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); }