From: ouv Date: Fri, 2 Dec 2005 15:50:40 +0000 (+0000) Subject: Geometrical Sphere. X-Git-Tag: TG-D5-38-2003_D2005-20-12~69 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a091b04b3ae8fdddf85928a684828044e126d306;p=modules%2Fvisu.git Geometrical Sphere. --- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 5743b3ba..ff17fb3a 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -543,7 +543,7 @@ VISU_GaussPtsAct vtkDataSet* aDataSet = GetInput(); vtkCellData* aCellData = aDataSet->GetCellData(); if(vtkDataArray *aScalarArray = aCellData->GetScalars()){ - float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); + float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray) / 2.; float aPyramidHeight = myPickingSettings->GetPyramidHeight(); aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); @@ -749,7 +749,7 @@ VISU_GaussPtsAct // if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){ aVal = aScalarArray->GetTuple1(aVtkId); - aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); + aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray) / 2.; // GetScalarBarCtrl()->SetIsMarked(true); GetScalarBarCtrl()->SetMarkValue(aVal); @@ -913,11 +913,19 @@ VISU_GaussPtsAct aPipeline->SetClamp( myInsideCursorSettings->GetClamp() ); aPipeline->SetImageData( myInsideCursorSettings->GetTexture() ); aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() ); + aPipeline->SetResolution( myInsideCursorSettings->GetResolution() ); aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() ); aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() ); aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() ); aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() ); + if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere ) + theActor->GetProperty()->SetRepresentation( VTK_POINTS ); + else + theActor->GetProperty()->SetRepresentation( VTK_SURFACE ); + + //aPipeLine->Update(); + Update(); } @@ -936,7 +944,6 @@ VISU_GaussPtsAct1 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents); - myInsideDeviceActor->SetProperty(GetProperty()); myInsideDeviceActor->SetVisibility(false); myInsideDeviceActor->SetPickable(false); myInsideDeviceActor->Delete(); @@ -1136,9 +1143,16 @@ VISU_GaussPtsAct1 anExtractGeometry->SetExtractInside(true); aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() ); + + if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere ) + myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS ); + else + myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE ); + aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() ); aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() ); aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() ); + aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() ); aPipeline->SetSize( myOutsideCursorSettings->GetSize() ); if( myOutsideCursorSettings->GetUniform() ) @@ -1153,6 +1167,8 @@ VISU_GaussPtsAct1 myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOn(); } + aPipeline->Update(); + Update(); } diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 143f3a6f..3c180fa7 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -113,6 +113,19 @@ VISU_GaussPointsPL } +//---------------------------------------------------------------------------- +void +CopyGlyph( vtkGlyph3D* source, vtkGlyph3D* dest ) +{ + dest->SetRange( source->GetRange() ); + dest->SetScaling( source->GetScaling() ); + dest->SetClamping( source->GetClamping() ); + dest->SetScaleMode( source->GetScaleMode() ); + dest->SetColorMode( source->GetColorMode() ); + dest->SetScaleFactor( source->GetScaleFactor() ); +} + + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -138,6 +151,9 @@ VISU_GaussPointsPL SetIsDeformed( aPipeLine->GetIsDeformed() ); SetScale( aPipeLine->GetScale() ); + + mySphereSource->SetRadius( aPipeLine->mySphereSource->GetRadius() ); + CopyGlyph( aPipeLine->myGlyph, this->myGlyph ); } Superclass::ShallowCopy(thePipeLine); } @@ -206,20 +222,21 @@ VISU_GaussPointsPL void VISU_GaussPointsPL ::Build() -{} +{ +} //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Update() { + //cout << "VISU_GaussPointsPL::Update()" << endl; + GetSourceRange(mySourceScalarRange); myDeltaScalarRange = mySourceScalarRange[1] - mySourceScalarRange[0]; SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) ); - mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. ); - vtkMapper* aMapper = GetMapper(); vtkDataSet* aDataSet = aMapper->GetInput(); vtkCellData* aCellData = aDataSet->GetCellData(); @@ -228,9 +245,61 @@ VISU_GaussPointsPL myPSMapper->SetLookupTable( myMapperTable ); myPSMapper->SetScalarRange( mySourceScalarRange ); + this->UpdateGlyph(); + VISU_ScalarMapPL::Update(); } +//---------------------------------------------------------------------------- +void +VISU_GaussPointsPL +::UpdateGlyph() +{ + //cout << "VISU_GaussPointsPL::UpdateGlyph()" << endl; + + float aScalarRange[2]; + GetSourceRange( aScalarRange ); + + if( myPSMapper->GetPointSpriteMode() == 0 ) // Results + { + //cout << "Results" << endl; + myGlyph->ClampingOn(); + myGlyph->SetScaleModeToScaleByScalar(); + myGlyph->SetColorModeToColorByScalar(); + + float aRange = 0; + float aMinSize = GetMinSize(); + float aMaxSize = GetMaxSize(); + if( fabs( aMaxSize - aMinSize ) > 0.0001 ) + aRange = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize ); + float aMinRange = aScalarRange[0] - aMinSize * aRange; + float aMaxRange = aMinRange + aRange; + + myGlyph->SetRange( aMinRange, aMaxRange ); + myGlyph->SetScaleFactor( 1.0 ); + } + else if( myPSMapper->GetPointSpriteMode() == 1 ) // Geometry + { + //cout << "Geometry" << endl; + myGlyph->ClampingOff(); + myGlyph->SetScaleModeToDataScalingOff(); + myGlyph->SetColorModeToColorByScale(); + + myGlyph->SetScaleFactor( GetSize() ); + } + else if( myPSMapper->GetPointSpriteMode() == 2 ) // Outside + { + //cout << "Outside" << endl; + myGlyph->ClampingOff(); + myGlyph->SetScaleModeToDataScalingOff(); + myGlyph->SetColorModeToColorByScalar(); + + myGlyph->SetScaleFactor( GetSize() ); + } + + mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. ); +} + //---------------------------------------------------------------------------- VISU::TGaussPointID VISU_GaussPointsPL @@ -322,6 +391,7 @@ VISU_GaussPointsPL ::SetIsColored(bool theIsColored) { myPSMapper->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry + Modified(); } //---------------------------------------------------------------------------- @@ -392,30 +462,12 @@ VISU_GaussPointsPL return myPSMapper->GetPointSpriteSize(); } -//---------------------------------------------------------------------------- -void -VISU_GaussPointsPL -::UpdateGlyphRange() -{ - float aScalarRange[2]; - GetSourceRange( aScalarRange ); - - float aMinSize = GetMinSize(); - float aMaxSize = GetMaxSize(); - float aRange = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize ); - float aMinRange = aScalarRange[0] - aMinSize * aRange; - float aMaxRange = aMinRange + aRange; - - myGlyph->SetRange( aMinRange, aMaxRange ); -} - //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetMinSize(float theMinSize) { myPSMapper->SetPointSpriteMinSize( theMinSize ); - UpdateGlyphRange(); Modified(); } @@ -433,7 +485,6 @@ VISU_GaussPointsPL ::SetMaxSize(float theMaxSize) { myPSMapper->SetPointSpriteMaxSize( theMaxSize ); - UpdateGlyphRange(); Modified(); } diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 19e00796..86d63dc9 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -98,6 +98,10 @@ public: void Update(); + //! Update glyph. + void + UpdateGlyph(); + virtual VISU::TGaussPointID GetObjID(vtkIdType theID) const; @@ -237,10 +241,6 @@ public: float GetAverageCellSize(); - //! Update scalar range of the glyph. - void - UpdateGlyphRange(); - //! Set image data for the Point Sprite texture. void SetImageData(vtkImageData* theImageData); diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index f4640aee..511b3b3e 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -671,6 +671,26 @@ struct TVertex GLfloat vx, vy, vz; }; +float ViewToDisplay( vtkRenderer* theRenderer ) +{ + float p1[3], p2[3]; + + theRenderer->SetViewPoint( 0.0, 0.0, 0.0 ); + theRenderer->ViewToDisplay(); + theRenderer->GetDisplayPoint( p1 ); + + theRenderer->SetViewPoint( 1.0, 1.0, 1.0 ); + theRenderer->ViewToDisplay(); + theRenderer->GetDisplayPoint( p2 ); + + float coefficient = sqrt( pow( p2[0] - p1[0], 2 ) + pow( p2[1] - p1[1], 2 ) ) / sqrt( 2 ); + //cout << p1[0] << " " << p1[1] << " " << p1[2] << endl; + //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl; + //cout << "ZOOM : " << coefficient << endl; + + return coefficient; +} + //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, vtkUnsignedCharArray *colors, @@ -681,23 +701,11 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, vtkRenderer *ren, vtkActor* act) { - if( this->UsePointSprites ) + if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite ) this->InitPointSprites(); - float p1[3], p2[3]; - - ren->SetViewPoint( 0.0, 0.0, 0.0 ); - ren->ViewToDisplay(); - ren->GetDisplayPoint( p1 ); - - ren->SetViewPoint( 1.0, 1.0, 1.0 ); - ren->ViewToDisplay(); - ren->GetDisplayPoint( p2 ); - - float coefficient = sqrt( pow( p2[0] - p1[0], 2 ) + pow( p2[1] - p1[1], 2 ) ) / sqrt( 2 ); - //cout << p1[0] << " " << p1[1] << " " << p1[2] << endl; - //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl; - //cout << "ZOOM : " << coefficient << endl; + if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint ) + glEnable( GL_POINT_SMOOTH ); glPointSize( this->DefaultPointSize ); @@ -749,7 +757,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, else size = this->PointSpriteSize; - aVertex[i].hue = coefficient * this->AverageCellSize * this->PointSpriteMagnification * size; + aVertex[i].hue = ViewToDisplay( ren ) * this->AverageCellSize * this->PointSpriteMagnification * size; } GLuint aBufferObjectID = 0; @@ -779,8 +787,11 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, vglUseProgramObjectARB( 0 ); - if( this->UsePointSprites ) + if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite ) this->CleanupPointSprites(); + + if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint ) + glDisable( GL_POINT_SMOOTH ); } //----------------------------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 097ffdd6..2d33325f 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -599,6 +599,7 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs ) bool isDeformed = thePrs->GetIsDeformed(); myScaleSpinBox->setValue( thePrs->GetScaleFactor() ); myDefShapeButton->setChecked( isDeformed ); + myDefShapeButton->setEnabled( thePrs->GetField()->myNbComp > 1 ); onToggleDefShape( isDeformed ); bool isResults = thePrs->GetIsColored(); diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.cxx b/src/VVTK/VVTK_SegmentationCursorDlg.cxx index 1fa96fd2..c81d39cb 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.cxx +++ b/src/VVTK/VVTK_SegmentationCursorDlg.cxx @@ -356,6 +356,7 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp"; QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp"; float anAlphaThreshold = 0.1; + int aResolution = 8; int aMinSize = 3; int aMaxSize = 33; int aMagnification = 100; @@ -368,6 +369,7 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() myInsidePrimitiveBox->setMainTexture( myInsideMainTexture ); myInsidePrimitiveBox->setAlphaTexture( myInsideAlphaTexture ); myInsidePrimitiveBox->setAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() ); + myInsidePrimitiveBox->setResolution( myInsideCursorSettings->GetResolution() ); myInsideSizeBox->setMinSize( myInsideCursorSettings->GetMinSize() ); myInsideSizeBox->setMaxSize( myInsideCursorSettings->GetMaxSize() ); @@ -394,6 +396,9 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_alpha_threshold", anAlphaThreshold ); myInsidePrimitiveBox->setAlphaThreshold( anAlphaThreshold ); + aResolution = aResourceMgr->integerValue( "VISU", "inside_geom_sphere_resolution", aResolution ); + myInsidePrimitiveBox->setResolution( aResolution ); + aMinSize = aResourceMgr->integerValue( "VISU", "inside_point_sprite_min_size", aMinSize ); myInsideSizeBox->setMinSize( aMinSize / 100.0 ); @@ -416,6 +421,7 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints() QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp"; QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp"; float anAlphaThreshold = 0.1; + int aResolution = 8; int aSize = 25; bool aUniform = false; QColor aColor = Qt::blue; @@ -427,6 +433,7 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints() myOutsidePrimitiveBox->setMainTexture( myOutsideMainTexture ); myOutsidePrimitiveBox->setAlphaTexture( myOutsideAlphaTexture ); myOutsidePrimitiveBox->setAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() ); + myOutsidePrimitiveBox->setResolution( myOutsideCursorSettings->GetResolution() ); myOutsideSizeBox->setOutsideSize( myOutsideCursorSettings->GetSize() ); myOutsideSizeBox->setUniform( myOutsideCursorSettings->GetUniform() ); @@ -456,6 +463,9 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints() anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "outside_point_sprite_alpha_threshold", anAlphaThreshold ); myOutsidePrimitiveBox->setAlphaThreshold( anAlphaThreshold ); + aResolution = aResourceMgr->integerValue( "VISU", "outside_geom_sphere_resolution", aResolution ); + myOutsidePrimitiveBox->setResolution( aResolution ); + aSize = aResourceMgr->integerValue( "VISU", "outside_point_sprite_size", aSize ); myOutsideSizeBox->setOutsideSize( aSize / 100.0 ); @@ -593,6 +603,7 @@ void VVTK_SegmentationCursorDlg::ApplyInsideGaussPoints() myInsideCursorSettings->SetPrimitiveType( myInsidePrimitiveBox->getPrimitiveType() ); myInsideCursorSettings->SetClamp( myInsidePrimitiveBox->getClamp() ); myInsideCursorSettings->SetAlphaThreshold( myInsidePrimitiveBox->getAlphaThreshold() ); + myInsideCursorSettings->SetResolution( myInsidePrimitiveBox->getResolution() ); myInsideCursorSettings->SetMinSize( myInsideSizeBox->getMinSize() ); myInsideCursorSettings->SetMaxSize( myInsideSizeBox->getMaxSize() ); @@ -615,6 +626,7 @@ void VVTK_SegmentationCursorDlg::ApplyOutsideGaussPoints() myOutsideCursorSettings->SetPrimitiveType( myOutsidePrimitiveBox->getPrimitiveType() ); myOutsideCursorSettings->SetClamp( myOutsidePrimitiveBox->getClamp() ); myOutsideCursorSettings->SetAlphaThreshold( myOutsidePrimitiveBox->getAlphaThreshold() ); + myOutsideCursorSettings->SetResolution( myOutsidePrimitiveBox->getResolution() ); myOutsideCursorSettings->SetSize( myOutsideSizeBox->getOutsideSize() ); myOutsideCursorSettings->SetUniform( myOutsideSizeBox->getUniform() );