X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Actor.cxx;h=bdd94da6b30d6b0bc391cbab6bbbc3d01de2b01f;hb=dbf226547fc4b1b1c901ab994db7c1708dd6576d;hp=b2882117b8bd3e9ede4d9248d222c963447501c9;hpb=e0528f4426fbfb1ab5d8285045a3bcf703b4f041;p=modules%2Fsmesh.git diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index b2882117b..bdd94da6b 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -75,6 +75,7 @@ #include #include +#include #include #include @@ -142,10 +143,11 @@ SMESH_ActorDef::SMESH_ActorDef() if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) ) myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1); - double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5); - double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10); - double aLineWidth = SMESH::GetFloat("SMESH:element_width",1); - double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1); + double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5); + double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10); + double aBallElemScale = SMESH::GetFloat("SMESH:ball_elem_scale",1.0); + double aLineWidth = SMESH::GetFloat("SMESH:element_width",1); + double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1); SMESH::LabelFont aFamilyNd = SMESH::FntTimes; bool aBoldNd = true; @@ -220,10 +222,11 @@ SMESH_ActorDef::SMESH_ActorDef() aFilter = my2DActor->GetExtractUnstructuredGrid(); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_TRIANGLE); - aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUAD); + aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); @@ -243,10 +246,11 @@ SMESH_ActorDef::SMESH_ActorDef() my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe); aFilter = my2DExtActor->GetExtractUnstructuredGrid(); aFilter->RegisterCellsWithType(VTK_TRIANGLE); - aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUAD); + aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); @@ -273,10 +277,7 @@ SMESH_ActorDef::SMESH_ActorDef() aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); -//#ifdef VTK_HAVE_POLYHEDRON - MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)"); aFilter->RegisterCellsWithType(VTK_POLYHEDRON); -//#endif my3DExtProp = vtkProperty::New(); my3DExtProp->DeepCopy(myNormalVProp); @@ -375,7 +376,6 @@ SMESH_ActorDef::SMESH_ActorDef() my0DActor->SetProperty(my0DProp); my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface); aFilter = my0DActor->GetExtractUnstructuredGrid(); - //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_VERTEX); @@ -394,6 +394,7 @@ SMESH_ActorDef::SMESH_ActorDef() myBallActor->SetVisibility(false); myBallActor->SetProperty(myBallProp); myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface); + myBallActor->SetBallEnabled(true); aFilter = myBallActor->GetExtractUnstructuredGrid(); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_POLY_VERTEX); @@ -474,11 +475,6 @@ SMESH_ActorDef::SMESH_ActorDef() myHighlightProp->SetLineWidth(aLineWidth); myHighlightProp->SetRepresentation(1); - myBallHighlightProp = vtkProperty::New(); - myBallHighlightProp->DeepCopy(myHighlightProp); - myBallHighlightProp->SetPointSize(aBallElemSize); - - myOutLineProp = vtkProperty::New(); myOutLineProp->SetAmbient(1.0); myOutLineProp->SetDiffuse(0.0); @@ -498,10 +494,6 @@ SMESH_ActorDef::SMESH_ActorDef() myPreselectProp->SetLineWidth(aLineWidth); myPreselectProp->SetRepresentation(1); - myBallPreselectProp = vtkProperty::New(); - myBallPreselectProp->DeepCopy(myPreselectProp); - myBallPreselectProp->SetPointSize(aBallElemSize); - myHighlitableActor = SMESH_DeviceActor::New(); myHighlitableActor->SetUserMatrix(aMatrix); myHighlitableActor->PickableOff(); @@ -543,6 +535,8 @@ SMESH_ActorDef::SMESH_ActorDef() myImplicitBoolean = vtkImplicitBoolean::New(); myImplicitBoolean->SetOperationTypeToIntersection(); + myPlaneCollection = vtkPlaneCollection::New(); + //Quadratic 2D elements representation //----------------------------------------------------------------------------- int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0); @@ -572,6 +566,7 @@ SMESH_ActorDef::SMESH_ActorDef() #endif SetBallSize(aBallElemSize); + SetBallScale(aBallElemScale); Set0DSize(aElem0DSize); } @@ -602,9 +597,6 @@ SMESH_ActorDef::~SMESH_ActorDef() myOutLineProp->Delete(); myPreselectProp->Delete(); - myBallHighlightProp->Delete(); - myBallPreselectProp->Delete(); - myHighlitableActor->Delete(); my2DExtProp->Delete(); @@ -631,6 +623,7 @@ SMESH_ActorDef::~SMESH_ActorDef() //my0DExtActor->Delete(); myImplicitBoolean->Delete(); + myPlaneCollection->Delete(); #ifndef DISABLE_PLOT2DVIEWER if(my2dHistogram) { @@ -678,8 +671,6 @@ void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int the { if(my3DActor) { my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b ); - SetRepresentation( GetRepresentation() ); - myTimeStamp->Modified(); } if(my2DActor) { my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b ); @@ -1094,8 +1085,6 @@ SetControlMode(eControl theMode, void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){ - //myHighlightActor->AddToRender(theRenderer); - theRenderer->AddActor(myBaseActor); theRenderer->AddActor(myNodeExtActor); theRenderer->AddActor(my1DExtActor); @@ -1108,7 +1097,6 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){ my1DActor ->AddToRender(theRenderer); my0DActor ->AddToRender(theRenderer); myBallActor ->AddToRender(theRenderer); - //theRenderer->AddActor(my0DExtActor); theRenderer->AddActor(myHighlitableActor); @@ -1157,6 +1145,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, myVisualObj = theVisualObj; myVisualObj->Update(theIsClear); + SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj); + SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj); + myNodeActor->Init(myVisualObj,myImplicitBoolean); myBaseActor->Init(myVisualObj,myImplicitBoolean); @@ -1323,7 +1314,7 @@ void SMESH_ActorDef::SetShrinkFactor(double theValue){ Modified(); } -void SMESH_ActorDef::SetShrink(){ +void SMESH_ActorDef::SetShrink() { if(!myIsShrinkable) return; myBaseActor->SetShrink(); @@ -1559,7 +1550,6 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode) if (myEntityMode & eBallElem) { aFilter->RegisterCellsWithType(VTK_POLY_VERTEX); - aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX); } if (myEntityMode & eEdges) { @@ -1574,18 +1564,20 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode) if (myEntityMode & eFaces) { if (MYDEBUG) MESSAGE("FACES"); aFilter->RegisterCellsWithType(VTK_TRIANGLE); - aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUAD); + aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); aHightFilter->RegisterCellsWithType(VTK_TRIANGLE); - aHightFilter->RegisterCellsWithType(VTK_POLYGON); aHightFilter->RegisterCellsWithType(VTK_QUAD); + aHightFilter->RegisterCellsWithType(VTK_POLYGON); aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); } @@ -1601,11 +1593,10 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode) aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA); aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON); aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); -//#ifdef VTK_HAVE_POLYHEDRON aFilter->RegisterCellsWithType(VTK_POLYHEDRON); -//#endif aHightFilter->RegisterCellsWithType(VTK_TETRA); aHightFilter->RegisterCellsWithType(VTK_VOXEL); @@ -1619,9 +1610,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode) aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); -//#ifdef VTK_HAVE_POLYHEDRON aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON); -//#endif } aFilter->Update(); if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells()); @@ -1638,9 +1627,9 @@ void SMESH_ActorDef::SetRepresentation (int theMode) if (theMode < 0) { myRepresentation = eSurface; - if (!aNbFaces && !aNbVolumes && aNbEdges) { + if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) { myRepresentation = eEdge; - } else if (!aNbFaces && !aNbVolumes && !aNbEdges) { + } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) { myRepresentation = ePoint; } } else { @@ -1710,25 +1699,22 @@ void SMESH_ActorDef::SetRepresentation (int theMode) my3DActor->SetBackfaceProperty(aPropVR); my3DActor->SetRepresentation(aReperesent); - //my0DExtActor->SetVisibility(false); + my1DExtActor->SetVisibility(false); my2DExtActor->SetVisibility(false); my3DExtActor->SetVisibility(false); - // ??? - //my0DActor->SetProperty(aProp); - //my0DActor->SetBackfaceProperty(aBackProp); my0DActor->SetRepresentation(aReperesent); myBallActor->SetRepresentation(aReperesent); - //my0DExtActor->SetRepresentation(aReperesent); - switch(myControlMode){ + switch ( myControlMode ) { case eLength: case eMultiConnection: aProp = aBackProp = my1DProp; if(myRepresentation != ePoint) aReperesent = SMESH_DeviceActor::eInsideframe; break; + default:; } if(aQuadraticMode == SMESH_Actor::eLines) @@ -1770,7 +1756,6 @@ bool SMESH_ActorDef::GetPointRepresentation(){ void SMESH_ActorDef::UpdateHighlight(){ myHighlitableActor->SetHighlited(false); myHighlitableActor->SetVisibility(false); - bool anIsVisible = GetVisibility(); switch(myRepresentation){ @@ -1779,12 +1764,9 @@ void SMESH_ActorDef::UpdateHighlight(){ { if(myIsHighlighted) { myHighlitableActor->SetProperty(myHighlightProp); - myBallActor->SetProperty(myBallHighlightProp); }else if(myIsPreselected){ myHighlitableActor->SetProperty(myPreselectProp); - myBallActor->SetProperty(myBallPreselectProp); } else if(anIsVisible){ - myBallActor->SetProperty(myBallProp); (myRepresentation == eSurface) ? myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp); } @@ -2042,7 +2024,6 @@ void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b){ void SMESH_ActorDef::SetHighlightColor(double r,double g,double b){ myHighlightProp->SetColor(r,g,b); - myBallHighlightProp->SetColor(r,g,b); Modified(); } @@ -2052,7 +2033,6 @@ void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b){ void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b){ myPreselectProp->SetColor(r,g,b); - myBallPreselectProp->SetColor(r,g,b); Modified(); } @@ -2111,8 +2091,7 @@ double SMESH_ActorDef::Get0DSize(){ void SMESH_ActorDef::SetBallSize(double theVal){ myBallProp->SetPointSize(theVal); - myBallHighlightProp->SetPointSize(theVal); - myBallPreselectProp->SetPointSize(theVal); + if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) { aCustom->SetBallSize(theVal); } @@ -2127,6 +2106,24 @@ double SMESH_ActorDef::GetBallSize(){ return myBallProp->GetPointSize(); } +double SMESH_ActorDef::GetBallScale() +{ + return myBallActor->GetBallScale(); +} + +void SMESH_ActorDef::SetBallScale( double theVal ) +{ + myBallActor->SetBallScale( theVal ); + if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) { + aCustom->SetBallScale(theVal); + } + if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) { + aCustom->SetBallScale(theVal); + } + + Modified(); +} + int SMESH_ActorDef::GetObjDimension( const int theObjId ) { return myVisualObj->GetElemDimension( theObjId ); @@ -2175,10 +2172,70 @@ SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane) return myCippingPlaneCont.size(); } +void +SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane) +{ + if(thePlane) + myPlaneCollection->AddItem( thePlane ); +} + +void +SMESH_ActorDef::SetOpenGLClippingPlane() +{ + // before use this method you must add clipping planes using method + // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane) + if( !myPlaneCollection->GetNumberOfItems() ) + return; + + // It is necessary to set plane collection for each mapper of actor + // and update current inputs of mapper + myNodeActor->SetPlaneCollection( myPlaneCollection ); + myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + myBaseActor->SetPlaneCollection( myPlaneCollection ); + myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + myHighlitableActor->SetPlaneCollection( myPlaneCollection ); + myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my1DActor->SetPlaneCollection( myPlaneCollection ); + my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my2DActor->SetPlaneCollection( myPlaneCollection ); + my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + myNodeExtActor->SetPlaneCollection( myPlaneCollection ); + myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my0DActor->SetPlaneCollection( myPlaneCollection ); + my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + myBallActor->SetPlaneCollection( myPlaneCollection ); + myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my1DExtActor->SetPlaneCollection( myPlaneCollection ); + my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my2DExtActor->SetPlaneCollection( myPlaneCollection ); + my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my3DActor->SetPlaneCollection( myPlaneCollection ); + my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + my3DExtActor->SetPlaneCollection( myPlaneCollection ); + my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + if(IsShrunk()) + SetShrink(); + else + Modified(); +} + void SMESH_ActorDef:: RemoveAllClippingPlanes() { + myPlaneCollection->RemoveAllItems(); myImplicitBoolean->GetFunction()->RemoveAllItems(); myImplicitBoolean->GetFunction()->Modified(); // VTK bug myCippingPlaneCont.clear(); @@ -2197,7 +2254,7 @@ vtkPlane* SMESH_ActorDef:: GetClippingPlane(vtkIdType theID) { - if(theID >= myCippingPlaneCont.size()) + if ( theID >= (vtkIdType)myCippingPlaneCont.size() ) return NULL; return myCippingPlaneCont[theID].Get(); } @@ -2431,7 +2488,7 @@ SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() { bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10; fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic); - for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ ) + for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ ) my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast(nbEvents[i])); if(funValues.size() >= 2)