1 // SMESH OBJECT : interactive object for SMESH visualization
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
30 #include "SMESH_ActorDef.h"
31 #include "SMESH_ActorUtils.h"
32 #include "SMESH_DeviceActor.h"
33 #include "SMESH_ControlsDef.hxx"
34 #include <VTKViewer_ExtractUnstructuredGrid.h>
36 #include "SUIT_Session.h"
37 #include "SUIT_ResourceMgr.h"
39 #include <qstringlist.h>
41 #include <vtkTimeStamp.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkShrinkPolyData.h>
44 #include <vtkMergeFilter.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkUnstructuredGrid.h>
48 #include <vtkPointData.h>
49 #include <vtkCellData.h>
51 #include <vtkMapper.h>
52 #include <vtkRenderer.h>
55 #include <vtkIdList.h>
56 #include <vtkIntArray.h>
58 #include <vtkActor2D.h>
59 #include <vtkProperty2D.h>
60 #include <vtkPolyData.h>
61 #include <vtkMaskPoints.h>
62 #include <vtkCellCenters.h>
63 #include <vtkTextProperty.h>
64 #include <vtkLabeledDataMapper.h>
65 #include <vtkSelectVisiblePoints.h>
67 #include <vtkScalarBarActor.h>
68 #include <vtkLookupTable.h>
72 #include <vtkImplicitBoolean.h>
73 #include <vtkImplicitFunctionCollection.h>
75 #include "utilities.h"
78 static int MYDEBUG = 1;
80 static int MYDEBUG = 0;
83 static int aLineWidthInc = 2;
84 static int aPointSizeInc = 2;
87 SMESH_ActorDef* SMESH_ActorDef::New(){
88 return new SMESH_ActorDef();
92 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
97 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
98 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
106 SMESH_ActorDef::SMESH_ActorDef()
108 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
110 myTimeStamp = vtkTimeStamp::New();
112 myIsPointsVisible = false;
114 myIsShrinkable = false;
117 myControlsPrecision = (long)SMESH::GetFloat( "SMESH:ControlsPrecision", -1 );
119 float aPointSize = SMESH::GetFloat("SMESH:SettingsNodesSize",3);
120 float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1);
122 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
123 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
125 //Definition 2D and 3D divices of the actor
126 //-----------------------------------------
127 float anRGB[3] = {1,1,1};
128 mySurfaceProp = vtkProperty::New();
129 anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
130 anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
131 anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
132 mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
134 myBackSurfaceProp = vtkProperty::New();
135 anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
136 anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
137 anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
138 myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
140 my2DActor = SMESH_DeviceActor::New();
141 my2DActor->SetUserMatrix(aMatrix);
142 my2DActor->PickableOff();
143 my2DActor->SetProperty(mySurfaceProp);
144 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
145 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
146 aFilter = my2DActor->GetExtractUnstructuredGrid();
147 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
148 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
149 aFilter->RegisterCellsWithType(VTK_POLYGON);
150 aFilter->RegisterCellsWithType(VTK_QUAD);
152 my3DActor = SMESH_DeviceActor::New();
153 my3DActor->SetUserMatrix(aMatrix);
154 my3DActor->PickableOff();
155 my3DActor->SetProperty(mySurfaceProp);
156 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
157 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
158 aFilter = my3DActor->GetExtractUnstructuredGrid();
159 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
160 aFilter->RegisterCellsWithType(VTK_TETRA);
161 aFilter->RegisterCellsWithType(VTK_VOXEL);
162 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
163 aFilter->RegisterCellsWithType(VTK_WEDGE);
164 aFilter->RegisterCellsWithType(VTK_PYRAMID);
165 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
167 //Definition 1D divice of the actor
168 //---------------------------------
169 myEdgeProp = vtkProperty::New();
170 myEdgeProp->SetAmbient(1.0);
171 myEdgeProp->SetDiffuse(0.0);
172 myEdgeProp->SetSpecular(0.0);
173 anRGB[0] = SMESH::GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.;
174 anRGB[1] = SMESH::GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.;
175 anRGB[2] = SMESH::GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.;
176 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
177 myEdgeProp->SetLineWidth(aLineWidth);
179 my1DActor = SMESH_DeviceActor::New();
180 my1DActor->SetUserMatrix(aMatrix);
181 my1DActor->PickableOff();
182 my1DActor->SetHighlited(true);
183 my1DActor->SetProperty(myEdgeProp);
184 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
185 aFilter = my1DActor->GetExtractUnstructuredGrid();
186 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
187 aFilter->RegisterCellsWithType(VTK_LINE);
189 my1DProp = vtkProperty::New();
190 my1DProp->DeepCopy(myEdgeProp);
191 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
192 my1DProp->SetPointSize(aPointSize);
194 my1DExtProp = vtkProperty::New();
195 my1DExtProp->DeepCopy(myEdgeProp);
196 anRGB[0] = 1 - anRGB[0];
197 anRGB[1] = 1 - anRGB[1];
198 anRGB[2] = 1 - anRGB[2];
199 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
200 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
201 my1DExtProp->SetPointSize(aPointSize + aPointSizeInc);
203 my1DExtActor = SMESH_DeviceActor::New();
204 my1DExtActor->SetUserMatrix(aMatrix);
205 my1DExtActor->PickableOff();
206 my1DExtActor->SetHighlited(true);
207 my1DExtActor->SetVisibility(false);
208 my1DExtActor->SetProperty(my1DExtProp);
209 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
210 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
211 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
212 aFilter->RegisterCellsWithType(VTK_LINE);
215 //Definition 0D divice of the actor
216 //---------------------------------
217 myNodeProp = vtkProperty::New();
218 anRGB[0] = SMESH::GetFloat("SMESH:SettingsNodeColorRed",255)/255.;
219 anRGB[1] = SMESH::GetFloat("SMESH:SettingsNodeColorGreen",0)/255.;
220 anRGB[2] = SMESH::GetFloat("SMESH:SettingsNodeColorBlue",0)/255.;
221 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
222 myNodeProp->SetPointSize(aPointSize);
224 myNodeActor = SMESH_DeviceActor::New();
225 myNodeActor->SetUserMatrix(aMatrix);
226 myNodeActor->SetStoreClippingMapping(true);
227 myNodeActor->PickableOff();
228 myNodeActor->SetVisibility(false);
229 myNodeActor->SetProperty(myNodeProp);
230 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
231 aFilter = myNodeActor->GetExtractUnstructuredGrid();
232 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
235 //Definition of Pickable and Highlitable engines
236 //----------------------------------------------
238 myBaseActor = SMESH_DeviceActor::New();
239 myBaseActor->SetUserMatrix(aMatrix);
240 myBaseActor->SetStoreGemetryMapping(true);
241 myBaseActor->GetProperty()->SetOpacity(0.0);
243 myPickableActor = myBaseActor;
245 myHighlightProp = vtkProperty::New();
246 myHighlightProp->SetAmbient(1.0);
247 myHighlightProp->SetDiffuse(0.0);
248 myHighlightProp->SetSpecular(0.0);
249 anRGB[0] = SMESH::GetFloat("SMESH:SettingsSelectColorRed", 255)/255.; // 1;
250 anRGB[1] = SMESH::GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1;
251 anRGB[2] = SMESH::GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.; // 1;
252 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
253 myHighlightProp->SetPointSize(aPointSize);
254 myHighlightProp->SetRepresentation(1);
256 myPreselectProp = vtkProperty::New();
257 myPreselectProp->SetAmbient(1.0);
258 myPreselectProp->SetDiffuse(0.0);
259 myPreselectProp->SetSpecular(0.0);
260 anRGB[0] = SMESH::GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.; // 0;
261 anRGB[1] = SMESH::GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1;
262 anRGB[2] = SMESH::GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.; // 1;
263 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
264 myPreselectProp->SetPointSize(aPointSize);
265 myPreselectProp->SetRepresentation(1);
267 myHighlitableActor = SMESH_DeviceActor::New();
268 myHighlitableActor->SetUserMatrix(aMatrix);
269 myHighlitableActor->PickableOff();
270 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
272 SetShrinkFactor(SMESH::GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.);
277 myControlMode = eNone;
278 myControlActor = my2DActor;
280 //Definition of myScalarBarActor
281 //------------------------------
282 myLookupTable = vtkLookupTable::New();
283 //Fix for Bug PAL5195 - SMESH764:
284 //Controls - Aspect Ratio: incorrect colors of the best and worst values
285 myLookupTable->SetHueRange(0.667,0.0);
287 myScalarBarActor = vtkScalarBarActor::New();
288 myScalarBarActor->SetVisibility(false);
289 myScalarBarActor->SetLookupTable(myLookupTable);
291 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
293 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
297 QColor aTColor = mgr->colorValue( "ScalarBarTitleColor", "SMESH", QColor( 255, 255, 255 ) );
298 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
300 aScalarBarTitleProp->SetFontFamilyToArial();
302 if( mgr->hasValue( "ScalarBarTitleFont", "SMESH" ) ){
303 QString str = mgr->stringValue( "ScalarBarTitleFont", "SMESH" );
304 if ( str == "Arial" )
305 aScalarBarTitleProp->SetFontFamilyToArial();
306 else if ( str == "Courier" )
307 aScalarBarTitleProp->SetFontFamilyToCourier();
308 else if ( str == "Times" )
309 aScalarBarTitleProp->SetFontFamilyToTimes();
312 if ( mgr->stringValue( "ScalarBarTitleBold", "SMESH" ) == "true" )
313 aScalarBarTitleProp->BoldOn();
315 aScalarBarTitleProp->BoldOff();
317 if ( mgr->stringValue( "ScalarBarTitleItalic", "SMESH" ) == "true" )
318 aScalarBarTitleProp->ItalicOn();
320 aScalarBarTitleProp->ItalicOff();
322 if ( mgr->stringValue( "ScalarBarTitleShadow", "SMESH" ) == "true" )
323 aScalarBarTitleProp->ShadowOn();
325 aScalarBarTitleProp->ShadowOff();
327 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
328 aScalarBarTitleProp->Delete();
330 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
332 aTColor = mgr->colorValue( "ScalarBarLabelColor", "SMESH", QColor( 255, 255, 255 ) );
333 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
335 aScalarBarLabelProp->SetFontFamilyToArial();
336 if( mgr->hasValue( "ScalarBarLabelFont", "SMESH" ) )
338 QString str = mgr->stringValue( "ScalarBarLabelFont", "SMESH" );
340 aScalarBarLabelProp->SetFontFamilyToArial();
341 else if( str == "Courier" )
342 aScalarBarLabelProp->SetFontFamilyToCourier();
343 else if( str == "Times" )
344 aScalarBarLabelProp->SetFontFamilyToTimes();
347 if( mgr->stringValue( "ScalarBarLabelBold", "SMESH" ) == "true" )
348 aScalarBarLabelProp->BoldOn();
350 aScalarBarLabelProp->BoldOff();
352 if ( mgr->stringValue( "ScalarBarLabelItalic", "SMESH" ) == "true" )
353 aScalarBarLabelProp->ItalicOn();
355 aScalarBarLabelProp->ItalicOff();
357 if( mgr->stringValue( "ScalarBarLabelShadow", "SMESH" ) == "true" )
358 aScalarBarLabelProp->ShadowOn();
360 aScalarBarLabelProp->ShadowOff();
362 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
363 aScalarBarLabelProp->Delete();
365 if( mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" )
366 myScalarBarActor->SetOrientationToHorizontal();
368 myScalarBarActor->SetOrientationToVertical();
370 float aXVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.20 : 0.01;
371 if( mgr->hasValue( "ScalarBarXPosition", "SMESH" ) )
372 aXVal = mgr->doubleValue( "ScalarBarXPosition", "SMESH", aXVal );
373 float aYVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.01 : 0.1;
374 if( mgr->hasValue( "ScalarBarYPosition", "SMESH" ) )
375 aYVal = mgr->doubleValue( "ScalarBarYPosition", "SMESH", aYVal );
376 myScalarBarActor->SetPosition( aXVal, aYVal );
378 float aWVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.60 : 0.10;
379 if( mgr->hasValue( "ScalarBarWidth", "SMESH" ) )
380 aWVal = mgr->doubleValue( "ScalarBarWidth", "SMESH", aWVal );
381 myScalarBarActor->SetWidth( aWVal );
383 float aHVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.12 : 0.80;
384 if( mgr->hasValue( "ScalarBarHeight", "SMESH" ) )
385 aHVal = mgr->doubleValue( "ScalarBarHeight", "SMESH", aHVal );
386 myScalarBarActor->SetHeight( aHVal );
389 if( mgr->hasValue( "ScalarBarNbOfLabels", "SMESH" ) )
390 anIntVal = mgr->integerValue( "ScalarBarNbOfLabels", "SMESH", anIntVal );
391 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
394 if( mgr->hasValue( "ScalarBarNbOfColors", "SMESH" ) )
395 anIntVal = mgr->integerValue( "ScalarBarNbOfColors", "SMESH", anIntVal );
396 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
399 //Definition of points numbering pipeline
400 //---------------------------------------
401 myPointsNumDataSet = vtkUnstructuredGrid::New();
403 myPtsMaskPoints = vtkMaskPoints::New();
404 myPtsMaskPoints->SetInput(myPointsNumDataSet);
405 myPtsMaskPoints->SetOnRatio(1);
407 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
408 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
409 myPtsSelectVisiblePoints->SelectInvisibleOff();
410 myPtsSelectVisiblePoints->SetTolerance(0.1);
412 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
413 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
414 myPtsLabeledDataMapper->SetLabelFormat("%g");
415 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
417 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
418 aPtsTextProp->SetFontFamilyToTimes();
419 static int aPointsFontSize = 10;
420 aPtsTextProp->SetFontSize(aPointsFontSize);
421 aPtsTextProp->SetBold(1);
422 aPtsTextProp->SetItalic(0);
423 aPtsTextProp->SetShadow(0);
424 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
425 aPtsTextProp->Delete();
427 myEntityMode = eAllEntity;
429 myIsPointsLabeled = false;
431 myPointLabels = vtkActor2D::New();
432 myPointLabels->SetMapper(myPtsLabeledDataMapper);
433 myPointLabels->GetProperty()->SetColor(1,1,1);
434 myPointLabels->SetVisibility(myIsPointsLabeled);
437 //Definition of cells numbering pipeline
438 //---------------------------------------
439 myCellsNumDataSet = vtkUnstructuredGrid::New();
441 myCellCenters = vtkCellCenters::New();
442 myCellCenters->SetInput(myCellsNumDataSet);
444 myClsMaskPoints = vtkMaskPoints::New();
445 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
446 myClsMaskPoints->SetOnRatio(1);
448 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
449 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
450 myClsSelectVisiblePoints->SelectInvisibleOff();
451 myClsSelectVisiblePoints->SetTolerance(0.1);
453 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
454 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
455 myClsLabeledDataMapper->SetLabelFormat("%g");
456 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
458 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
459 aClsTextProp->SetFontFamilyToTimes();
460 static int aCellsFontSize = 12;
461 aClsTextProp->SetFontSize(aCellsFontSize);
462 aClsTextProp->SetBold(1);
463 aClsTextProp->SetItalic(0);
464 aClsTextProp->SetShadow(0);
465 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
466 aClsTextProp->Delete();
468 myIsCellsLabeled = false;
470 myCellsLabels = vtkActor2D::New();
471 myCellsLabels->SetMapper(myClsLabeledDataMapper);
472 myCellsLabels->GetProperty()->SetColor(0,1,0);
473 myCellsLabels->SetVisibility(myIsCellsLabeled);
476 myImplicitBoolean = vtkImplicitBoolean::New();
477 myImplicitBoolean->SetOperationTypeToIntersection();
481 SMESH_ActorDef::~SMESH_ActorDef()
483 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
485 myScalarBarActor->Delete();
486 myLookupTable->Delete();
488 mySurfaceProp->Delete();
489 myBackSurfaceProp->Delete();
491 myEdgeProp->Delete();
492 myHighlightProp->Delete();
493 myPreselectProp->Delete();
495 myNodeProp->Delete();
500 my1DExtProp->Delete();
501 my1DExtActor->Delete();
506 myNodeActor->Delete();
507 myBaseActor->Delete();
509 myHighlitableActor->Delete();
511 //Deleting of pints numbering pipeline
512 //---------------------------------------
513 myPointsNumDataSet->Delete();
515 myPtsLabeledDataMapper->RemoveAllInputs();
516 myPtsLabeledDataMapper->Delete();
518 myPtsSelectVisiblePoints->UnRegisterAllOutputs();
519 myPtsSelectVisiblePoints->Delete();
521 myPtsMaskPoints->UnRegisterAllOutputs();
522 myPtsMaskPoints->Delete();
524 myPointLabels->Delete();
527 //Deleting of cells numbering pipeline
528 //---------------------------------------
529 myCellsNumDataSet->Delete();
531 myClsLabeledDataMapper->RemoveAllInputs();
532 myClsLabeledDataMapper->Delete();
534 myClsSelectVisiblePoints->UnRegisterAllOutputs();
535 myClsSelectVisiblePoints->Delete();
537 myClsMaskPoints->UnRegisterAllOutputs();
538 myClsMaskPoints->Delete();
540 myCellCenters->UnRegisterAllOutputs();
541 myCellCenters->Delete();
543 myCellsLabels->Delete();
545 myImplicitBoolean->Delete();
547 myTimeStamp->Delete();
551 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
553 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
554 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
556 if ( myIsPointsLabeled )
558 myPointsNumDataSet->ShallowCopy(aGrid);
559 vtkDataSet *aDataSet = myPointsNumDataSet;
561 int aNbElem = aDataSet->GetNumberOfPoints();
563 vtkIntArray *anArray = vtkIntArray::New();
564 anArray->SetNumberOfValues( aNbElem );
566 for ( int anId = 0; anId < aNbElem; anId++ )
568 int aSMDSId = myVisualObj->GetNodeObjId( anId );
569 anArray->SetValue( anId, aSMDSId );
572 aDataSet->GetPointData()->SetScalars( anArray );
574 myPtsMaskPoints->SetInput( aDataSet );
575 myPointLabels->SetVisibility( GetVisibility() );
579 myPointLabels->SetVisibility( false );
581 SetRepresentation(GetRepresentation());
582 myTimeStamp->Modified();
586 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
588 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
589 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
590 if(myIsCellsLabeled){
591 myCellsNumDataSet->ShallowCopy(aGrid);
592 vtkDataSet *aDataSet = myCellsNumDataSet;
593 int aNbElem = aDataSet->GetNumberOfCells();
594 vtkIntArray *anArray = vtkIntArray::New();
595 anArray->SetNumberOfValues(aNbElem);
596 for(int anId = 0; anId < aNbElem; anId++){
597 int aSMDSId = myVisualObj->GetElemObjId(anId);
598 anArray->SetValue(anId,aSMDSId);
600 aDataSet->GetCellData()->SetScalars(anArray);
601 myCellCenters->SetInput(aDataSet);
602 myCellsLabels->SetVisibility(GetVisibility());
604 myCellsLabels->SetVisibility(false);
606 myTimeStamp->Modified();
612 SetControlMode(eControl theMode)
614 SetControlMode(theMode,true);
620 SetControlMode(eControl theMode,
621 bool theCheckEntityMode)
623 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
627 myControlMode = eNone;
628 theCheckEntityMode &= mgr->stringValue( "DispayEntity", "SMESH" ) == "true";
630 my1DActor->GetMapper()->SetScalarVisibility(false);
631 my2DActor->GetMapper()->SetScalarVisibility(false);
632 my3DActor->GetMapper()->SetScalarVisibility(false);
633 myScalarBarActor->SetVisibility(false);
635 bool anIsScalarVisible = theMode > eNone;
637 if(anIsScalarVisible){
638 SMESH::Controls::FunctorPtr aFunctor;
642 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
643 aControl->SetPrecision( myControlsPrecision );
644 aFunctor.reset( aControl );
645 myControlActor = my1DActor;
650 aFunctor.reset(new SMESH::Controls::Length2D());
651 myControlActor = my2DActor;
655 aFunctor.reset(new SMESH::Controls::FreeBorders());
656 myControlActor = my1DActor;
659 aFunctor.reset(new SMESH::Controls::FreeEdges());
660 myControlActor = my2DActor;
662 case eMultiConnection:
663 aFunctor.reset(new SMESH::Controls::MultiConnection());
664 myControlActor = my1DActor;
666 case eMultiConnection2D:
667 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
668 myControlActor = my2DActor;
672 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
673 aControl->SetPrecision( myControlsPrecision );
674 aFunctor.reset( aControl );
675 myControlActor = my2DActor;
680 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
681 aControl->SetPrecision( myControlsPrecision );
682 aFunctor.reset( aControl );
683 myControlActor = my2DActor;
688 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
689 aControl->SetPrecision( myControlsPrecision );
690 aFunctor.reset( aControl );
691 myControlActor = my2DActor;
696 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
697 aControl->SetPrecision( myControlsPrecision );
698 aFunctor.reset( aControl );
699 myControlActor = my3DActor;
704 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
705 aControl->SetPrecision( myControlsPrecision );
706 aFunctor.reset( aControl );
707 myControlActor = my2DActor;
712 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
713 aControl->SetPrecision( myControlsPrecision );
714 aFunctor.reset( aControl );
715 myControlActor = my2DActor;
720 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
721 aControl->SetPrecision( myControlsPrecision );
722 aFunctor.reset( aControl );
723 myControlActor = my2DActor;
730 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
731 vtkIdType aNbCells = aGrid->GetNumberOfCells();
733 myControlMode = theMode;
734 switch(myControlMode){
737 my1DExtActor->SetExtControlMode(aFunctor);
740 case eMultiConnection2D:
741 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
744 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
748 if(theCheckEntityMode){
749 if(myControlActor == my1DActor)
750 SetEntityMode(eEdges);
751 else if(myControlActor == my2DActor){
752 switch(myControlMode){
755 case eMultiConnection2D:
756 //SetEntityMode(eEdges);
757 SetEntityMode(eFaces);
760 SetEntityMode(eFaces);
762 }else if(myControlActor == my3DActor)
763 SetEntityMode(eVolumes);
766 }else if(theCheckEntityMode){
767 myEntityMode = eAllEntity;
770 SetRepresentation(GetRepresentation());
772 myTimeStamp->Modified();
777 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
778 SALOME_Actor::AddToRender(theRenderer);
780 theRenderer->AddActor(myNodeActor);
781 theRenderer->AddActor(myBaseActor);
783 theRenderer->AddActor(my3DActor);
784 theRenderer->AddActor(my2DActor);
786 theRenderer->AddActor(my1DActor);
787 theRenderer->AddActor(my1DExtActor);
789 theRenderer->AddActor(myHighlitableActor);
791 theRenderer->AddActor2D(myScalarBarActor);
793 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
794 myClsSelectVisiblePoints->SetRenderer(theRenderer);
796 theRenderer->AddActor2D(myPointLabels);
797 theRenderer->AddActor2D(myCellsLabels);
800 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
801 SALOME_Actor::RemoveFromRender(theRenderer);
803 theRenderer->RemoveActor(myNodeActor);
804 theRenderer->RemoveActor(myBaseActor);
806 theRenderer->RemoveActor(myHighlitableActor);
808 theRenderer->RemoveActor(my1DActor);
809 theRenderer->RemoveActor(my1DExtActor);
811 theRenderer->RemoveActor(my2DActor);
812 theRenderer->RemoveActor(my3DActor);
814 theRenderer->RemoveActor(myScalarBarActor);
815 theRenderer->RemoveActor(myPointLabels);
816 theRenderer->RemoveActor(myCellsLabels);
820 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
821 const char* theEntry,
825 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
829 myVisualObj = theVisualObj;
830 myVisualObj->Update(theIsClear);
832 myNodeActor->Init(myVisualObj,myImplicitBoolean);
833 myBaseActor->Init(myVisualObj,myImplicitBoolean);
835 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
837 my1DActor->Init(myVisualObj,myImplicitBoolean);
838 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
840 my2DActor->Init(myVisualObj,myImplicitBoolean);
841 my3DActor->Init(myVisualObj,myImplicitBoolean);
843 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
844 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
846 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
847 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
849 float aFactor, aUnits;
850 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
851 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
853 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
854 SetIsShrunkable(true);
856 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
860 QString aMode = mgr->stringValue( "DisplayMode", "SMESH" );
861 SetRepresentation(-1);
863 if(aMode.compare("Wireframe") == 0){
864 SetRepresentation(eEdge);
865 }else if(aMode.compare("Shading") == 0){
866 SetRepresentation(eSurface);
867 }else if(aMode.compare("Nodes") == 0){
868 SetRepresentation(ePoint);
871 aMode = mgr->stringValue( "Shrink", "SMESH" );
876 myTimeStamp->Modified();
882 float* SMESH_ActorDef::GetBounds(){
883 return myNodeActor->GetBounds();
887 vtkDataSet* SMESH_ActorDef::GetInput(){
888 return GetUnstructuredGrid();
892 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
893 myNodeActor->SetTransform(theTransform);
894 myBaseActor->SetTransform(theTransform);
896 myHighlitableActor->SetTransform(theTransform);
898 my1DActor->SetTransform(theTransform);
899 my1DExtActor->SetTransform(theTransform);
901 my2DActor->SetTransform(theTransform);
902 my3DActor->SetTransform(theTransform);
908 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
909 vtkLODActor::SetMapper(theMapper);
913 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
914 SALOME_Actor::ShallowCopy(prop);
918 vtkMapper* SMESH_ActorDef::GetMapper(){
919 return myPickableActor->GetMapper();
923 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
924 return myVisualObj->GetUnstructuredGrid();
928 bool SMESH_ActorDef::IsInfinitive(){
929 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
931 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
932 aDataSet->GetNumberOfCells() == 1 &&
933 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
934 return SALOME_Actor::IsInfinitive();
938 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
939 myIsShrinkable = theShrunkable;
943 float SMESH_ActorDef::GetShrinkFactor(){
944 return myBaseActor->GetShrinkFactor();
947 void SMESH_ActorDef::SetShrinkFactor(float theValue){
948 myBaseActor->SetShrinkFactor(theValue);
950 my1DActor->SetShrinkFactor(theValue);
951 my1DExtActor->SetShrinkFactor(theValue);
953 my2DActor->SetShrinkFactor(theValue);
954 my3DActor->SetShrinkFactor(theValue);
959 void SMESH_ActorDef::SetShrink(){
960 if(!myIsShrinkable) return;
962 myBaseActor->SetShrink();
964 my1DActor->SetShrink();
965 my1DExtActor->SetShrink();
967 my2DActor->SetShrink();
968 my3DActor->SetShrink();
974 void SMESH_ActorDef::UnShrink(){
975 if(!myIsShrunk) return;
977 myBaseActor->UnShrink();
979 my1DActor->UnShrink();
980 my1DExtActor->UnShrink();
982 my2DActor->UnShrink();
983 my3DActor->UnShrink();
990 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
991 return myPickableActor->GetNodeObjId(theVtkID);
994 float* SMESH_ActorDef::GetNodeCoord(int theObjID){
995 return myPickableActor->GetNodeCoord(theObjID);
999 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1000 return myPickableActor->GetElemObjId(theVtkID);
1003 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1004 return myPickableActor->GetElemCell(theObjID);
1008 void SMESH_ActorDef::SetVisibility(int theMode){
1009 SetVisibility(theMode,true);
1013 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1014 SALOME_Actor::SetVisibility(theMode);
1016 myNodeActor->VisibilityOff();
1017 myBaseActor->VisibilityOff();
1019 my1DActor->VisibilityOff();
1020 my1DExtActor->VisibilityOff();
1022 my2DActor->VisibilityOff();
1023 my3DActor->VisibilityOff();
1025 myScalarBarActor->VisibilityOff();
1026 myPointLabels->VisibilityOff();
1027 myCellsLabels->VisibilityOff();
1029 if(GetVisibility()){
1030 if(theIsUpdateRepersentation)
1031 SetRepresentation(GetRepresentation());
1033 if(myControlMode != eNone){
1034 switch(myControlMode){
1037 my1DExtActor->VisibilityOn();
1040 case eMultiConnection2D:
1041 my1DExtActor->VisibilityOn();
1043 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1044 myScalarBarActor->VisibilityOn();
1048 if(myRepresentation != ePoint)
1049 myPickableActor->VisibilityOn();
1051 myNodeActor->VisibilityOn();
1054 if(myEntityMode & eEdges){
1055 my1DActor->VisibilityOn();
1058 if(myEntityMode & eFaces){
1059 my2DActor->VisibilityOn();
1062 if(myEntityMode & eVolumes){
1063 my3DActor->VisibilityOn();
1066 if(myIsPointsLabeled){
1067 myPointLabels->VisibilityOn();
1068 myNodeActor->VisibilityOn();
1071 if(myIsCellsLabeled)
1072 myCellsLabels->VisibilityOn();
1079 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
1080 myEntityState = eAllEntity;
1082 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){
1083 myEntityState &= ~eEdges;
1087 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){
1088 myEntityState &= ~eFaces;
1092 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){
1093 myEntityState &= ~eVolumes;
1094 theMode &= ~eVolumes;
1098 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1101 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1104 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1105 theMode |= eVolumes;
1108 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1110 myEntityMode = theMode;
1111 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1112 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1113 aFilter->ClearRegisteredCellsWithType();
1114 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1116 if(myEntityMode & eEdges){
1117 if (MYDEBUG) MESSAGE("EDGES");
1118 aFilter->RegisterCellsWithType(VTK_LINE);
1121 if(myEntityMode & eFaces){
1122 if (MYDEBUG) MESSAGE("FACES");
1123 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1124 aFilter->RegisterCellsWithType(VTK_POLYGON);
1125 aFilter->RegisterCellsWithType(VTK_QUAD);
1128 if(myEntityMode & eVolumes){
1129 if (MYDEBUG) MESSAGE("VOLUMES");
1130 aFilter->RegisterCellsWithType(VTK_TETRA);
1131 aFilter->RegisterCellsWithType(VTK_VOXEL);
1132 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1133 aFilter->RegisterCellsWithType(VTK_WEDGE);
1134 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1135 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1138 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1139 SetVisibility(GetVisibility(),false);
1142 void SMESH_ActorDef::SetRepresentation(int theMode){
1143 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1144 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1145 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1147 myRepresentation = eSurface;
1148 if(!aNbFaces && !aNbVolumes && aNbEdges){
1149 myRepresentation = eEdge;
1150 }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1151 myRepresentation = ePoint;
1156 if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1159 if(!aNbFaces && !aNbVolumes) return;
1162 myRepresentation = theMode;
1165 if(!GetUnstructuredGrid()->GetNumberOfCells())
1166 myRepresentation = ePoint;
1169 if(myRepresentation == ePoint){
1177 myPickableActor = myBaseActor;
1178 myNodeActor->SetVisibility(false);
1179 vtkProperty *aProp = NULL, *aBackProp = NULL;
1180 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1181 switch(myRepresentation){
1183 myPickableActor = myNodeActor;
1184 myNodeActor->SetVisibility(true);
1186 aProp = aBackProp = myNodeProp;
1187 aReperesent = SMESH_DeviceActor::ePoint;
1190 aProp = aBackProp = myEdgeProp;
1191 aReperesent = SMESH_DeviceActor::eInsideframe;
1194 aProp = mySurfaceProp;
1195 aBackProp = myBackSurfaceProp;
1196 aReperesent = SMESH_DeviceActor::eSurface;
1200 my2DActor->SetProperty(aProp);
1201 my2DActor->SetBackfaceProperty(aBackProp);
1202 my2DActor->SetRepresentation(aReperesent);
1204 my3DActor->SetProperty(aProp);
1205 my3DActor->SetBackfaceProperty(aBackProp);
1206 my3DActor->SetRepresentation(aReperesent);
1208 my1DExtActor->SetVisibility(false);
1210 switch(myControlMode){
1212 case eMultiConnection:
1213 aProp = aBackProp = my1DProp;
1214 if(myRepresentation != ePoint)
1215 aReperesent = SMESH_DeviceActor::eInsideframe;
1219 my1DActor->SetProperty(aProp);
1220 my1DActor->SetBackfaceProperty(aBackProp);
1221 my1DActor->SetRepresentation(aReperesent);
1223 my1DExtActor->SetRepresentation(aReperesent);
1225 if(myIsPointsVisible)
1226 myPickableActor = myNodeActor;
1227 if(GetPointRepresentation())
1228 myNodeActor->SetVisibility(true);
1230 SetMapper(myPickableActor->GetMapper());
1232 SetVisibility(GetVisibility(),false);
1238 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1239 myIsPointsVisible = theIsPointsVisible;
1240 SetRepresentation(GetRepresentation());
1243 bool SMESH_ActorDef::GetPointRepresentation(){
1244 return myIsPointsVisible || myIsPointsLabeled;
1248 void SMESH_ActorDef::UpdateHighlight(){
1249 myHighlitableActor->SetVisibility(false);
1250 myHighlitableActor->SetHighlited(false);
1252 if(myIsHighlighted){
1253 myHighlitableActor->SetProperty(myHighlightProp);
1254 }else if(myIsPreselected){
1255 myHighlitableActor->SetProperty(myPreselectProp);
1258 bool anIsVisible = GetVisibility();
1260 if(myIsHighlighted || myIsPreselected){
1261 if(GetUnstructuredGrid()->GetNumberOfCells()){
1262 myHighlitableActor->SetHighlited(anIsVisible);
1263 myHighlitableActor->SetVisibility(anIsVisible);
1264 myHighlitableActor->GetExtractUnstructuredGrid()->
1265 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1266 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1267 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1268 myHighlitableActor->SetHighlited(anIsVisible);
1269 myHighlitableActor->SetVisibility(anIsVisible);
1270 myHighlitableActor->GetExtractUnstructuredGrid()->
1271 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1272 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1278 void SMESH_ActorDef::highlight(bool theHighlight){
1279 myIsHighlighted = theHighlight;
1284 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1285 myIsPreselected = thePreselect;
1291 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1293 if (myPickableActor->GetIsOpaque())
1295 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1303 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1305 if (!myPickableActor->GetIsOpaque())
1307 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1315 void SMESH_ActorDef::Render(vtkRenderer *ren){
1316 unsigned long aTime = myTimeStamp->GetMTime();
1317 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1318 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1319 if(anObjTime > aTime || aClippingTime > aTime)
1324 void SMESH_ActorDef::Update(){
1325 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1327 if(GetControlMode() != eNone) {
1328 unsigned long aTime = myTimeStamp->GetMTime();
1329 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1330 if (anObjTime > aTime)
1331 SetControlMode(GetControlMode(),false);
1333 if(myIsPointsLabeled){
1334 SetPointsLabeled(myIsPointsLabeled);
1336 if(myIsCellsLabeled){
1337 SetCellsLabeled(myIsCellsLabeled);
1339 SetEntityMode(GetEntityMode());
1340 SetVisibility(GetVisibility());
1342 myTimeStamp->Modified();
1347 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1348 SALOME_Actor::ReleaseGraphicsResources(renWin);
1350 myPickableActor->ReleaseGraphicsResources(renWin);
1354 static void GetColor(vtkProperty *theProperty, float& r,float& g,float& b){
1355 float* aColor = theProperty->GetColor();
1362 void SMESH_ActorDef::SetOpacity(float theValue){
1363 mySurfaceProp->SetOpacity(theValue);
1364 myBackSurfaceProp->SetOpacity(theValue);
1365 myEdgeProp->SetOpacity(theValue);
1366 myNodeProp->SetOpacity(theValue);
1368 my1DProp->SetOpacity(theValue);
1372 float SMESH_ActorDef::GetOpacity(){
1373 return mySurfaceProp->GetOpacity();
1377 void SMESH_ActorDef::SetSufaceColor(float r,float g,float b){
1378 mySurfaceProp->SetColor(r,g,b);
1382 void SMESH_ActorDef::GetSufaceColor(float& r,float& g,float& b){
1383 ::GetColor(mySurfaceProp,r,g,b);
1386 void SMESH_ActorDef::SetBackSufaceColor(float r,float g,float b){
1387 myBackSurfaceProp->SetColor(r,g,b);
1391 void SMESH_ActorDef::GetBackSufaceColor(float& r,float& g,float& b){
1392 ::GetColor(myBackSurfaceProp,r,g,b);
1395 void SMESH_ActorDef::SetEdgeColor(float r,float g,float b){
1396 myEdgeProp->SetColor(r,g,b);
1397 my1DProp->SetColor(r,g,b);
1398 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1402 void SMESH_ActorDef::GetEdgeColor(float& r,float& g,float& b){
1403 ::GetColor(myEdgeProp,r,g,b);
1406 void SMESH_ActorDef::SetNodeColor(float r,float g,float b){
1407 myNodeProp->SetColor(r,g,b);
1411 void SMESH_ActorDef::GetNodeColor(float& r,float& g,float& b){
1412 ::GetColor(myNodeProp,r,g,b);
1415 void SMESH_ActorDef::SetHighlightColor(float r,float g,float b){
1416 myHighlightProp->SetColor(r,g,b);
1420 void SMESH_ActorDef::GetHighlightColor(float& r,float& g,float& b){
1421 ::GetColor(myHighlightProp,r,g,b);
1424 void SMESH_ActorDef::SetPreHighlightColor(float r,float g,float b){
1425 myPreselectProp->SetColor(r,g,b);
1429 void SMESH_ActorDef::GetPreHighlightColor(float& r,float& g,float& b){
1430 ::GetColor(myPreselectProp,r,g,b);
1434 float SMESH_ActorDef::GetLineWidth(){
1435 return myEdgeProp->GetLineWidth();
1439 void SMESH_ActorDef::SetLineWidth(float theVal){
1440 myEdgeProp->SetLineWidth(theVal);
1442 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1443 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1449 void SMESH_ActorDef::SetNodeSize(float theVal){
1450 myNodeProp->SetPointSize(theVal);
1451 myHighlightProp->SetPointSize(theVal);
1452 myPreselectProp->SetPointSize(theVal);
1454 my1DProp->SetPointSize(theVal + aPointSizeInc);
1455 my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1460 float SMESH_ActorDef::GetNodeSize(){
1461 return myNodeProp->GetPointSize();
1464 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1466 return myVisualObj->GetElemDimension( theObjId );
1471 IsImplicitFunctionUsed() const
1473 return myBaseActor->IsImplicitFunctionUsed();
1478 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1480 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1481 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1483 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1485 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1486 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1488 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1489 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1494 AddClippingPlane(vtkPlane* thePlane)
1497 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1498 myCippingPlaneCont.push_back(thePlane);
1499 if(!IsImplicitFunctionUsed())
1500 SetImplicitFunctionUsed(true);
1502 return myCippingPlaneCont.size();
1507 RemoveAllClippingPlanes()
1509 myImplicitBoolean->GetFunction()->RemoveAllItems();
1510 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1511 myCippingPlaneCont.clear();
1512 SetImplicitFunctionUsed(false);
1517 GetNumberOfClippingPlanes()
1519 return myCippingPlaneCont.size();
1524 GetClippingPlane(vtkIdType theID)
1526 if(theID >= myCippingPlaneCont.size())
1528 return myCippingPlaneCont[theID].Get();
1532 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1533 float theDirection[3], float theMinPnt[3],
1534 float& theMaxBoundPrj, float& theMinBoundPrj)
1537 theDataSet->GetBounds(aBounds);
1539 //Enlarge bounds in order to avoid conflicts of precision
1540 for(int i = 0; i < 6; i += 2){
1541 static double EPS = 1.0E-3;
1542 float aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1543 aBounds[i] -= aDelta;
1544 aBounds[i+1] += aDelta;
1547 float aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1548 {aBounds[1],aBounds[2],aBounds[4]},
1549 {aBounds[0],aBounds[3],aBounds[4]},
1550 {aBounds[1],aBounds[3],aBounds[4]},
1551 {aBounds[0],aBounds[2],aBounds[5]},
1552 {aBounds[1],aBounds[2],aBounds[5]},
1553 {aBounds[0],aBounds[3],aBounds[5]},
1554 {aBounds[1],aBounds[3],aBounds[5]}};
1556 int aMaxId = 0, aMinId = aMaxId;
1557 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1558 theMinBoundPrj = theMaxBoundPrj;
1559 for(int i = 1; i < 8; i++){
1560 float aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1561 if(theMaxBoundPrj < aTmp){
1562 theMaxBoundPrj = aTmp;
1565 if(theMinBoundPrj > aTmp){
1566 theMinBoundPrj = aTmp;
1570 float *aMinPnt = aBoundPoints[aMaxId];
1571 theMinPnt[0] = aMinPnt[0];
1572 theMinPnt[1] = aMinPnt[1];
1573 theMinPnt[2] = aMinPnt[2];
1577 static void DistanceToPosition(vtkDataSet* theDataSet,
1578 float theDirection[3], float theDist, float thePos[3])
1580 float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1581 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1582 float aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1583 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1584 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1585 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1589 static void PositionToDistance(vtkDataSet* theDataSet,
1590 float theDirection[3], float thePos[3], float& theDist)
1592 float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1593 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1594 float aPrj = vtkMath::Dot(theDirection,thePos);
1595 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1599 void SMESH_ActorDef::SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane)
1601 thePlane->SetNormal(theDir);
1603 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1604 thePlane->SetOrigin(anOrigin);
1608 void SMESH_ActorDef::GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane)
1610 thePlane->GetNormal(theDir);
1613 thePlane->GetOrigin(anOrigin);
1614 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);