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 "SALOME_ExtractUnstructuredGrid.h"
36 #include "QAD_Config.h"
37 #include <qstringlist.h>
39 #include <vtkTimeStamp.h>
40 #include <vtkObjectFactory.h>
41 #include <vtkShrinkPolyData.h>
42 #include <vtkMergeFilter.h>
44 #include <vtkMatrix4x4.h>
45 #include <vtkUnstructuredGrid.h>
46 #include <vtkPointData.h>
47 #include <vtkCellData.h>
49 #include <vtkMapper.h>
50 #include <vtkRenderer.h>
53 #include <vtkIdList.h>
54 #include <vtkIntArray.h>
56 #include <vtkActor2D.h>
57 #include <vtkProperty2D.h>
58 #include <vtkPolyData.h>
59 #include <vtkMaskPoints.h>
60 #include <vtkCellCenters.h>
61 #include <vtkTextProperty.h>
62 #include <vtkLabeledDataMapper.h>
63 #include <vtkSelectVisiblePoints.h>
65 #include <vtkScalarBarActor.h>
66 #include <vtkLookupTable.h>
70 #include <vtkImplicitBoolean.h>
71 #include <vtkImplicitFunctionCollection.h>
73 #include "utilities.h"
76 static int MYDEBUG = 0;
78 static int MYDEBUG = 0;
81 static int aLineWidthInc = 2;
82 static int aPointSizeInc = 2;
85 SMESH_ActorDef* SMESH_ActorDef::New(){
86 return new SMESH_ActorDef();
90 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
95 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
96 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
104 SMESH_ActorDef::SMESH_ActorDef()
106 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
108 myTimeStamp = vtkTimeStamp::New();
110 myIsPointsVisible = false;
112 myIsShrinkable = false;
115 myControlsPrecision = (long)SMESH::GetFloat( "SMESH:ControlsPrecision", -1 );
117 float aPointSize = SMESH::GetFloat("SMESH:SettingsNodesSize",3);
118 float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1);
120 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
121 SALOME_ExtractUnstructuredGrid* aFilter = NULL;
123 //Definition 2D and 3D divices of the actor
124 //-----------------------------------------
125 float anRGB[3] = {1,1,1};
126 mySurfaceProp = vtkProperty::New();
127 anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
128 anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
129 anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
130 mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
132 myBackSurfaceProp = vtkProperty::New();
133 anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
134 anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
135 anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
136 myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
138 my2DActor = SMESH_DeviceActor::New();
139 my2DActor->SetUserMatrix(aMatrix);
140 my2DActor->PickableOff();
141 my2DActor->SetProperty(mySurfaceProp);
142 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
143 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
144 aFilter = my2DActor->GetExtractUnstructuredGrid();
145 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
146 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
147 aFilter->RegisterCellsWithType(VTK_POLYGON);
148 aFilter->RegisterCellsWithType(VTK_QUAD);
150 my3DActor = SMESH_DeviceActor::New();
151 my3DActor->SetUserMatrix(aMatrix);
152 my3DActor->PickableOff();
153 my3DActor->SetProperty(mySurfaceProp);
154 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
155 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
156 aFilter = my3DActor->GetExtractUnstructuredGrid();
157 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
158 aFilter->RegisterCellsWithType(VTK_TETRA);
159 aFilter->RegisterCellsWithType(VTK_VOXEL);
160 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
161 aFilter->RegisterCellsWithType(VTK_WEDGE);
162 aFilter->RegisterCellsWithType(VTK_PYRAMID);
165 //Definition 1D divice of the actor
166 //---------------------------------
167 myEdgeProp = vtkProperty::New();
168 myEdgeProp->SetAmbient(1.0);
169 myEdgeProp->SetDiffuse(0.0);
170 myEdgeProp->SetSpecular(0.0);
171 anRGB[0] = SMESH::GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.;
172 anRGB[1] = SMESH::GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.;
173 anRGB[2] = SMESH::GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.;
174 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
175 myEdgeProp->SetLineWidth(aLineWidth);
177 my1DActor = SMESH_DeviceActor::New();
178 my1DActor->SetUserMatrix(aMatrix);
179 my1DActor->PickableOff();
180 my1DActor->SetHighlited(true);
181 my1DActor->SetProperty(myEdgeProp);
182 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
183 aFilter = my1DActor->GetExtractUnstructuredGrid();
184 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
185 aFilter->RegisterCellsWithType(VTK_LINE);
187 my1DProp = vtkProperty::New();
188 my1DProp->DeepCopy(myEdgeProp);
189 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
190 my1DProp->SetPointSize(aPointSize);
192 my1DExtProp = vtkProperty::New();
193 my1DExtProp->DeepCopy(myEdgeProp);
194 anRGB[0] = 1 - anRGB[0];
195 anRGB[1] = 1 - anRGB[1];
196 anRGB[2] = 1 - anRGB[2];
197 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
198 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
199 my1DExtProp->SetPointSize(aPointSize + aPointSizeInc);
201 my1DExtActor = SMESH_DeviceActor::New();
202 my1DExtActor->SetUserMatrix(aMatrix);
203 my1DExtActor->PickableOff();
204 my1DExtActor->SetHighlited(true);
205 my1DExtActor->SetVisibility(false);
206 my1DExtActor->SetProperty(my1DExtProp);
207 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
208 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
209 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
210 aFilter->RegisterCellsWithType(VTK_LINE);
213 //Definition 0D divice of the actor
214 //---------------------------------
215 myNodeProp = vtkProperty::New();
216 anRGB[0] = SMESH::GetFloat("SMESH:SettingsNodeColorRed",255)/255.;
217 anRGB[1] = SMESH::GetFloat("SMESH:SettingsNodeColorGreen",0)/255.;
218 anRGB[2] = SMESH::GetFloat("SMESH:SettingsNodeColorBlue",0)/255.;
219 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
220 myNodeProp->SetPointSize(aPointSize);
222 myNodeActor = SMESH_DeviceActor::New();
223 myNodeActor->SetUserMatrix(aMatrix);
224 myNodeActor->SetStoreClippingMapping(true);
225 myNodeActor->PickableOff();
226 myNodeActor->SetVisibility(false);
227 myNodeActor->SetProperty(myNodeProp);
228 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
229 aFilter = myNodeActor->GetExtractUnstructuredGrid();
230 aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints);
233 //Definition of Pickable and Highlitable engines
234 //----------------------------------------------
236 myBaseActor = SMESH_DeviceActor::New();
237 myBaseActor->SetUserMatrix(aMatrix);
238 myBaseActor->SetStoreGemetryMapping(true);
239 myBaseActor->GetProperty()->SetOpacity(0.0);
241 myPickableActor = myBaseActor;
243 myHighlightProp = vtkProperty::New();
244 myHighlightProp->SetAmbient(1.0);
245 myHighlightProp->SetDiffuse(0.0);
246 myHighlightProp->SetSpecular(0.0);
247 anRGB[0] = SMESH::GetFloat("SMESH:SettingsSelectColorRed", 255)/255.; // 1;
248 anRGB[1] = SMESH::GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1;
249 anRGB[2] = SMESH::GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.; // 1;
250 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
251 myHighlightProp->SetPointSize(aPointSize);
252 myHighlightProp->SetRepresentation(1);
254 myPreselectProp = vtkProperty::New();
255 myPreselectProp->SetAmbient(1.0);
256 myPreselectProp->SetDiffuse(0.0);
257 myPreselectProp->SetSpecular(0.0);
258 anRGB[0] = SMESH::GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.; // 0;
259 anRGB[1] = SMESH::GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1;
260 anRGB[2] = SMESH::GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.; // 1;
261 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
262 myPreselectProp->SetPointSize(aPointSize);
263 myPreselectProp->SetRepresentation(1);
265 myHighlitableActor = SMESH_DeviceActor::New();
266 myHighlitableActor->SetUserMatrix(aMatrix);
267 myHighlitableActor->PickableOff();
268 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
270 SetShrinkFactor(SMESH::GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.);
275 myControlMode = eNone;
276 myControlActor = my2DActor;
278 //Definition of myScalarBarActor
279 //------------------------------
280 myLookupTable = vtkLookupTable::New();
281 //Fix for Bug PAL5195 - SMESH764:
282 //Controls - Aspect Ratio: incorrect colors of the best and worst values
283 myLookupTable->SetHueRange(0.667,0.0);
285 myScalarBarActor = vtkScalarBarActor::New();
286 myScalarBarActor->SetVisibility(false);
287 myScalarBarActor->SetLookupTable(myLookupTable);
289 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
291 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
292 QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
293 aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
294 ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ),
295 ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
298 aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 );
300 aScalarBarTitleProp->SetFontFamilyToArial();
301 if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){
302 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
303 aScalarBarTitleProp->SetFontFamilyToArial();
304 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
305 aScalarBarTitleProp->SetFontFamilyToCourier();
306 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
307 aScalarBarTitleProp->SetFontFamilyToTimes();
310 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" )
311 aScalarBarTitleProp->BoldOn();
313 aScalarBarTitleProp->BoldOff();
315 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" )
316 aScalarBarTitleProp->ItalicOn();
318 aScalarBarTitleProp->ItalicOff();
320 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" )
321 aScalarBarTitleProp->ShadowOn();
323 aScalarBarTitleProp->ShadowOff();
325 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
326 aScalarBarTitleProp->Delete();
328 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
330 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
331 QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
332 aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
333 ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ),
334 ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
337 aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 );
339 aScalarBarLabelProp->SetFontFamilyToArial();
340 if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){
341 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
342 aScalarBarLabelProp->SetFontFamilyToArial();
343 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
344 aScalarBarLabelProp->SetFontFamilyToCourier();
345 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
346 aScalarBarLabelProp->SetFontFamilyToTimes();
349 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" )
350 aScalarBarLabelProp->BoldOn();
352 aScalarBarLabelProp->BoldOff();
354 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" )
355 aScalarBarLabelProp->ItalicOn();
357 aScalarBarLabelProp->ItalicOff();
359 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" )
360 aScalarBarLabelProp->ShadowOn();
362 aScalarBarLabelProp->ShadowOff();
364 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
365 aScalarBarLabelProp->Delete();
367 if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" )
368 myScalarBarActor->SetOrientationToHorizontal();
370 myScalarBarActor->SetOrientationToVertical();
372 float aXVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01;
373 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
374 aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat();
375 float aYVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1;
376 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
377 aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat();
378 myScalarBarActor->SetPosition( aXVal, aYVal );
380 float aWVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10;
381 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
382 aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat();
383 myScalarBarActor->SetWidth( aWVal );
385 float aHVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80;
386 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
387 aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat();
388 myScalarBarActor->SetHeight( aHVal );
391 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
392 anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt();
393 myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal);
396 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
397 anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt();
398 myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal);
401 //Definition of points numbering pipeline
402 //---------------------------------------
403 myPointsNumDataSet = vtkUnstructuredGrid::New();
405 myPtsMaskPoints = vtkMaskPoints::New();
406 myPtsMaskPoints->SetInput(myPointsNumDataSet);
407 myPtsMaskPoints->SetOnRatio(1);
409 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
410 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
411 myPtsSelectVisiblePoints->SelectInvisibleOff();
412 myPtsSelectVisiblePoints->SetTolerance(0.1);
414 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
415 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
416 myPtsLabeledDataMapper->SetLabelFormat("%g");
417 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
419 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
420 aPtsTextProp->SetFontFamilyToTimes();
421 static int aPointsFontSize = 10;
422 aPtsTextProp->SetFontSize(aPointsFontSize);
423 aPtsTextProp->SetBold(1);
424 aPtsTextProp->SetItalic(0);
425 aPtsTextProp->SetShadow(0);
426 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
427 aPtsTextProp->Delete();
429 myEntityMode = eAllEntity;
431 myIsPointsLabeled = false;
433 myPointLabels = vtkActor2D::New();
434 myPointLabels->SetMapper(myPtsLabeledDataMapper);
435 myPointLabels->GetProperty()->SetColor(1,1,1);
436 myPointLabels->SetVisibility(myIsPointsLabeled);
439 //Definition of cells numbering pipeline
440 //---------------------------------------
441 myCellsNumDataSet = vtkUnstructuredGrid::New();
443 myCellCenters = vtkCellCenters::New();
444 myCellCenters->SetInput(myCellsNumDataSet);
446 myClsMaskPoints = vtkMaskPoints::New();
447 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
448 myClsMaskPoints->SetOnRatio(1);
450 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
451 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
452 myClsSelectVisiblePoints->SelectInvisibleOff();
453 myClsSelectVisiblePoints->SetTolerance(0.1);
455 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
456 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
457 myClsLabeledDataMapper->SetLabelFormat("%g");
458 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
460 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
461 aClsTextProp->SetFontFamilyToTimes();
462 static int aCellsFontSize = 12;
463 aClsTextProp->SetFontSize(aCellsFontSize);
464 aClsTextProp->SetBold(1);
465 aClsTextProp->SetItalic(0);
466 aClsTextProp->SetShadow(0);
467 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
468 aClsTextProp->Delete();
470 myIsCellsLabeled = false;
472 myCellsLabels = vtkActor2D::New();
473 myCellsLabels->SetMapper(myClsLabeledDataMapper);
474 myCellsLabels->GetProperty()->SetColor(0,1,0);
475 myCellsLabels->SetVisibility(myIsCellsLabeled);
478 myImplicitBoolean = vtkImplicitBoolean::New();
479 myImplicitBoolean->SetOperationTypeToIntersection();
483 SMESH_ActorDef::~SMESH_ActorDef()
485 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
487 myScalarBarActor->Delete();
488 myLookupTable->Delete();
490 mySurfaceProp->Delete();
491 myBackSurfaceProp->Delete();
493 myEdgeProp->Delete();
494 myHighlightProp->Delete();
495 myPreselectProp->Delete();
497 myNodeProp->Delete();
502 my1DExtProp->Delete();
503 my1DExtActor->Delete();
508 myNodeActor->Delete();
509 myBaseActor->Delete();
511 myHighlitableActor->Delete();
513 //Deleting of pints numbering pipeline
514 //---------------------------------------
515 myPointsNumDataSet->Delete();
517 myPtsLabeledDataMapper->RemoveAllInputs();
518 myPtsLabeledDataMapper->Delete();
520 myPtsSelectVisiblePoints->UnRegisterAllOutputs();
521 myPtsSelectVisiblePoints->Delete();
523 myPtsMaskPoints->UnRegisterAllOutputs();
524 myPtsMaskPoints->Delete();
526 myPointLabels->Delete();
529 //Deleting of cells numbering pipeline
530 //---------------------------------------
531 myCellsNumDataSet->Delete();
533 myClsLabeledDataMapper->RemoveAllInputs();
534 myClsLabeledDataMapper->Delete();
536 myClsSelectVisiblePoints->UnRegisterAllOutputs();
537 myClsSelectVisiblePoints->Delete();
539 myClsMaskPoints->UnRegisterAllOutputs();
540 myClsMaskPoints->Delete();
542 myCellCenters->UnRegisterAllOutputs();
543 myCellCenters->Delete();
545 myCellsLabels->Delete();
547 myImplicitBoolean->Delete();
549 myTimeStamp->Delete();
553 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
555 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
556 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
558 if ( myIsPointsLabeled )
560 myPointsNumDataSet->ShallowCopy(aGrid);
561 vtkDataSet *aDataSet = myPointsNumDataSet;
563 int aNbElem = aDataSet->GetNumberOfPoints();
565 vtkIntArray *anArray = vtkIntArray::New();
566 anArray->SetNumberOfValues( aNbElem );
568 for ( int anId = 0; anId < aNbElem; anId++ )
570 int aSMDSId = myVisualObj->GetNodeObjId( anId );
571 anArray->SetValue( anId, aSMDSId );
574 aDataSet->GetPointData()->SetScalars( anArray );
576 myPtsMaskPoints->SetInput( aDataSet );
577 myPointLabels->SetVisibility( GetVisibility() );
581 myPointLabels->SetVisibility( false );
583 SetRepresentation(GetRepresentation());
584 myTimeStamp->Modified();
588 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
590 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
591 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
592 if(myIsCellsLabeled){
593 myCellsNumDataSet->ShallowCopy(aGrid);
594 vtkDataSet *aDataSet = myCellsNumDataSet;
595 int aNbElem = aDataSet->GetNumberOfCells();
596 vtkIntArray *anArray = vtkIntArray::New();
597 anArray->SetNumberOfValues(aNbElem);
598 for(int anId = 0; anId < aNbElem; anId++){
599 int aSMDSId = myVisualObj->GetElemObjId(anId);
600 anArray->SetValue(anId,aSMDSId);
602 aDataSet->GetCellData()->SetScalars(anArray);
603 myCellCenters->SetInput(aDataSet);
604 myCellsLabels->SetVisibility(GetVisibility());
606 myCellsLabels->SetVisibility(false);
608 myTimeStamp->Modified();
614 SetControlMode(eControl theMode)
616 SetControlMode(theMode,true);
622 SetControlMode(eControl theMode,
623 bool theCheckEntityMode)
625 myControlMode = eNone;
626 theCheckEntityMode &= QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true";
628 my1DActor->GetMapper()->SetScalarVisibility(false);
629 my2DActor->GetMapper()->SetScalarVisibility(false);
630 my3DActor->GetMapper()->SetScalarVisibility(false);
631 myScalarBarActor->SetVisibility(false);
633 bool anIsScalarVisible = theMode > eNone;
635 if(anIsScalarVisible){
636 SMESH::Controls::FunctorPtr aFunctor;
640 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
641 aControl->SetPrecision( myControlsPrecision );
642 aFunctor.reset( aControl );
643 myControlActor = my1DActor;
648 aFunctor.reset(new SMESH::Controls::Length2D());
649 myControlActor = my2DActor;
653 aFunctor.reset(new SMESH::Controls::FreeBorders());
654 myControlActor = my1DActor;
657 aFunctor.reset(new SMESH::Controls::FreeEdges());
658 myControlActor = my2DActor;
660 case eMultiConnection:
661 aFunctor.reset(new SMESH::Controls::MultiConnection());
662 myControlActor = my1DActor;
664 case eMultiConnection2D:
665 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
666 myControlActor = my2DActor;
670 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
671 aControl->SetPrecision( myControlsPrecision );
672 aFunctor.reset( aControl );
673 myControlActor = my2DActor;
678 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
679 aControl->SetPrecision( myControlsPrecision );
680 aFunctor.reset( aControl );
681 myControlActor = my2DActor;
686 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
687 aControl->SetPrecision( myControlsPrecision );
688 aFunctor.reset( aControl );
689 myControlActor = my2DActor;
694 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
695 aControl->SetPrecision( myControlsPrecision );
696 aFunctor.reset( aControl );
697 myControlActor = my3DActor;
702 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
703 aControl->SetPrecision( myControlsPrecision );
704 aFunctor.reset( aControl );
705 myControlActor = my2DActor;
710 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
711 aControl->SetPrecision( myControlsPrecision );
712 aFunctor.reset( aControl );
713 myControlActor = my2DActor;
718 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
719 aControl->SetPrecision( myControlsPrecision );
720 aFunctor.reset( aControl );
721 myControlActor = my2DActor;
728 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
729 vtkIdType aNbCells = aGrid->GetNumberOfCells();
731 myControlMode = theMode;
732 switch(myControlMode){
735 my1DExtActor->SetExtControlMode(aFunctor);
738 case eMultiConnection2D:
739 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
742 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
746 if(theCheckEntityMode){
747 if(myControlActor == my1DActor)
748 SetEntityMode(eEdges);
749 else if(myControlActor == my2DActor){
750 switch(myControlMode){
753 case eMultiConnection2D:
754 //SetEntityMode(eEdges);
755 SetEntityMode(eFaces);
758 SetEntityMode(eFaces);
760 }else if(myControlActor == my3DActor)
761 SetEntityMode(eVolumes);
764 }else if(theCheckEntityMode){
765 myEntityMode = eAllEntity;
768 SetRepresentation(GetRepresentation());
770 myTimeStamp->Modified();
775 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
776 SALOME_Actor::AddToRender(theRenderer);
778 theRenderer->AddActor(myNodeActor);
779 theRenderer->AddActor(myBaseActor);
781 theRenderer->AddActor(my3DActor);
782 theRenderer->AddActor(my2DActor);
784 theRenderer->AddActor(my1DActor);
785 theRenderer->AddActor(my1DExtActor);
787 theRenderer->AddActor(myHighlitableActor);
789 theRenderer->AddActor2D(myScalarBarActor);
791 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
792 myClsSelectVisiblePoints->SetRenderer(theRenderer);
794 theRenderer->AddActor2D(myPointLabels);
795 theRenderer->AddActor2D(myCellsLabels);
798 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
799 SALOME_Actor::RemoveFromRender(theRenderer);
801 theRenderer->RemoveActor(myNodeActor);
802 theRenderer->RemoveActor(myBaseActor);
804 theRenderer->RemoveActor(myHighlitableActor);
806 theRenderer->RemoveActor(my1DActor);
807 theRenderer->RemoveActor(my1DExtActor);
809 theRenderer->RemoveActor(my2DActor);
810 theRenderer->RemoveActor(my3DActor);
812 theRenderer->RemoveActor(myScalarBarActor);
813 theRenderer->RemoveActor(myPointLabels);
814 theRenderer->RemoveActor(myCellsLabels);
818 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
819 const char* theEntry,
823 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
827 myVisualObj = theVisualObj;
828 myVisualObj->Update(theIsClear);
830 myNodeActor->Init(myVisualObj,myImplicitBoolean);
831 myBaseActor->Init(myVisualObj,myImplicitBoolean);
833 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
835 my1DActor->Init(myVisualObj,myImplicitBoolean);
836 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
838 my2DActor->Init(myVisualObj,myImplicitBoolean);
839 my3DActor->Init(myVisualObj,myImplicitBoolean);
841 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
842 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
844 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
845 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
847 float aFactor, aUnits;
848 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
849 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
851 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
852 SetIsShrunkable(true);
854 QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
855 SetRepresentation(-1);
856 if(aMode.compare("Wireframe") == 0){
857 SetRepresentation(eEdge);
858 }else if(aMode.compare("Shading") == 0){
859 SetRepresentation(eSurface);
860 }else if(aMode.compare("Nodes") == 0){
861 SetRepresentation(ePoint);
864 aMode = QAD_CONFIG->getSetting("SMESH:Shrink");
869 myTimeStamp->Modified();
875 float* SMESH_ActorDef::GetBounds(){
876 return myNodeActor->GetBounds();
880 vtkDataSet* SMESH_ActorDef::GetInput(){
881 return GetUnstructuredGrid();
885 void SMESH_ActorDef::SetTransform(SALOME_Transform* theTransform){
886 myNodeActor->SetTransform(theTransform);
887 myBaseActor->SetTransform(theTransform);
889 myHighlitableActor->SetTransform(theTransform);
891 my1DActor->SetTransform(theTransform);
892 my1DExtActor->SetTransform(theTransform);
894 my2DActor->SetTransform(theTransform);
895 my3DActor->SetTransform(theTransform);
901 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
902 vtkLODActor::SetMapper(theMapper);
906 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
907 SALOME_Actor::ShallowCopy(prop);
911 vtkMapper* SMESH_ActorDef::GetMapper(){
912 return myPickableActor->GetMapper();
916 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
917 return myVisualObj->GetUnstructuredGrid();
921 bool SMESH_ActorDef::IsInfinitive(){
922 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
924 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
925 aDataSet->GetNumberOfCells() == 1 &&
926 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
927 return SALOME_Actor::IsInfinitive();
931 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
932 myIsShrinkable = theShrunkable;
936 float SMESH_ActorDef::GetShrinkFactor(){
937 return myBaseActor->GetShrinkFactor();
940 void SMESH_ActorDef::SetShrinkFactor(float theValue){
941 myBaseActor->SetShrinkFactor(theValue);
943 my1DActor->SetShrinkFactor(theValue);
944 my1DExtActor->SetShrinkFactor(theValue);
946 my2DActor->SetShrinkFactor(theValue);
947 my3DActor->SetShrinkFactor(theValue);
952 void SMESH_ActorDef::SetShrink(){
953 if(!myIsShrinkable) return;
955 myBaseActor->SetShrink();
957 my1DActor->SetShrink();
958 my1DExtActor->SetShrink();
960 my2DActor->SetShrink();
961 my3DActor->SetShrink();
967 void SMESH_ActorDef::UnShrink(){
968 if(!myIsShrunk) return;
970 myBaseActor->UnShrink();
972 my1DActor->UnShrink();
973 my1DExtActor->UnShrink();
975 my2DActor->UnShrink();
976 my3DActor->UnShrink();
983 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
984 return myPickableActor->GetNodeObjId(theVtkID);
987 float* SMESH_ActorDef::GetNodeCoord(int theObjID){
988 return myPickableActor->GetNodeCoord(theObjID);
992 int SMESH_ActorDef::GetElemObjId(int theVtkID){
993 return myPickableActor->GetElemObjId(theVtkID);
996 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
997 return myPickableActor->GetElemCell(theObjID);
1001 void SMESH_ActorDef::SetVisibility(int theMode){
1002 SetVisibility(theMode,true);
1006 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1007 SALOME_Actor::SetVisibility(theMode);
1009 myNodeActor->VisibilityOff();
1010 myBaseActor->VisibilityOff();
1012 my1DActor->VisibilityOff();
1013 my1DExtActor->VisibilityOff();
1015 my2DActor->VisibilityOff();
1016 my3DActor->VisibilityOff();
1018 myScalarBarActor->VisibilityOff();
1019 myPointLabels->VisibilityOff();
1020 myCellsLabels->VisibilityOff();
1022 if(GetVisibility()){
1023 if(theIsUpdateRepersentation)
1024 SetRepresentation(GetRepresentation());
1026 if(myControlMode != eNone){
1027 switch(myControlMode){
1030 my1DExtActor->VisibilityOn();
1033 case eMultiConnection2D:
1034 my1DExtActor->VisibilityOn();
1036 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1037 myScalarBarActor->VisibilityOn();
1041 if(myRepresentation != ePoint)
1042 myPickableActor->VisibilityOn();
1044 myNodeActor->VisibilityOn();
1047 if(myEntityMode & eEdges){
1048 my1DActor->VisibilityOn();
1051 if(myEntityMode & eFaces){
1052 my2DActor->VisibilityOn();
1055 if(myEntityMode & eVolumes){
1056 my3DActor->VisibilityOn();
1059 if(myIsPointsLabeled){
1060 myPointLabels->VisibilityOn();
1061 myNodeActor->VisibilityOn();
1064 if(myIsCellsLabeled)
1065 myCellsLabels->VisibilityOn();
1072 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
1073 myEntityState = eAllEntity;
1075 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){
1076 myEntityState &= ~eEdges;
1080 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){
1081 myEntityState &= ~eFaces;
1085 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){
1086 myEntityState &= ~eVolumes;
1087 theMode &= ~eVolumes;
1091 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1094 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1097 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1098 theMode |= eVolumes;
1101 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1103 myEntityMode = theMode;
1104 SALOME_ExtractUnstructuredGrid* aFilter = NULL;
1105 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1106 aFilter->ClearRegisteredCellsWithType();
1107 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
1109 if(myEntityMode & eEdges){
1110 if (MYDEBUG) MESSAGE("EDGES");
1111 aFilter->RegisterCellsWithType(VTK_LINE);
1114 if(myEntityMode & eFaces){
1115 if (MYDEBUG) MESSAGE("FACES");
1116 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1117 aFilter->RegisterCellsWithType(VTK_POLYGON);
1118 aFilter->RegisterCellsWithType(VTK_QUAD);
1121 if(myEntityMode & eVolumes){
1122 if (MYDEBUG) MESSAGE("VOLUMES");
1123 aFilter->RegisterCellsWithType(VTK_TETRA);
1124 aFilter->RegisterCellsWithType(VTK_VOXEL);
1125 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1126 aFilter->RegisterCellsWithType(VTK_WEDGE);
1127 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1128 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1131 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1132 SetVisibility(GetVisibility(),false);
1135 void SMESH_ActorDef::SetRepresentation(int theMode){
1136 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1137 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1138 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1140 myRepresentation = eSurface;
1141 if(!aNbFaces && !aNbVolumes && aNbEdges){
1142 myRepresentation = eEdge;
1143 }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1144 myRepresentation = ePoint;
1149 if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1152 if(!aNbFaces && !aNbVolumes) return;
1155 myRepresentation = theMode;
1158 if(!GetUnstructuredGrid()->GetNumberOfCells())
1159 myRepresentation = ePoint;
1162 if(myRepresentation == ePoint){
1170 myPickableActor = myBaseActor;
1171 myNodeActor->SetVisibility(false);
1172 vtkProperty *aProp = NULL, *aBackProp = NULL;
1173 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1174 switch(myRepresentation){
1176 myPickableActor = myNodeActor;
1177 myNodeActor->SetVisibility(true);
1179 aProp = aBackProp = myNodeProp;
1180 aReperesent = SMESH_DeviceActor::ePoint;
1183 aProp = aBackProp = myEdgeProp;
1184 aReperesent = SMESH_DeviceActor::eInsideframe;
1187 aProp = mySurfaceProp;
1188 aBackProp = myBackSurfaceProp;
1189 aReperesent = SMESH_DeviceActor::eSurface;
1193 my2DActor->SetProperty(aProp);
1194 my2DActor->SetBackfaceProperty(aBackProp);
1195 my2DActor->SetRepresentation(aReperesent);
1197 my3DActor->SetProperty(aProp);
1198 my3DActor->SetBackfaceProperty(aBackProp);
1199 my3DActor->SetRepresentation(aReperesent);
1201 my1DExtActor->SetVisibility(false);
1203 switch(myControlMode){
1205 case eMultiConnection:
1206 aProp = aBackProp = my1DProp;
1207 if(myRepresentation != ePoint)
1208 aReperesent = SMESH_DeviceActor::eInsideframe;
1212 my1DActor->SetProperty(aProp);
1213 my1DActor->SetBackfaceProperty(aBackProp);
1214 my1DActor->SetRepresentation(aReperesent);
1216 my1DExtActor->SetRepresentation(aReperesent);
1218 if(myIsPointsVisible)
1219 myPickableActor = myNodeActor;
1220 if(GetPointRepresentation())
1221 myNodeActor->SetVisibility(true);
1223 SetMapper(myPickableActor->GetMapper());
1225 SetVisibility(GetVisibility(),false);
1231 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1232 myIsPointsVisible = theIsPointsVisible;
1233 SetRepresentation(GetRepresentation());
1236 bool SMESH_ActorDef::GetPointRepresentation(){
1237 return myIsPointsVisible || myIsPointsLabeled;
1241 void SMESH_ActorDef::UpdateHighlight(){
1242 myHighlitableActor->SetVisibility(false);
1243 myHighlitableActor->SetHighlited(false);
1245 if(myIsHighlighted){
1246 myHighlitableActor->SetProperty(myHighlightProp);
1247 }else if(myIsPreselected){
1248 myHighlitableActor->SetProperty(myPreselectProp);
1251 bool anIsVisible = GetVisibility();
1253 if(myIsHighlighted || myIsPreselected){
1254 if(GetUnstructuredGrid()->GetNumberOfCells()){
1255 myHighlitableActor->SetHighlited(anIsVisible);
1256 myHighlitableActor->SetVisibility(anIsVisible);
1257 myHighlitableActor->GetExtractUnstructuredGrid()->
1258 SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::eCells);
1259 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1260 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1261 myHighlitableActor->SetHighlited(anIsVisible);
1262 myHighlitableActor->SetVisibility(anIsVisible);
1263 myHighlitableActor->GetExtractUnstructuredGrid()->
1264 SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints);
1265 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1271 void SMESH_ActorDef::highlight(bool theHighlight){
1272 myIsHighlighted = theHighlight;
1277 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1278 myIsPreselected = thePreselect;
1284 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1286 if (myPickableActor->GetIsOpaque())
1288 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1296 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1298 if (!myPickableActor->GetIsOpaque())
1300 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1308 void SMESH_ActorDef::Render(vtkRenderer *ren){
1309 unsigned long aTime = myTimeStamp->GetMTime();
1310 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1311 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1312 if(anObjTime > aTime || aClippingTime > aTime)
1317 void SMESH_ActorDef::Update(){
1318 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1320 if(GetControlMode() != eNone) {
1321 unsigned long aTime = myTimeStamp->GetMTime();
1322 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1323 if (anObjTime > aTime)
1324 SetControlMode(GetControlMode(),false);
1326 if(myIsPointsLabeled){
1327 SetPointsLabeled(myIsPointsLabeled);
1329 if(myIsCellsLabeled){
1330 SetCellsLabeled(myIsCellsLabeled);
1332 SetEntityMode(GetEntityMode());
1333 SetVisibility(GetVisibility());
1335 myTimeStamp->Modified();
1340 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1341 SALOME_Actor::ReleaseGraphicsResources(renWin);
1343 myPickableActor->ReleaseGraphicsResources(renWin);
1347 static void GetColor(vtkProperty *theProperty, float& r,float& g,float& b){
1348 float* aColor = theProperty->GetColor();
1355 void SMESH_ActorDef::SetOpacity(float theValue){
1356 mySurfaceProp->SetOpacity(theValue);
1357 myBackSurfaceProp->SetOpacity(theValue);
1358 myEdgeProp->SetOpacity(theValue);
1359 myNodeProp->SetOpacity(theValue);
1361 my1DProp->SetOpacity(theValue);
1365 float SMESH_ActorDef::GetOpacity(){
1366 return mySurfaceProp->GetOpacity();
1370 void SMESH_ActorDef::SetSufaceColor(float r,float g,float b){
1371 mySurfaceProp->SetColor(r,g,b);
1375 void SMESH_ActorDef::GetSufaceColor(float& r,float& g,float& b){
1376 ::GetColor(mySurfaceProp,r,g,b);
1379 void SMESH_ActorDef::SetBackSufaceColor(float r,float g,float b){
1380 myBackSurfaceProp->SetColor(r,g,b);
1384 void SMESH_ActorDef::GetBackSufaceColor(float& r,float& g,float& b){
1385 ::GetColor(myBackSurfaceProp,r,g,b);
1388 void SMESH_ActorDef::SetEdgeColor(float r,float g,float b){
1389 myEdgeProp->SetColor(r,g,b);
1390 my1DProp->SetColor(r,g,b);
1391 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1395 void SMESH_ActorDef::GetEdgeColor(float& r,float& g,float& b){
1396 ::GetColor(myEdgeProp,r,g,b);
1399 void SMESH_ActorDef::SetNodeColor(float r,float g,float b){
1400 myNodeProp->SetColor(r,g,b);
1404 void SMESH_ActorDef::GetNodeColor(float& r,float& g,float& b){
1405 ::GetColor(myNodeProp,r,g,b);
1408 void SMESH_ActorDef::SetHighlightColor(float r,float g,float b){
1409 myHighlightProp->SetColor(r,g,b);
1413 void SMESH_ActorDef::GetHighlightColor(float& r,float& g,float& b){
1414 ::GetColor(myHighlightProp,r,g,b);
1417 void SMESH_ActorDef::SetPreHighlightColor(float r,float g,float b){
1418 myPreselectProp->SetColor(r,g,b);
1422 void SMESH_ActorDef::GetPreHighlightColor(float& r,float& g,float& b){
1423 ::GetColor(myPreselectProp,r,g,b);
1427 float SMESH_ActorDef::GetLineWidth(){
1428 return myEdgeProp->GetLineWidth();
1432 void SMESH_ActorDef::SetLineWidth(float theVal){
1433 myEdgeProp->SetLineWidth(theVal);
1435 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1436 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1442 void SMESH_ActorDef::SetNodeSize(float theVal){
1443 myNodeProp->SetPointSize(theVal);
1444 myHighlightProp->SetPointSize(theVal);
1445 myPreselectProp->SetPointSize(theVal);
1447 my1DProp->SetPointSize(theVal + aPointSizeInc);
1448 my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1453 float SMESH_ActorDef::GetNodeSize(){
1454 return myNodeProp->GetPointSize();
1457 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1459 return myVisualObj->GetElemDimension( theObjId );
1464 IsImplicitFunctionUsed() const
1466 return myBaseActor->IsImplicitFunctionUsed();
1471 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1473 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1474 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1476 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1478 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1479 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1481 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1482 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1487 AddClippingPlane(vtkPlane* thePlane)
1490 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1491 myCippingPlaneCont.push_back(thePlane);
1492 if(!IsImplicitFunctionUsed())
1493 SetImplicitFunctionUsed(true);
1495 return myCippingPlaneCont.size();
1500 RemoveAllClippingPlanes()
1502 myImplicitBoolean->GetFunction()->RemoveAllItems();
1503 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1504 myCippingPlaneCont.clear();
1505 SetImplicitFunctionUsed(false);
1510 GetNumberOfClippingPlanes()
1512 return myCippingPlaneCont.size();
1517 GetClippingPlane(vtkIdType theID)
1519 if(theID >= myCippingPlaneCont.size())
1521 return myCippingPlaneCont[theID].Get();
1525 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1526 float theDirection[3], float theMinPnt[3],
1527 float& theMaxBoundPrj, float& theMinBoundPrj)
1530 theDataSet->GetBounds(aBounds);
1532 //Enlarge bounds in order to avoid conflicts of precision
1533 for(int i = 0; i < 6; i += 2){
1534 static double EPS = 1.0E-3;
1535 float aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1536 aBounds[i] -= aDelta;
1537 aBounds[i+1] += aDelta;
1540 float aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1541 {aBounds[1],aBounds[2],aBounds[4]},
1542 {aBounds[0],aBounds[3],aBounds[4]},
1543 {aBounds[1],aBounds[3],aBounds[4]},
1544 {aBounds[0],aBounds[2],aBounds[5]},
1545 {aBounds[1],aBounds[2],aBounds[5]},
1546 {aBounds[0],aBounds[3],aBounds[5]},
1547 {aBounds[1],aBounds[3],aBounds[5]}};
1549 int aMaxId = 0, aMinId = aMaxId;
1550 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1551 theMinBoundPrj = theMaxBoundPrj;
1552 for(int i = 1; i < 8; i++){
1553 float aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1554 if(theMaxBoundPrj < aTmp){
1555 theMaxBoundPrj = aTmp;
1558 if(theMinBoundPrj > aTmp){
1559 theMinBoundPrj = aTmp;
1563 float *aMinPnt = aBoundPoints[aMaxId];
1564 theMinPnt[0] = aMinPnt[0];
1565 theMinPnt[1] = aMinPnt[1];
1566 theMinPnt[2] = aMinPnt[2];
1570 static void DistanceToPosition(vtkDataSet* theDataSet,
1571 float theDirection[3], float theDist, float thePos[3])
1573 float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1574 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1575 float aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1576 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1577 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1578 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1582 static void PositionToDistance(vtkDataSet* theDataSet,
1583 float theDirection[3], float thePos[3], float& theDist)
1585 float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1586 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1587 float aPrj = vtkMath::Dot(theDirection,thePos);
1588 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1592 void SMESH_ActorDef::SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane)
1594 thePlane->SetNormal(theDir);
1596 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1597 thePlane->SetOrigin(anOrigin);
1601 void SMESH_ActorDef::GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane)
1603 thePlane->GetNormal(theDir);
1606 thePlane->GetOrigin(anOrigin);
1607 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);