0019882: EDF 453 GEOM: Impossible to change the iso values in the VTK window

This commit is contained in:
dmv 2008-06-19 10:07:20 +00:00
parent 09e9d9d991
commit 5ce415581c
4 changed files with 106 additions and 67 deletions

View File

@ -470,30 +470,41 @@ void GEOMToolsGUI::OnNbIsos()
if ( selected.IsEmpty() )
return;
Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
if ( FirstIOS.IsNull() )
return;
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW )
return;
SVTK_View* aView = vtkVW->getView();
vtkActorCollection* aCollection = aView->getRenderer()->GetActors();
SALOME_View* view = GEOM_Displayer::GetActiveView();
vtkActorCollection* aCollection = vtkActorCollection::New();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject) anIObject = It.Value();
SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
if ( vtkPrs ) {
vtkActorCollection* anActors = vtkPrs->GetObjects();
anActors->InitTraversal();
vtkActor* anAct = anActors->GetNextActor();
aCollection->AddItem(anAct);
}
}
if(aCollection)
aCollection->InitTraversal();
else
return;
int UIso = 0;
int VIso = 0;
if(aCollection){
aCollection->InitTraversal();
}
vtkActor *anAct = aCollection->GetNextActor();
if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
vtkActor* anAct = aCollection->GetNextActor();
if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
anActor->GetNbIsos(UIso,VIso);
}
else
return;
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
NbIsosDlg->setU( UIso );
@ -502,14 +513,15 @@ void GEOMToolsGUI::OnNbIsos()
if ( NbIsosDlg->exec() ) {
SUIT_OverrideCursor();
while(anAct = aCollection->GetNextActor()) {
if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
while( anAct!=NULL ) {
if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
// There are no casting to needed actor.
UIso = NbIsosDlg->getU();
VIso = NbIsosDlg->getV();
int aIsos[2]={UIso,VIso};
anActor->SetNbIsos(aIsos);
}
anAct = aCollection->GetNextActor();
}
}
} // end vtkviewer

View File

@ -67,6 +67,8 @@
#include <vtkMath.h>
#include <vtkCamera.h>
#include "utilities.h"
//vtkStandardNewMacro(GEOM_Actor);
#ifndef MYDEBUG
@ -105,7 +107,7 @@ GEOM_Actor::GEOM_Actor():
{
#ifdef MYDEBUG
cout <<this<< " GEOM_Actor::GEOM_Actor"<<endl;
MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
#endif
myPolyDataMapper->SetInput(myAppendFilter->GetOutput());
@ -180,7 +182,7 @@ GEOM_Actor::GEOM_Actor():
GEOM_Actor::~GEOM_Actor()
{
#ifdef MYDEBUG
cout <<this<< " ~GEOM_Actor::GEOM_Actor"<<endl;
MESSAGE (this<< " ~GEOM_Actor::GEOM_Actor");
#endif
myHighlightProp->Delete();
myPreHighlightProp->Delete();
@ -199,7 +201,7 @@ New()
void Write(vtkPolyData* theDataSet, const char* theFileName){
vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
cout<<"Write - "<<theFileName<<"' : "<<theDataSet->GetNumberOfPoints()<<"; "<<theDataSet->GetNumberOfCells()<<endl;
MESSAGE ("Write - "<<theFileName<<"' : "<<theDataSet->GetNumberOfPoints()<<"; "<<theDataSet->GetNumberOfCells());
aWriter->SetInput(theDataSet);
aWriter->SetFileName(theFileName);
//aWriter->Write();
@ -275,7 +277,7 @@ GEOM_Actor::
setDisplayMode(int theMode)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SetDisplayMode = "<<theMode <<endl;
MESSAGE ( "GEOM_Actor::SetDisplayMode = "<<theMode );
#endif
VTKViewer_Actor::setDisplayMode(theMode);
SetVisibility(GetVisibility());
@ -286,7 +288,7 @@ GEOM_Actor::
SetSelected(bool theIsSelected)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SetSelected = "<<theIsSelected <<endl;
MESSAGE ( "GEOM_Actor::SetSelected = "<<theIsSelected );
#endif
myIsSelected = theIsSelected;
@ -298,8 +300,8 @@ GEOM_Actor::
SetVisibility(int theVisibility)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SetVisibility = "<<theVisibility <<" myIsSelected="<< myIsSelected
<< " theVisibility="<<theVisibility<<" myIsPreselected="<<myIsPreselected<<endl;
MESSAGE ( "GEOM_Actor::SetVisibility = "<<theVisibility <<" myIsSelected="<< myIsSelected
<< " theVisibility="<<theVisibility<<" myIsPreselected="<<myIsPreselected );
#endif
SALOME_Actor::SetVisibility(theVisibility);
@ -313,7 +315,8 @@ SetVisibility(int theVisibility)
myOneFaceEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected);
myVertexActor->SetVisibility(false);// must be added new mode points
// myVertexActor->SetVisibility(false);// must be added new mode points
myVertexActor->SetVisibility(theVisibility);
}
@ -321,16 +324,14 @@ void
GEOM_Actor
::SetNbIsos(const int theNb[2])
{
myNbIsos[0] = theNb[0];
myNbIsos[1] = theNb[1];
myWireframeFaceSource->SetNbIso(theNb);
}
void
GEOM_Actor
::GetNbIsos(int &theNbU,int &theNbV)
{
theNbU = myNbIsos[0];
theNbV = myNbIsos[1];
myWireframeFaceSource->GetNbIso(theNbU, theNbV);
}
static
@ -465,7 +466,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
// OLD METHODS
void GEOM_Actor::setDeflection(double adef) {
#ifdef MYDEBUG
cout << "GEOM_Actor::setDeflection"<<endl;
MESSAGE ( "GEOM_Actor::setDeflection" );
#endif
SetDeflection((float)adef,GetIsRelative());
}
@ -479,7 +480,7 @@ void GEOM_Actor::setDeflection(double adef) {
void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SetHighlightProperty"<<endl;
MESSAGE ( "GEOM_Actor::SetHighlightProperty" );
#endif
this->myHighlightActor->GetProperty()->DeepCopy(Prop);
@ -488,7 +489,7 @@ void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop)
void GEOM_Actor::SetWireframeProperty(vtkProperty* Prop)
{
#ifdef MYDEBUG
cout << this << " GEOM_Actor::SetWireframeProperty"<<endl;
MESSAGE ( this << " GEOM_Actor::SetWireframeProperty" );
#endif
// must be filled
myWireframeFaceActor->SetProperty(Prop);
@ -497,7 +498,7 @@ void GEOM_Actor::SetWireframeProperty(vtkProperty* Prop)
void GEOM_Actor::SetShadingProperty(vtkProperty* Prop)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SetShadingProperty"<<endl;
MESSAGE ( "GEOM_Actor::SetShadingProperty" );
#endif
myShadingFaceProp->DeepCopy(Prop);
}
@ -506,7 +507,7 @@ void GEOM_Actor::SetShadingProperty(vtkProperty* Prop)
void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::Render"<<endl;
MESSAGE ( "GEOM_Actor::Render" );
#endif
if(!GetVisibility())
@ -578,7 +579,7 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
void GEOM_Actor::ReleaseGraphicsResources(vtkWindow *)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::ReleaseGraphicsResources"<<endl;
MESSAGE ( "GEOM_Actor::ReleaseGraphicsResources" );
#endif
}
@ -587,7 +588,7 @@ void GEOM_Actor::ReleaseGraphicsResources(vtkWindow *)
void GEOM_Actor::ShallowCopy(vtkProp *prop)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::ShallowCopy"<<endl;
MESSAGE ( "GEOM_Actor::ShallowCopy" );
#endif
GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
if ( f != NULL )
@ -601,7 +602,7 @@ void GEOM_Actor::ShallowCopy(vtkProp *prop)
const TopoDS_Shape& GEOM_Actor::getTopo() {
#ifdef MYDEBUG
cout << "GEOM_Actor::getTopo"<<endl;
MESSAGE ( "GEOM_Actor::getTopo" );
#endif
return myShape;
}
@ -610,14 +611,14 @@ void GEOM_Actor::setInputShape(const TopoDS_Shape& ashape, double adef1,
int imode, bool isVector)
{
#ifdef MYDEBUG
cout << "GEOM_Actor::setInputShape"<<endl;
MESSAGE ( "GEOM_Actor::setInputShape" );
#endif
}
double GEOM_Actor::getDeflection()
{
#ifdef MYDEBUG
cout << "GEOM_Actor::getDeflection"<<endl;
MESSAGE ( "GEOM_Actor::getDeflection" );
#endif
return (double) GetDeflection();
}
@ -626,7 +627,7 @@ double GEOM_Actor::getDeflection()
double GEOM_Actor::isVector()
{
#ifdef MYDEBUG
cout << "GEOM_Actor::isVector"<<endl;
MESSAGE ( "GEOM_Actor::isVector" );
#endif
return 0;
}
@ -634,21 +635,21 @@ double GEOM_Actor::isVector()
void GEOM_Actor::SubShapeOn()
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SubShapeOn"<<endl;
MESSAGE ( "GEOM_Actor::SubShapeOn" );
#endif
}
void GEOM_Actor::SubShapeOff()
{
#ifdef MYDEBUG
cout << "GEOM_Actor::SubShapeOff"<<endl;
MESSAGE ( "GEOM_Actor::SubShapeOff" );
#endif
}
void GEOM_Actor::highlight(bool highlight)
{
#ifdef MYDEBUG
cout << this << " GEOM_Actor::highlight highlight="<<highlight<<endl;
MESSAGE ( this << " GEOM_Actor::highlight highlight="<<highlight );
#endif
SALOME_Actor::highlight(highlight);
}
@ -701,7 +702,7 @@ GEOM_Actor
{
myIsSelected = theIsHighlight;
#ifdef MYDEBUG
cout << this << " GEOM_Actor::Highlight myIsSelected="<<myIsSelected<<endl;
MESSAGE ( this << " GEOM_Actor::Highlight myIsSelected="<<myIsSelected );
#endif
SALOME_Actor::Highlight(theIsHighlight); // this method call ::highlight(theIsHighlight) in the end
@ -718,7 +719,7 @@ GEOM_Actor
bool theIsHighlight)
{
#ifdef MYDEBUG
cout << this<<" GEOM_Actor::PreHighlight (3) theIsHighlight="<<theIsHighlight<<endl;
MESSAGE ( this<<" GEOM_Actor::PreHighlight (3) theIsHighlight="<<theIsHighlight );
#endif
if ( !GetPickable() )
@ -763,7 +764,7 @@ GEOM_Actor
{
// define the selection of object
#ifdef MYDEBUG
cout << endl << this << " GEOM_Actor::Highlight (3) myIsSelected="<<myIsSelected<<endl;
MESSAGE ( std::endl << this << " GEOM_Actor::Highlight (3) myIsSelected="<<myIsSelected );
#endif
bool aRet = SALOME_Actor::Highlight(theInteractorStyle,theSelectionEvent,theIsHighlight);
SetSelected(theIsHighlight);

View File

@ -32,9 +32,10 @@
vtkStandardNewMacro(GEOM_WireframeFace);
GEOM_WireframeFace::GEOM_WireframeFace():
NbIso(1),
Discret(15)
{
NbIso[0] = 1;
NbIso[1] = 1;
}
GEOM_WireframeFace::~GEOM_WireframeFace()
@ -58,12 +59,29 @@ Execute()
}
}
void GEOM_WireframeFace::SetNbIso(const int theNb[2])
{
if ( theNb[0] == NbIso[0] && theNb[1] == NbIso[1])
return;
NbIso[0] = theNb[0];
NbIso[1] = theNb[1];
Modified();
}
void GEOM_WireframeFace::GetNbIso(int &theNbU,int &theNbV)
{
theNbU = NbIso[0];
theNbV = NbIso[1];
}
void
GEOM_WireframeFace::
OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* thePolyData,
vtkPoints* thePts,
const int theNbIso,
const int theNbIso[2],
const int theDiscret)
{
TopoDS_Face aFace = theFace;
@ -74,7 +92,7 @@ OCC2VTK(const TopoDS_Face& theFace,
void
GEOM_WireframeFace::
CreateIso(const TopoDS_Face& theFace,
const int theNbIso,
const int theNbIso[2],
const int theDiscret,
vtkPolyData* thePolyData,
vtkPoints* thePts)
@ -95,8 +113,8 @@ CreateIso(const TopoDS_Face& theFace,
Standard_False);
Standard_Real anUMin, anUMax, aVMin, aVMax;
TColStd_Array1OfReal anUPrm(1, theNbIso), aVPrm(1, theNbIso);
TColStd_Array1OfInteger anUInd(1, theNbIso), aVInd(1, theNbIso);
TColStd_Array1OfReal anUPrm(1, theNbIso[0]), aVPrm(1, theNbIso[1]);
TColStd_Array1OfInteger anUInd(1, theNbIso[0]), aVInd(1, theNbIso[1]);
anUInd.Init(0);
aVInd.Init(0);
@ -185,11 +203,11 @@ CreateIso(const TopoDS_Face& theFace,
Standard_Real confusion = Min(DeltaU, DeltaV) * HATHCER_CONFUSION_3D ;
aHatcher.Confusion3d (confusion) ;
Standard_Real StepU = DeltaU / (Standard_Real)theNbIso;
Standard_Real StepU = DeltaU / (Standard_Real)theNbIso[0];
if(StepU > confusion){
Standard_Real UPrm = anUMin + StepU / 2.;
gp_Dir2d Dir(0., 1.) ;
for(IIso = 1 ; IIso <= theNbIso ; IIso++) {
for(IIso = 1 ; IIso <= theNbIso[0] ; IIso++) {
anUPrm(IIso) = UPrm ;
gp_Pnt2d Ori (UPrm, 0.) ;
Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ;
@ -198,11 +216,11 @@ CreateIso(const TopoDS_Face& theFace,
}
}
Standard_Real StepV = DeltaV / (Standard_Real) theNbIso ;
Standard_Real StepV = DeltaV / (Standard_Real) theNbIso[1] ;
if(StepV > confusion){
Standard_Real VPrm = aVMin + StepV / 2.;
gp_Dir2d Dir(1., 0.);
for(IIso = 1 ; IIso <= theNbIso ; IIso++){
for(IIso = 1 ; IIso <= theNbIso[1] ; IIso++){
aVPrm(IIso) = VPrm;
gp_Pnt2d Ori (0., VPrm);
Geom2dAdaptor_Curve HCur(new Geom2d_Line (Ori, Dir));
@ -217,9 +235,9 @@ CreateIso(const TopoDS_Face& theFace,
aHatcher.Trim() ;
Standard_Integer aNbDom = 0 ; // for debug purpose
for(IIso = 1 ; IIso <= theNbIso ; IIso++){
Standard_Integer Index ;
for(IIso = 1 ; IIso <= theNbIso[0] ; IIso++){
Index = anUInd(IIso) ;
if(Index != 0){
if(aHatcher.TrimDone(Index) && !aHatcher.TrimFailed(Index)){
@ -228,7 +246,9 @@ CreateIso(const TopoDS_Face& theFace,
aNbDom = aHatcher.NbDomains (Index);
}
}
}
for(IIso = 1 ; IIso <= theNbIso[1] ; IIso++){
Index = aVInd(IIso);
if(Index != 0){
if(aHatcher.TrimDone (Index) && !aHatcher.TrimFailed(Index)){

View File

@ -15,8 +15,8 @@ public:
vtkTypeMacro(GEOM_WireframeFace,GEOM_FaceSource);
static GEOM_WireframeFace* New();
vtkSetMacro(NbIso,int);
vtkGetMacro(NbIso,int);
/* vtkSetMacro(NbIso,int);
vtkGetMacro(NbIso,int);*/
vtkSetMacro(Discret,int);
vtkGetMacro(Discret,int);
@ -25,16 +25,22 @@ public:
void OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* thePolyData,
vtkPoints* thePts,
int theNbIso = 1,
int theDiscret = 15);
const int theNbIso[2],
const int theDiscret = 15);
//! IsoLines management
// theNb[0] - number of U lines
// theNb[1] - number of V lines
virtual void SetNbIso(const int theNb[2]);
virtual void GetNbIso(int &theNbU,int &theNbV);
protected:
int NbIso, Discret;
int NbIso[2], Discret;
static
void
CreateIso(const TopoDS_Face& theFace,
const int theNbIso,
const int theNbIso[2],
const int theDiscret,
vtkPolyData* thePolyData,
vtkPoints* thePts);