Hi all,
i went to render a section clipping continous fringe plot, i did implement the following methods which didn’t lead to the desired results, even though the default plane widget is not shown. here are my functions :
void CEMWPlotViewCtrl::CreateSectionClipContinuousFringe(vtkEMWPlane* plane, long sectionID, vtkEMWAppendFilter* pGridModel)
{
if (!m_pUnstructuredGridModel && !pGridModel)
return;
m_SectionActorsList[sectionID].bCreated = FALSE;
if (pGridModel == NULL)
pGridModel = m_pUnstructuredGridModel;
int iClippingListSize = m_SectionActorsList[sectionID].pActorsList.size();
int nbre = pGridModel->GetNumberOfInputConnections(0);
if (iClippingListSize > 0)
RemoveSectionClipActors(sectionID);
vtkPolyData* pPlaneWidgetPolyData = NULL;
BOOL bAddMeshOverlay = FALSE;
for (int iGrid = 0; iGrid < nbre; iGrid++)
{
vtkUnstructuredGrid* pUGrid = (vtkUnstructuredGrid*)pGridModel->GetInput(iGrid);
if (pUGrid == NULL)
continue;
vtkSmartPointer<vtkEMWClipDataSet> clipper = vtkSmartPointer<vtkEMWClipDataSet>::New();
vtkSmartPointer<vtkEMWAppendFilter> appendfilter = vtkSmartPointer<vtkEMWAppendFilter>::New();
vtkSmartPointer<vtkActor> pClipActor = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkActor> pClipMeshActor = NULL;
appendfilter->AddInputData(pUGrid);
m_SectionActorsList[sectionID].pAppendFiltersList[iGrid] = appendfilter;
clipper->SetInputConnection(appendfilter->GetOutputPort());
clipper->SetClipFunction(plane);
clipper->GenerateClipScalarsOff();
clipper->InsideOutOff();
m_SectionActorsList[sectionID].pClippersList[iGrid] = clipper;
// convert from unstructuredGrid to PolyData
vtkSmartPointer<vtkGeometryFilter> extract = vtkSmartPointer<vtkGeometryFilter>::New();
extract->SetInputConnection(clipper->GetOutputPort());
// None
vtkSmartPointer<vtkPolyDataNormals> normals = NULL;
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
InitializeDataSetMapper(mapper);
switch (m_lPlotUnCutPart)
{
case NONE:
case MESH: {
normals = vtkSmartPointer<vtkPolyDataNormals>::New(); // none
normals->SetInputData(extract->GetOutput());
vtkSmartPointer<vtkThreshold> pThreshold = vtkSmartPointer<vtkThreshold>::New();
pThreshold->SetInputConnection(normals->GetOutputPort());
m_SectionActorsList[sectionID].pThreshold->AddInputConnection(normals->GetOutputPort());
m_SectionActorsList[sectionID].pThreshold->ThresholdBetween(m_SectionActorsList[sectionID].minValue, m_SectionActorsList[sectionID].maxValue);
pThreshold->ThresholdBetween(m_AutomaticMinValue, m_AutomaticMaxValue);
mapper->SetInputConnection(pThreshold->GetOutputPort());
m_SectionActorsList[sectionID].pThreshold->AddInputConnection(pThreshold->GetOutputPort());
} break;
case MESH3D: {
// 3D mesh
vtkSmartPointer<vtkExtractEdges> edges = NULL;
edges = vtkExtractEdges::New(); // 3D mesh
edges->SetInputConnection(clipper->GetOutputPort());
ApplyThresholdFilter(edges->GetOutputPort(), sectionID);
mapper->SetInputConnection(m_SectionActorsList[sectionID].pThreshold->GetOutputPort());
pPlaneWidgetPolyData = edges->GetOutput();
} break;
default: {
} break;
}
vtkSmartPointer<vtkLookupTable> pColours = GetUpdatedPlotLookuptable();
if (pColours == NULL)
return;
PrepareDataSetMapper(mapper, pColours, m_CurrentMinValue, m_CurrentMaxValue);
if (pClipActor != NULL)
pClipActor->SetMapper(mapper);
if (pClipActor != NULL)
{
m_SectionActorsList[sectionID].pActorsList[iGrid] = pClipActor;
AddActorToViewProp(pClipActor);
}
}//for (int iGrid = 0; iGrid < nbre; ++iGrid)
pPlaneWidgetPolyData = (vtkPolyData*)m_SectionActorsList[sectionID].pThreshold->GetInput();
//Create and show plane widget
if (m_SectionActorsList[sectionID].bCreated == FALSE)
{
this->DrawSectionClippingPlaneWidget(pPlaneWidgetPolyData, sectionID, false, false, true);
vtkSmartPointer<vtkGeometryFilter> extract = vtkSmartPointer<vtkGeometryFilter>::New();
extract->SetInputConnection(m_pUnstructuredGridModel->GetOutputPort());
vtkSmartPointer<vtkDepthSortPolyData> depthSort = CreateDepthSortVTkForPolyData(extract);
vtkSmartPointer<vtkOutlineFilter> outline = vtkSmartPointer<vtkOutlineFilter>::New();
outline->SetInputConnection(depthSort->GetOutputPort());
this->DrawDefaultSectionClipPlaneWidget(outline->GetOutput(), sectionID);
}
else
{
if ((m_IsSectionClipping == FALSE) && (m_bClipping == FALSE))
{
this->DrawSectionClippingPlaneWidget(pPlaneWidgetPolyData, sectionID, true, true, true, true, true);
}
}
m_SectionActorsList[sectionID].bCreated = TRUE;
}
void CEMWPlotViewCtrl::DrawDefaultSectionClipPlaneWidget(vtkPolyData* polyData, long sectionID, bool bShow)
{
if(!m_pUnstructuredGridModel)
return;
if( m_pDefaultPlaneWidget )
return;
vtkUnstructuredGrid* pUGrid = (vtkUnstructuredGrid*)m_pUnstructuredGridModel->GetInput();
m_pDefaultPlaneWidget = vtkSmartPointer<vtkEMWImplicitPlaneWidget>::New();
m_pDefaultPlaneWidget->SetEMWGlModelViewCtrl(this);
m_pDefaultPlaneWidget->SetEdgeColoringOff();
m_pDefaultPlaneWidget->SetPlaneEdgeColor(m_dFixedSectionPlaneEdgeColorList);
m_pDefaultPlaneWidget->SetInteractor(m_piren);
m_pDefaultPlaneWidget->On();
m_pDefaultPlaneWidget->SetBounds(m_Bounds);
m_pDefaultPlaneWidget->SetCurrentRenderer(m_prenderer);
m_pDefaultPlaneWidget->SetModelDiagonal(m_Diagonal*2.0);
m_pDefaultPlaneWidget->SetInputData(polyData);
m_pDefaultPlaneWidget->MoveSectionClippingOff();
// Set up a transform to move the label to a new position.
vtkSmartPointer<vtkTransform> aLabelTransform = vtkSmartPointer<vtkTransform>::New();
aLabelTransform->Identity();
aLabelTransform->Scale( m_Diagonal*.03, m_Diagonal*.03, m_Diagonal*.03);
double normal[3];
unsigned short planeType = -1;
if(m_PlotType != VECTORPLOT )
planeType = m_SectionActorsList[sectionID].planeType;
else
planeType = m_pVectorSectionClipping.planeType;
GetFixedNormalPlane(planeType, normal);
m_pDefaultPlaneWidget->SetNormal(normal);
if(planeType == FRONTPLANE)
{
m_pDefaultPlaneWidget->NormalToZAxisOn(); // parallel to (X, Y)
m_sPlaneLabel = _T("Front Plane");
aLabelTransform->Translate(-m_Diagonal*2000, 0, 0);
}
else if(planeType == TOPPLANE)
{
m_pDefaultPlaneWidget->NormalToYAxisOn(); // parallel to (X, Z)
m_sPlaneLabel = _T("Top Plane");
aLabelTransform->Translate(-m_Diagonal*2000, 0, 0);
}
else if(planeType == RIGHTPLANE)
{
m_pDefaultPlaneWidget->NormalToXAxisOn(); // parallel to (Y, Z)
m_sPlaneLabel = _T("Right Plane");
aLabelTransform->Translate(0,-m_Diagonal*2000, 0);
}
m_pDefaultPlaneWidget->SetPlaceFactor(2);
m_pDefaultPlaneWidget->TubingOff();
m_pDefaultPlaneWidget->PlaceWidget(m_Bounds);
ShowHideSectionClipDefaultPlaneWidget(bShow);
m_pDefaultPlaneWidget->OutlineTranslationOff(); // option
m_pDefaultPlaneWidget->ScaleEnabledOff();
m_pDefaultPlaneWidget->GetPlaneProperty()->SetOpacity(0.02);
m_pDefaultPlaneWidget->GetSelectedPlaneProperty()->SetOpacity(0.02);
m_pDefaultPlaneWidget->GetOutlineProperty()->SetColor(0.0, 0.0, 0.0);
m_pDefaultPlaneWidget->RemoveLineActor1();
m_pDefaultPlaneWidget->RemoveConeActor1();
m_pDefaultPlaneWidget->RemoveLineActor2();
m_pDefaultPlaneWidget->RemoveConeActor2();
m_pDefaultPlaneWidget->RemoveOutlineActor();
m_pDefaultPlaneWidget->SetTolerance(-1);
m_pDefaultPlaneWidget->UpdatePlacement();
m_pDefaultPlaneWidget->SphereActorVisibilityOn(); // default is Off
m_pDefaultPlaneWidget->SetSphereColor(m_dFixedSectionPlaneEdgeColorList[0],m_dFixedSectionPlaneEdgeColorList[1],m_dFixedSectionPlaneEdgeColorList[2]);
// Define the text for the label
vtkSmartPointer<vtkVectorText> caseLabel = vtkSmartPointer<vtkVectorText>::New();
std::string str = CT2A( m_sPlaneLabel );
const char* file_path=str.c_str();
caseLabel->SetText(file_path);
switch(planeType)
{
case FRONTPLANE: // front plane parallel to (x,y) plane
{
aLabelTransform->RotateZ(90);
} break;
case TOPPLANE: // top plane parallel to (x,z) plane
{
aLabelTransform->RotateX(90);
aLabelTransform->RotateZ(90);
} break;
case RIGHTPLANE: // right plane parallel to (y,z) plane
{
aLabelTransform->RotateX(90);
aLabelTransform->RotateY(90);
aLabelTransform->RotateZ(90);
} break;
}
// Move the label to a new position.
vtkSmartPointer<vtkTransformPolyDataFilter> labelTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
labelTransform->SetTransform(aLabelTransform);
labelTransform->SetInputConnection( caseLabel->GetOutputPort());
// Create a mapper and actor to display the text.
vtkSmartPointer<vtkPolyDataMapper> labelMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
labelMapper->SetInputConnection(labelTransform->GetOutputPort());
m_pLabelActor = vtkSmartPointer < vtkActor>::New();
m_pLabelActor->SetMapper(labelMapper);
m_pLabelActor->SetOrientation(normal);
}
it give me the following results
where the desired results looks like this
thanks in advance for any answer, i really appreciate your help.