Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

set (VTK_CONTRIB_MAJOR_VERSION "5")
set (VTK_CONTRIB_MINOR_VERSION "11")
set (VTK_CONTRIB_MINOR_VERSION "12")
set (VTK_CONTRIB_RELEASE_VERSION "0")
set (VTK_CONTRIB_VERSION ${VTK_CONTRIB_MAJOR_VERSION}.${VTK_CONTRIB_MINOR_VERSION}.${VTK_CONTRIB_RELEASE_VERSION})

Expand Down
3 changes: 3 additions & 0 deletions src/VtkContrib/public/VtkContrib/vtkFrustumWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef VTK_FRUSTUM_WIDGET_H
#define VTK_FRUSTUM_WIDGET_H

#include "VtkContrib/vtkPolygonFilter.h"

#include <vtkActor.h>
#include <vtk3DWidget.h>
#include <vtkActor.h>
Expand Down Expand Up @@ -212,6 +214,7 @@ class vtkFrustumWidget : public vtk3DWidget

/** Le tronc et sa représentation. */
vtkSmartPointer<vtkFrustumSource> _frustum;
vtkSmartPointer<vtkPolygonFilter> _polygonFilter;
vtkSmartPointer<vtkPlanes> _planes;
vtkSmartPointer<vtkPolyDataMapper> _frustumMapper;
vtkSmartPointer<vtkActor> _frustumActor;
Expand Down
59 changes: 59 additions & 0 deletions src/VtkContrib/public/VtkContrib/vtkPolygonFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef VTK_POLYGON_FILTER_H
#define VTK_POLYGON_FILTER_H


#include <vtkPolyDataAlgorithm.h>
#include <vtkIndent.h>
#include <vtkCell.h>
#include <iostream>


/** <P>Filtre permettant d'extraire les polygones d'une instance de vtkPolyData.
* </P>
* @author Charles PIGNEROL, CEA/DAM/DCLC
*/
class vtkPolygonFilter : public vtkPolyDataAlgorithm
{
public :

/** Destructeur : RAS
*/
virtual ~vtkPolygonFilter ( );

/** Instanciation de cette classe.
*/
static vtkPolygonFilter* New ( );

vtkTypeMacro(vtkPolygonFilter,vtkPolyDataAlgorithm);

/**
* Affiche quelques infos sur l'instance.
* @param flux d'impression
* @param indentation utilisée
*/
virtual void PrintSelf (ostream& os, vtkIndent indent);

/**
* Effectue l'extraction.
*/
virtual int RequestData (vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector);


protected :

/** Constructeur.
*/
vtkPolygonFilter ( );


private :

/** Constructeur de copie : interdit. */
vtkPolygonFilter (const vtkPolygonFilter&);

/** Opérateur = : interdit. */
vtkPolygonFilter& operator = (const vtkPolygonFilter&);
}; // class vtkPolygonFilter


#endif // VTK_POLYGON_FILTER_H
13 changes: 12 additions & 1 deletion src/VtkContrib/vtkFrustumWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ vtkFrustumWidget::vtkFrustumWidget ( )
: vtk3DWidget ( ), _parallelPlanes ( )
{
_frustum = vtkSmartPointer<vtkFrustumSource>::Take (vtkFrustumSource::New ( ));
_polygonFilter = vtkSmartPointer<vtkPolygonFilter>::Take (vtkPolygonFilter::New ( ));
_polygonFilter->SetInputData (_frustum->GetOutput ( ));
_planes = vtkSmartPointer<vtkPlanes>::Take (vtkPlanes::New ( ));
_frustumMapper = vtkSmartPointer<vtkPolyDataMapper>::Take (vtkPolyDataMapper::New ( ));
_frustumActor = vtkSmartPointer<vtkActor>::Take (vtkActor::New ( ));
_frustumMapper->SetInputConnection (_frustum->GetOutputPort ( ));
_frustumMapper->SetInputData (_polygonFilter->GetOutput ( ));
_frustumActor->SetMapper (_frustumMapper);
_contourFilter = vtkSmartPointer<vtkTubeFilter>::Take (vtkTubeFilter::New ( ));
_contourMapper = vtkSmartPointer<vtkPolyDataMapper>::Take (vtkPolyDataMapper::New ( ));
Expand Down Expand Up @@ -312,6 +314,12 @@ void vtkFrustumWidget::SetEnabled (int enabled)
{
if (true == enabled)
{
_polygonFilter->Update ( );
double bounds [6] = { 0., 0., 0., 0., 0., 0. };
GetBounds (bounds);
const double radius = sqrt ((bounds [1] - bounds [0])*(bounds [1] - bounds [0]) + (bounds [3] - bounds [2])*(bounds [3] - bounds [2]) + (bounds [5] - bounds [4])*(bounds [5] - bounds [4])) / 200.;
_contourFilter->SetRadius (radius); // 5.12.0
_contourFilter->Update ( );
GetCurrentRenderer ( )->AddActor (_frustumActor);
GetCurrentRenderer ( )->AddActor (_contourActor);
}
Expand Down Expand Up @@ -490,6 +498,7 @@ void vtkFrustumWidget::GetBounds (double bounds [6])
else
{
// frustum->GetBounds (bounds);
// CP : le commentaire ci-après n'est peut être plus vrai depuis l'utilisation de vtkPolygonFilter (v 5.12.0).
/* On n'utilise pas frustum->GetBounds (bounds) car notre polydata contient des lignes qui parfois, de manière non reproductible,
* sortent carrément du domaine observé, à savoir qu'une composante d'une coordonnée peut être de l'ordre de 10E+30 ! Parfois veut ici
* dire environ 1 fois sur 15, et c'est semble-t-il toujours au premier appel de cette fonction. Problème d'initialisation d'une
Expand Down Expand Up @@ -638,6 +647,7 @@ void vtkFrustumWidget::CreateDefaultRepresentation ( )
_planes->SetNormals (normals);
_frustum->SetPlanes (_planes);
_frustum->Update ( );
_polygonFilter->Update ( );
// On confère à ce widget le look de la classe vtkImplicitPlaneWidget :
_frustumActor->SetProperty (_planeWidgets [0]->GetPlaneProperty ( ));
} // vtkFrustumWidget::CreateDefaultRepresentation
Expand Down Expand Up @@ -692,6 +702,7 @@ void vtkFrustumWidget::Update (vtkFrustumWidget::vtkInternalPlaneWidget* planeWi
_frustum->SetPlanes (_planes);
_frustum->Modified ( );
_frustum->Update ( );
_polygonFilter->Update ( );

// Recentrer les manipulateurs sur leur face :
vtkPolyData* frustum = _frustum->GetOutput ( );
Expand Down
90 changes: 90 additions & 0 deletions src/VtkContrib/vtkPolygonFilter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include "VtkContrib/vtkPolygonFilter.h"

#include <vtkDataSet.h>
#include <vtkCellData.h>
#include <vtkPointData.h>
#include <assert.h>

#include <algorithm>
#include <list>
using namespace std;


vtkPolygonFilter::vtkPolygonFilter ( )
: vtkPolyDataAlgorithm ( )
{
} // vtkPolygonFilter::vtkPolygonFilter


vtkPolygonFilter::vtkPolygonFilter (const vtkPolygonFilter&)
: vtkPolyDataAlgorithm ( )
{
assert (0 && "vtkPolygonFilter copy constructor is not allowed.");
} // vtkPolygonFilter::vtkPolygonFilter


vtkPolygonFilter& vtkPolygonFilter::operator = (const vtkPolygonFilter&)
{
assert (0 && "vtkPolygonFilter operator = is not allowed.");
return *this;
} // vtkPolygonFilter::operator =


vtkPolygonFilter::~vtkPolygonFilter ( )
{
} // vtkPolygonFilter::~vtkPolygonFilter


vtkPolygonFilter* vtkPolygonFilter::New ( )
{
return new vtkPolygonFilter ( );
} // vtkPolygonFilter::New


void vtkPolygonFilter::PrintSelf (ostream& os, vtkIndent indent)
{
Superclass::PrintSelf(os,indent);
} // vtkPolygonFilter::PrintSelf


#define RD_SUCCESS 1
#define RD_FAILURE 0
int vtkPolygonFilter::RequestData (vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
vtkPolyData* input = GetPolyDataInput (0);
vtkPolyData* output = GetOutput ( );
vtkPoints* pointSet = 0 == input ? 0 : input->GetPoints ( );
vtkCellArray* cells = 0 == input ? 0 : input->GetPolys ( );
if (0 == output)
{
vtkErrorMacro(<<"vtkPolygonFilter::Execute : filter does not have any output.");
return RD_FAILURE;
} // if (0 == output)
if ((0 == input) || (0 == pointSet) || (0 == cells))
{
vtkErrorMacro(<<"vtkPolygonFilter::Execute : filter does not have any input.");
return RD_FAILURE;
} // if (0 == input) || (0 == pointSet) || (0 == cells))
output->Reset ( );

const size_t cellNum = cells->GetNumberOfCells ( );
vtkIdType* cellsPtr = cells->GetPointer ( );
output->SetPoints (pointSet);
output->Allocate (cellNum, cellNum);
for (int i = 0; i < cellNum; i++)
{
const vtkIdType nodeCount = *cellsPtr;
cellsPtr++;
switch (nodeCount)
{
case 3 : output->InsertNextCell (VTK_TRIANGLE, nodeCount, cellsPtr); break;
case 4 : output->InsertNextCell (VTK_QUAD, nodeCount, cellsPtr); break;
} // switch (nodeCount)
cellsPtr += nodeCount;
} // for (i = 0; i < cellNum; i++)

output->GetCellData ( )->PassData (input->GetCellData ( ));
output->Squeeze ( );

return RD_SUCCESS;
} // vtkPolygonFilter::RequestData
13 changes: 13 additions & 0 deletions versions.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Version 5.12.0 : 17/10/25
================

Classe vtkPolygonFilter.

Correctifs vtkFrustumWidget :
- le rayon des tubes délimitants le contour des plans est calculé au moment de l'affichage => évite que ces
tubes soient tellement fins qu'on ne les voit pas.
- Dans certains cas à la moindre interaction (zoom/rotation) la scène disparaissait (pb probable de clipping).
Cela semblait provenir des vtkLines du vtkPolyData en sortie de vtkFrustumSource dont certaines composantes
de coordonnées pouvaient être infinies. Problème semble t-il résolu en filtrant avec la classe vtkPolygonFilter.


Version 5.11.0 : 03/10/25
================

Expand Down