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(){
105 if(MYDEBUG) MESSAGE("SMESH_ActorDef");
107 myTimeStamp = vtkTimeStamp::New();
109 myIsPointsVisible = false;
111 myIsShrinkable = false;
114 myControlsPrecision = (long)SMESH::GetFloat( "SMESH:ControlsPrecision", -1 );
116 float aPointSize = SMESH::GetFloat("SMESH:SettingsNodesSize",3);
117 float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1);
119 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
120 SALOME_ExtractUnstructuredGrid* aFilter = NULL;
122 //Definition 2D and 3D divices of the actor
123 //-----------------------------------------
124 float anRGB[3] = {1,1,1};
125 mySurfaceProp = vtkProperty::New();
126 anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
127 anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
128 anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
129 mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
131 myBackSurfaceProp = vtkProperty::New();
132 anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
133 anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
134 anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
135 myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
137 my2DActor = SMESH_DeviceActor::New();
138 my2DActor->SetUserMatrix(aMatrix);
139 my2DActor->SetStoreMapping(true);
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->SetStoreMapping(true);
153 my3DActor->PickableOff();
154 my3DActor->SetProperty(mySurfaceProp);
155 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
156 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
157 aFilter = my3DActor->GetExtractUnstructuredGrid();
158 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
159 aFilter->RegisterCellsWithType(VTK_TETRA);
160 aFilter->RegisterCellsWithType(VTK_VOXEL);
161 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
162 aFilter->RegisterCellsWithType(VTK_WEDGE);
163 aFilter->RegisterCellsWithType(VTK_PYRAMID);
166 //Definition 1D divice of the actor
167 //---------------------------------
168 myEdgeProp = vtkProperty::New();
169 myEdgeProp->SetAmbient(1.0);
170 myEdgeProp->SetDiffuse(0.0);
171 myEdgeProp->SetSpecular(0.0);
172 anRGB[0] = SMESH::GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.;
173 anRGB[1] = SMESH::GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.;
174 anRGB[2] = SMESH::GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.;
175 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
176 myEdgeProp->SetLineWidth(aLineWidth);
178 my1DActor = SMESH_DeviceActor::New();
179 my1DActor->SetUserMatrix(aMatrix);
180 my1DActor->SetStoreMapping(true);
181 my1DActor->PickableOff();
182 my1DActor->SetHighlited(true);
183 my1DActor->SetProperty(myEdgeProp);
184 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
185 aFilter = my1DActor->GetExtractUnstructuredGrid();
186 aFilter->SetModeOfChanging(SALOME_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->SetStoreMapping(true);
206 my1DExtActor->PickableOff();
207 my1DExtActor->SetHighlited(true);
208 my1DExtActor->SetVisibility(false);
209 my1DExtActor->SetProperty(my1DExtProp);
210 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
211 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
212 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
213 aFilter->RegisterCellsWithType(VTK_LINE);
216 //Definition 0D divice of the actor
217 //---------------------------------
218 myNodeProp = vtkProperty::New();
219 anRGB[0] = SMESH::GetFloat("SMESH:SettingsNodeColorRed",255)/255.;
220 anRGB[1] = SMESH::GetFloat("SMESH:SettingsNodeColorGreen",0)/255.;
221 anRGB[2] = SMESH::GetFloat("SMESH:SettingsNodeColorBlue",0)/255.;
222 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
223 myNodeProp->SetPointSize(aPointSize);
225 myNodeActor = SMESH_DeviceActor::New();
226 myNodeActor->SetUserMatrix(aMatrix);
227 myNodeActor->SetStoreMapping(true);
228 myNodeActor->PickableOff();
229 myNodeActor->SetVisibility(false);
230 myNodeActor->SetProperty(myNodeProp);
231 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
232 aFilter = myNodeActor->GetExtractUnstructuredGrid();
233 aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints);
236 //Definition of Pickable and Highlitable engines
237 //----------------------------------------------
239 myBaseActor = SMESH_DeviceActor::New();
240 myBaseActor->SetUserMatrix(aMatrix);
241 myBaseActor->SetStoreMapping(true);
242 myBaseActor->GetProperty()->SetOpacity(0.0);
243 myBaseActor->myGeomFilter->SetInside(true);
245 myPickableActor = myBaseActor;
247 myHighlightProp = vtkProperty::New();
248 myHighlightProp->SetAmbient(1.0);
249 myHighlightProp->SetDiffuse(0.0);
250 myHighlightProp->SetSpecular(0.0);
251 anRGB[0] = SMESH::GetFloat("SMESH:SettingsSelectColorRed", 255)/255.; // 1;
252 anRGB[1] = SMESH::GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1;
253 anRGB[2] = SMESH::GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.; // 1;
254 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
255 myHighlightProp->SetPointSize(aPointSize);
256 myHighlightProp->SetRepresentation(1);
258 myPreselectProp = vtkProperty::New();
259 myPreselectProp->SetAmbient(1.0);
260 myPreselectProp->SetDiffuse(0.0);
261 myPreselectProp->SetSpecular(0.0);
262 anRGB[0] = SMESH::GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.; // 0;
263 anRGB[1] = SMESH::GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1;
264 anRGB[2] = SMESH::GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.; // 1;
265 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
266 myPreselectProp->SetPointSize(aPointSize);
267 myPreselectProp->SetRepresentation(1);
269 myHighlitableActor = SMESH_DeviceActor::New();
270 myHighlitableActor->SetUserMatrix(aMatrix);
271 myHighlitableActor->SetStoreMapping(false);
272 myHighlitableActor->PickableOff();
273 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
275 myNodeHighlitableActor = SMESH_DeviceActor::New();
276 myNodeHighlitableActor->SetUserMatrix(aMatrix);
277 myNodeHighlitableActor->SetStoreMapping(false);
278 myNodeHighlitableActor->PickableOff();
279 myNodeHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
280 aFilter = myNodeHighlitableActor->GetExtractUnstructuredGrid();
281 aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints);
284 SetShrinkFactor(SMESH::GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.);
289 myControlMode = eNone;
290 myControlActor = my2DActor;
292 //Definition of myScalarBarActor
293 //------------------------------
294 myLookupTable = vtkLookupTable::New();
295 //Fix for Bug PAL5195 - SMESH764:
296 //Controls - Aspect Ratio: incorrect colors of the best and worst values
297 myLookupTable->SetHueRange(0.667,0.0);
299 myScalarBarActor = vtkScalarBarActor::New();
300 myScalarBarActor->SetVisibility(false);
301 myScalarBarActor->SetLookupTable(myLookupTable);
303 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
305 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
306 QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
307 aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
308 ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ),
309 ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
312 aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 );
314 aScalarBarTitleProp->SetFontFamilyToArial();
315 if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){
316 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
317 aScalarBarTitleProp->SetFontFamilyToArial();
318 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
319 aScalarBarTitleProp->SetFontFamilyToCourier();
320 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
321 aScalarBarTitleProp->SetFontFamilyToTimes();
324 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" )
325 aScalarBarTitleProp->BoldOn();
327 aScalarBarTitleProp->BoldOff();
329 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" )
330 aScalarBarTitleProp->ItalicOn();
332 aScalarBarTitleProp->ItalicOff();
334 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" )
335 aScalarBarTitleProp->ShadowOn();
337 aScalarBarTitleProp->ShadowOff();
339 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
340 aScalarBarTitleProp->Delete();
342 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
344 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
345 QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
346 aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
347 ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ),
348 ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
351 aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 );
353 aScalarBarLabelProp->SetFontFamilyToArial();
354 if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){
355 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
356 aScalarBarLabelProp->SetFontFamilyToArial();
357 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
358 aScalarBarLabelProp->SetFontFamilyToCourier();
359 else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
360 aScalarBarLabelProp->SetFontFamilyToTimes();
363 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" )
364 aScalarBarLabelProp->BoldOn();
366 aScalarBarLabelProp->BoldOff();
368 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" )
369 aScalarBarLabelProp->ItalicOn();
371 aScalarBarLabelProp->ItalicOff();
373 if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" )
374 aScalarBarLabelProp->ShadowOn();
376 aScalarBarLabelProp->ShadowOff();
378 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
379 aScalarBarLabelProp->Delete();
381 if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" )
382 myScalarBarActor->SetOrientationToHorizontal();
384 myScalarBarActor->SetOrientationToVertical();
386 float aXVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01;
387 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
388 aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat();
389 float aYVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1;
390 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
391 aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat();
392 myScalarBarActor->SetPosition( aXVal, aYVal );
394 float aWVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10;
395 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
396 aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat();
397 myScalarBarActor->SetWidth( aWVal );
399 float aHVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80;
400 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
401 aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat();
402 myScalarBarActor->SetHeight( aHVal );
405 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
406 anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt();
407 myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal);
410 if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
411 anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt();
412 myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal);
415 //Definition of points numbering pipeline
416 //---------------------------------------
417 myPointsNumDataSet = vtkUnstructuredGrid::New();
419 myPtsMaskPoints = vtkMaskPoints::New();
420 myPtsMaskPoints->SetInput(myPointsNumDataSet);
421 myPtsMaskPoints->SetOnRatio(1);
423 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
424 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
425 myPtsSelectVisiblePoints->SelectInvisibleOff();
426 myPtsSelectVisiblePoints->SetTolerance(0.1);
428 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
429 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
430 myPtsLabeledDataMapper->SetLabelFormat("%g");
431 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
433 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
434 aPtsTextProp->SetFontFamilyToTimes();
435 static int aPointsFontSize = 10;
436 aPtsTextProp->SetFontSize(aPointsFontSize);
437 aPtsTextProp->SetBold(1);
438 aPtsTextProp->SetItalic(0);
439 aPtsTextProp->SetShadow(0);
440 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
441 aPtsTextProp->Delete();
443 myEntityMode = eAllEntity;
445 myIsPointsLabeled = false;
447 myPointLabels = vtkActor2D::New();
448 myPointLabels->SetMapper(myPtsLabeledDataMapper);
449 myPointLabels->GetProperty()->SetColor(1,1,1);
450 myPointLabels->SetVisibility(myIsPointsLabeled);
453 //Definition of cells numbering pipeline
454 //---------------------------------------
455 myCellsNumDataSet = vtkUnstructuredGrid::New();
457 myCellCenters = vtkCellCenters::New();
458 myCellCenters->SetInput(myCellsNumDataSet);
460 myClsMaskPoints = vtkMaskPoints::New();
461 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
462 myClsMaskPoints->SetOnRatio(1);
464 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
465 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
466 myClsSelectVisiblePoints->SelectInvisibleOff();
467 myClsSelectVisiblePoints->SetTolerance(0.1);
469 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
470 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
471 myClsLabeledDataMapper->SetLabelFormat("%g");
472 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
474 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
475 aClsTextProp->SetFontFamilyToTimes();
476 static int aCellsFontSize = 12;
477 aClsTextProp->SetFontSize(aCellsFontSize);
478 aClsTextProp->SetBold(1);
479 aClsTextProp->SetItalic(0);
480 aClsTextProp->SetShadow(0);
481 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
482 aClsTextProp->Delete();
484 myIsCellsLabeled = false;
486 myCellsLabels = vtkActor2D::New();
487 myCellsLabels->SetMapper(myClsLabeledDataMapper);
488 myCellsLabels->GetProperty()->SetColor(0,1,0);
489 myCellsLabels->SetVisibility(myIsCellsLabeled);
492 myImplicitBoolean = vtkImplicitBoolean::New();
493 myImplicitBoolean->SetOperationTypeToIntersection();
497 SMESH_ActorDef::~SMESH_ActorDef(){
498 if(MYDEBUG) MESSAGE("~SMESH_ActorDef");
500 myScalarBarActor->Delete();
501 myLookupTable->Delete();
503 mySurfaceProp->Delete();
504 myBackSurfaceProp->Delete();
506 myEdgeProp->Delete();
507 myHighlightProp->Delete();
508 myPreselectProp->Delete();
510 myNodeProp->Delete();
515 my1DExtProp->Delete();
516 my1DExtActor->Delete();
521 myNodeActor->Delete();
522 myBaseActor->Delete();
524 myHighlitableActor->Delete();
525 myNodeHighlitableActor->Delete();
528 //Deleting of pints numbering pipeline
529 //---------------------------------------
530 myPointsNumDataSet->Delete();
532 myPtsLabeledDataMapper->RemoveAllInputs();
533 myPtsLabeledDataMapper->Delete();
535 myPtsSelectVisiblePoints->UnRegisterAllOutputs();
536 myPtsSelectVisiblePoints->Delete();
538 myPtsMaskPoints->UnRegisterAllOutputs();
539 myPtsMaskPoints->Delete();
541 myPointLabels->Delete();
544 //Deleting of cells numbering pipeline
545 //---------------------------------------
546 myCellsNumDataSet->Delete();
548 myClsLabeledDataMapper->RemoveAllInputs();
549 myClsLabeledDataMapper->Delete();
551 myClsSelectVisiblePoints->UnRegisterAllOutputs();
552 myClsSelectVisiblePoints->Delete();
554 myClsMaskPoints->UnRegisterAllOutputs();
555 myClsMaskPoints->Delete();
557 myCellCenters->UnRegisterAllOutputs();
558 myCellCenters->Delete();
560 myCellsLabels->Delete();
562 myImplicitBoolean->Delete();
564 myTimeStamp->Delete();
568 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
570 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
571 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
573 if ( myIsPointsLabeled )
575 myPointsNumDataSet->ShallowCopy(aGrid);
576 vtkDataSet *aDataSet = myPointsNumDataSet;
578 int aNbElem = aDataSet->GetNumberOfPoints();
580 vtkIntArray *anArray = vtkIntArray::New();
581 anArray->SetNumberOfValues( aNbElem );
583 for ( int anId = 0; anId < aNbElem; anId++ )
585 int aSMDSId = myVisualObj->GetNodeObjId( anId );
586 anArray->SetValue( anId, aSMDSId );
589 aDataSet->GetPointData()->SetScalars( anArray );
591 myPtsMaskPoints->SetInput( aDataSet );
592 myPointLabels->SetVisibility( GetVisibility() );
596 myPointLabels->SetVisibility( false );
598 SetRepresentation(GetRepresentation());
599 myTimeStamp->Modified();
603 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
605 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
606 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
607 if(myIsCellsLabeled){
608 myCellsNumDataSet->ShallowCopy(aGrid);
609 vtkDataSet *aDataSet = myCellsNumDataSet;
610 int aNbElem = aDataSet->GetNumberOfCells();
611 vtkIntArray *anArray = vtkIntArray::New();
612 anArray->SetNumberOfValues(aNbElem);
613 for(int anId = 0; anId < aNbElem; anId++){
614 int aSMDSId = myVisualObj->GetElemObjId(anId);
615 anArray->SetValue(anId,aSMDSId);
617 aDataSet->GetCellData()->SetScalars(anArray);
618 myCellCenters->SetInput(aDataSet);
619 myCellsLabels->SetVisibility(GetVisibility());
621 myCellsLabels->SetVisibility(false);
623 myTimeStamp->Modified();
627 void SMESH_ActorDef::SetControlMode(eControl theMode){
628 myControlMode = eNone;
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,myControlActor);
740 case eMultiConnection2D:
741 my1DExtActor->SetExtControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
744 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
748 if(QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"){
749 if(myControlActor == my1DActor)
750 myEntityMode = eEdges;
751 else if(myControlActor == my2DActor)
752 myEntityMode = eFaces;
753 else if(myControlActor == my3DActor)
754 myEntityMode = eVolumes;
757 }else if(QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"){
758 myEntityMode = eAllEntity;
761 SetRepresentation(GetRepresentation());
763 myTimeStamp->Modified();
768 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
769 SALOME_Actor::AddToRender(theRenderer);
771 theRenderer->AddActor(myNodeActor);
772 theRenderer->AddActor(myBaseActor);
774 theRenderer->AddActor(my3DActor);
775 theRenderer->AddActor(my2DActor);
777 theRenderer->AddActor(my1DActor);
778 theRenderer->AddActor(my1DExtActor);
780 theRenderer->AddActor(myHighlitableActor);
781 theRenderer->AddActor(myNodeHighlitableActor);
783 theRenderer->AddActor2D(myScalarBarActor);
785 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
786 myClsSelectVisiblePoints->SetRenderer(theRenderer);
788 theRenderer->AddActor2D(myPointLabels);
789 theRenderer->AddActor2D(myCellsLabels);
792 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
793 SALOME_Actor::RemoveFromRender(theRenderer);
795 theRenderer->RemoveActor(myNodeActor);
796 theRenderer->RemoveActor(myBaseActor);
798 theRenderer->RemoveActor(myHighlitableActor);
799 theRenderer->RemoveActor(myNodeHighlitableActor);
801 theRenderer->RemoveActor(my1DActor);
802 theRenderer->RemoveActor(my1DExtActor);
804 theRenderer->RemoveActor(my2DActor);
805 theRenderer->RemoveActor(my3DActor);
807 theRenderer->RemoveActor(myScalarBarActor);
808 theRenderer->RemoveActor(myPointLabels);
809 theRenderer->RemoveActor(myCellsLabels);
813 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
814 const char* theEntry,
818 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
822 myVisualObj = theVisualObj;
823 myVisualObj->Update(theIsClear);
825 myNodeActor->Init(myVisualObj,myImplicitBoolean);
826 myBaseActor->Init(myVisualObj,myImplicitBoolean);
828 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
829 myNodeHighlitableActor->Init(myVisualObj,myImplicitBoolean);
831 my1DActor->Init(myVisualObj,myImplicitBoolean);
832 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
834 my2DActor->Init(myVisualObj,myImplicitBoolean);
835 my3DActor->Init(myVisualObj,myImplicitBoolean);
837 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
838 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
840 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
841 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
843 float aFactor, aUnits;
844 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
845 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
847 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
848 SetIsShrunkable(true);
850 QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
851 SetRepresentation(-1);
852 if(aMode.compare("Wireframe") == 0){
853 SetRepresentation(eEdge);
854 }else if(aMode.compare("Shading") == 0){
855 SetRepresentation(eSurface);
856 }else if(aMode.compare("Nodes") == 0){
857 SetRepresentation(ePoint);
860 aMode = QAD_CONFIG->getSetting("SMESH:Shrink");
865 myTimeStamp->Modified();
871 float* SMESH_ActorDef::GetBounds(){
872 return myNodeActor->GetBounds();
876 vtkDataSet* SMESH_ActorDef::GetInput(){
877 return GetUnstructuredGrid();
881 void SMESH_ActorDef::SetTransform(SALOME_Transform* theTransform){
882 myNodeActor->SetTransform(theTransform);
883 myBaseActor->SetTransform(theTransform);
885 myHighlitableActor->SetTransform(theTransform);
886 myNodeHighlitableActor->SetTransform(theTransform);
888 my1DActor->SetTransform(theTransform);
889 my1DExtActor->SetTransform(theTransform);
891 my2DActor->SetTransform(theTransform);
892 my3DActor->SetTransform(theTransform);
898 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
899 vtkLODActor::SetMapper(theMapper);
903 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
904 SALOME_Actor::ShallowCopy(prop);
908 vtkMapper* SMESH_ActorDef::GetMapper(){
909 return myPickableActor->GetMapper();
913 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
914 return myVisualObj->GetUnstructuredGrid();
918 bool SMESH_ActorDef::IsInfinitive(){
919 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
921 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
922 aDataSet->GetNumberOfCells() == 1 &&
923 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
924 return SALOME_Actor::IsInfinitive();
928 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
929 myIsShrinkable = theShrunkable;
933 float SMESH_ActorDef::GetShrinkFactor(){
934 return myBaseActor->GetShrinkFactor();
937 void SMESH_ActorDef::SetShrinkFactor(float theValue){
938 myBaseActor->SetShrinkFactor(theValue);
940 my1DActor->SetShrinkFactor(theValue);
941 my1DExtActor->SetShrinkFactor(theValue);
943 my2DActor->SetShrinkFactor(theValue);
944 my3DActor->SetShrinkFactor(theValue);
949 void SMESH_ActorDef::SetShrink(){
950 if(!myIsShrinkable) return;
952 myBaseActor->SetShrink();
954 my1DActor->SetShrink();
955 my1DExtActor->SetShrink();
957 my2DActor->SetShrink();
958 my3DActor->SetShrink();
964 void SMESH_ActorDef::UnShrink(){
965 if(!myIsShrunk) return;
967 myBaseActor->UnShrink();
969 my1DActor->UnShrink();
970 my1DExtActor->UnShrink();
972 my2DActor->UnShrink();
973 my3DActor->UnShrink();
980 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
981 return myPickableActor->GetNodeObjId(theVtkID);
984 float* SMESH_ActorDef::GetNodeCoord(int theObjID){
985 return myPickableActor->GetNodeCoord(theObjID);
989 int SMESH_ActorDef::GetElemObjId(int theVtkID){
990 return myPickableActor->GetElemObjId(theVtkID);
993 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
994 return myPickableActor->GetElemCell(theObjID);
998 void SMESH_ActorDef::SetVisibility(int theMode){
999 SetVisibility(theMode,true);
1003 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1004 SALOME_Actor::SetVisibility(theMode);
1006 myNodeActor->VisibilityOff();
1007 myBaseActor->VisibilityOff();
1009 my1DActor->VisibilityOff();
1010 my1DExtActor->VisibilityOff();
1012 my2DActor->VisibilityOff();
1013 my3DActor->VisibilityOff();
1015 myScalarBarActor->VisibilityOff();
1016 myPointLabels->VisibilityOff();
1017 myCellsLabels->VisibilityOff();
1019 if(GetVisibility()){
1020 if(theIsUpdateRepersentation)
1021 SetRepresentation(GetRepresentation());
1023 if(myControlMode != eNone){
1024 switch(myControlMode){
1027 my1DExtActor->VisibilityOn();
1030 case eMultiConnection2D:
1031 my1DExtActor->VisibilityOn();
1033 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1034 myScalarBarActor->VisibilityOn();
1038 if(myRepresentation != ePoint)
1039 myPickableActor->VisibilityOn();
1041 myNodeActor->VisibilityOn();
1044 if(myEntityMode & eEdges){
1045 my1DActor->VisibilityOn();
1048 if(myEntityMode & eFaces){
1049 my2DActor->VisibilityOn();
1052 if(myEntityMode & eVolumes){
1053 my3DActor->VisibilityOn();
1056 if(myIsPointsLabeled){
1057 myPointLabels->VisibilityOn();
1058 myNodeActor->VisibilityOn();
1061 if(myIsCellsLabeled)
1062 myCellsLabels->VisibilityOn();
1069 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
1070 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge))
1073 if(!myVisualObj->GetNbEntities(SMDSAbs_Face))
1076 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume))
1077 theMode &= ~eVolumes;
1080 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1083 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1086 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1087 theMode |= eVolumes;
1090 myEntityMode = theMode;
1091 SALOME_ExtractUnstructuredGrid* aFilter = NULL;
1092 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1093 aFilter->ClearRegisteredCellsWithType();
1094 aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
1096 if(myEntityMode & eEdges){
1097 if (MYDEBUG) MESSAGE("EDGES");
1098 aFilter->RegisterCellsWithType(VTK_LINE);
1101 if(myEntityMode & eFaces){
1102 if (MYDEBUG) MESSAGE("FACES");
1103 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1104 aFilter->RegisterCellsWithType(VTK_POLYGON);
1105 aFilter->RegisterCellsWithType(VTK_QUAD);
1108 if(myEntityMode & eVolumes){
1109 if (MYDEBUG) MESSAGE("VOLUMES");
1110 aFilter->RegisterCellsWithType(VTK_TETRA);
1111 aFilter->RegisterCellsWithType(VTK_VOXEL);
1112 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1113 aFilter->RegisterCellsWithType(VTK_WEDGE);
1114 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1115 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1118 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1119 SetVisibility(GetVisibility(),false);
1122 void SMESH_ActorDef::SetRepresentation(int theMode){
1123 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1124 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1125 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1127 myRepresentation = eSurface;
1128 if(!aNbFaces && !aNbVolumes && aNbEdges){
1129 myRepresentation = eEdge;
1130 }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1131 myRepresentation = ePoint;
1136 if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1139 if(!aNbFaces && !aNbVolumes) return;
1142 myRepresentation = theMode;
1145 if(!GetUnstructuredGrid()->GetNumberOfCells())
1146 myRepresentation = ePoint;
1149 if(myRepresentation == ePoint){
1157 myPickableActor = myBaseActor;
1158 myNodeActor->SetVisibility(false);
1159 vtkProperty *aProp = NULL, *aBackProp = NULL;
1160 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1161 switch(myRepresentation){
1163 myPickableActor = myNodeActor;
1164 myNodeActor->SetVisibility(true);
1166 aProp = aBackProp = myNodeProp;
1167 aReperesent = SMESH_DeviceActor::ePoint;
1170 aProp = aBackProp = myEdgeProp;
1171 aReperesent = SMESH_DeviceActor::eInsideframe;
1174 aProp = mySurfaceProp;
1175 aBackProp = myBackSurfaceProp;
1176 aReperesent = SMESH_DeviceActor::eSurface;
1180 my2DActor->SetProperty(aProp);
1181 my2DActor->SetBackfaceProperty(aBackProp);
1182 my2DActor->SetRepresentation(aReperesent);
1184 my3DActor->SetProperty(aProp);
1185 my3DActor->SetBackfaceProperty(aBackProp);
1186 my3DActor->SetRepresentation(aReperesent);
1188 my1DExtActor->SetVisibility(false);
1190 switch(myControlMode){
1192 case eMultiConnection:
1193 aProp = aBackProp = my1DProp;
1194 if(myRepresentation != ePoint)
1195 aReperesent = SMESH_DeviceActor::eInsideframe;
1199 my1DActor->SetProperty(aProp);
1200 my1DActor->SetBackfaceProperty(aBackProp);
1201 my1DActor->SetRepresentation(aReperesent);
1203 my1DExtActor->SetRepresentation(aReperesent);
1205 if(myIsPointsVisible)
1206 myPickableActor = myNodeActor;
1207 if(GetPointRepresentation())
1208 myNodeActor->SetVisibility(true);
1210 SetMapper(myPickableActor->GetMapper());
1212 SetVisibility(GetVisibility(),false);
1218 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1219 myIsPointsVisible = theIsPointsVisible;
1220 SetRepresentation(GetRepresentation());
1223 bool SMESH_ActorDef::GetPointRepresentation(){
1224 return myIsPointsVisible || myIsPointsLabeled;
1228 void SMESH_ActorDef::UpdateHighlight(){
1229 myHighlitableActor->SetVisibility(false);
1230 myHighlitableActor->SetHighlited(false);
1232 myNodeHighlitableActor->SetVisibility(false);
1233 myNodeHighlitableActor->SetHighlited(false);
1235 if(myIsHighlighted){
1236 myHighlitableActor->SetProperty(myHighlightProp);
1237 }else if(myIsPreselected){
1238 myHighlitableActor->SetProperty(myPreselectProp);
1241 bool isVisible = GetVisibility();
1243 if(myIsHighlighted || myIsPreselected){
1244 if(GetUnstructuredGrid()->GetNumberOfCells()){
1245 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1246 myHighlitableActor->SetVisibility(isVisible);
1247 myHighlitableActor->SetHighlited(isVisible);
1249 if(myRepresentation == ePoint || GetPointRepresentation()){
1250 myNodeHighlitableActor->SetProperty(myHighlitableActor->GetProperty());
1251 myNodeHighlitableActor->SetVisibility(isVisible);
1252 myNodeHighlitableActor->SetHighlited(isVisible);
1258 void SMESH_ActorDef::highlight(bool theHighlight){
1259 myIsHighlighted = theHighlight;
1264 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1265 myIsPreselected = thePreselect;
1271 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1273 if (myPickableActor->GetIsOpaque())
1275 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1283 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1285 if (!myPickableActor->GetIsOpaque())
1287 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1295 void SMESH_ActorDef::Render(vtkRenderer *ren){
1296 unsigned long aTime = myTimeStamp->GetMTime();
1297 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1298 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1299 if(anObjTime > aTime || aClippingTime > aTime)
1304 void SMESH_ActorDef::Update(){
1305 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1307 if(GetControlMode() != eNone) {
1308 unsigned long aTime = myTimeStamp->GetMTime();
1309 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1310 if (anObjTime > aTime)
1311 SetControlMode(GetControlMode());
1313 if(myIsPointsLabeled){
1314 SetPointsLabeled(myIsPointsLabeled);
1316 if(myIsCellsLabeled){
1317 SetCellsLabeled(myIsCellsLabeled);
1319 SetEntityMode(GetEntityMode());
1320 SetVisibility(GetVisibility());
1322 myTimeStamp->Modified();
1327 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1328 SALOME_Actor::ReleaseGraphicsResources(renWin);
1330 myPickableActor->ReleaseGraphicsResources(renWin);
1334 static void GetColor(vtkProperty *theProperty, float& r,float& g,float& b){
1335 float* aColor = theProperty->GetColor();
1342 void SMESH_ActorDef::SetOpacity(float theValue){
1343 mySurfaceProp->SetOpacity(theValue);
1344 myBackSurfaceProp->SetOpacity(theValue);
1345 myEdgeProp->SetOpacity(theValue);
1346 myNodeProp->SetOpacity(theValue);
1348 my1DProp->SetOpacity(theValue);
1352 float SMESH_ActorDef::GetOpacity(){
1353 return mySurfaceProp->GetOpacity();
1357 void SMESH_ActorDef::SetSufaceColor(float r,float g,float b){
1358 mySurfaceProp->SetColor(r,g,b);
1362 void SMESH_ActorDef::GetSufaceColor(float& r,float& g,float& b){
1363 ::GetColor(mySurfaceProp,r,g,b);
1366 void SMESH_ActorDef::SetBackSufaceColor(float r,float g,float b){
1367 myBackSurfaceProp->SetColor(r,g,b);
1371 void SMESH_ActorDef::GetBackSufaceColor(float& r,float& g,float& b){
1372 ::GetColor(myBackSurfaceProp,r,g,b);
1375 void SMESH_ActorDef::SetEdgeColor(float r,float g,float b){
1376 myEdgeProp->SetColor(r,g,b);
1377 my1DProp->SetColor(r,g,b);
1378 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1382 void SMESH_ActorDef::GetEdgeColor(float& r,float& g,float& b){
1383 ::GetColor(myEdgeProp,r,g,b);
1386 void SMESH_ActorDef::SetNodeColor(float r,float g,float b){
1387 myNodeProp->SetColor(r,g,b);
1391 void SMESH_ActorDef::GetNodeColor(float& r,float& g,float& b){
1392 ::GetColor(myNodeProp,r,g,b);
1395 void SMESH_ActorDef::SetHighlightColor(float r,float g,float b){
1396 myHighlightProp->SetColor(r,g,b);
1400 void SMESH_ActorDef::GetHighlightColor(float& r,float& g,float& b){
1401 ::GetColor(myHighlightProp,r,g,b);
1404 void SMESH_ActorDef::SetPreHighlightColor(float r,float g,float b){
1405 myPreselectProp->SetColor(r,g,b);
1409 void SMESH_ActorDef::GetPreHighlightColor(float& r,float& g,float& b){
1410 ::GetColor(myPreselectProp,r,g,b);
1414 float SMESH_ActorDef::GetLineWidth(){
1415 return myEdgeProp->GetLineWidth();
1419 void SMESH_ActorDef::SetLineWidth(float theVal){
1420 myEdgeProp->SetLineWidth(theVal);
1422 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1423 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1429 void SMESH_ActorDef::SetNodeSize(float theVal){
1430 myNodeProp->SetPointSize(theVal);
1431 myHighlightProp->SetPointSize(theVal);
1432 myPreselectProp->SetPointSize(theVal);
1434 my1DProp->SetPointSize(theVal + aPointSizeInc);
1435 my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1440 float SMESH_ActorDef::GetNodeSize(){
1441 return myNodeProp->GetPointSize();
1444 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1446 return myVisualObj->GetElemDimension( theObjId );
1451 IsImplicitFunctionUsed() const
1453 return myBaseActor->IsImplicitFunctionUsed();
1458 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1460 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1461 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1463 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1464 myNodeHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1466 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1467 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1469 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1470 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1475 AddClippingPlane(vtkPlane* thePlane)
1478 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1479 myCippingPlaneCont.push_back(thePlane);
1480 if(!IsImplicitFunctionUsed())
1481 SetImplicitFunctionUsed(true);
1483 return myCippingPlaneCont.size();
1488 RemoveAllClippingPlanes()
1490 myImplicitBoolean->GetFunction()->RemoveAllItems();
1491 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1492 myCippingPlaneCont.clear();
1493 SetImplicitFunctionUsed(false);
1498 GetNumberOfClippingPlanes()
1500 return myCippingPlaneCont.size();
1505 GetClippingPlane(vtkIdType theID)
1507 if(theID >= myCippingPlaneCont.size())
1509 return myCippingPlaneCont[theID].Get();
1513 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1514 float theDirection[3], float theMinPnt[3],
1515 float& theMaxBoundPrj, float& theMinBoundPrj)
1518 theDataSet->GetBounds(aBounds);
1520 //Enlarge bounds in order to avoid conflicts of precision
1521 for(int i = 0; i < 6; i += 2){
1522 static double EPS = 1.0E-3;
1523 float aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1524 aBounds[i] -= aDelta;
1525 aBounds[i+1] += aDelta;
1528 float aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1529 {aBounds[1],aBounds[2],aBounds[4]},
1530 {aBounds[0],aBounds[3],aBounds[4]},
1531 {aBounds[1],aBounds[3],aBounds[4]},
1532 {aBounds[0],aBounds[2],aBounds[5]},
1533 {aBounds[1],aBounds[2],aBounds[5]},
1534 {aBounds[0],aBounds[3],aBounds[5]},
1535 {aBounds[1],aBounds[3],aBounds[5]}};
1537 int aMaxId = 0, aMinId = aMaxId;
1538 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1539 theMinBoundPrj = theMaxBoundPrj;
1540 for(int i = 1; i < 8; i++){
1541 float aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1542 if(theMaxBoundPrj < aTmp){
1543 theMaxBoundPrj = aTmp;
1546 if(theMinBoundPrj > aTmp){
1547 theMinBoundPrj = aTmp;
1551 float *aMinPnt = aBoundPoints[aMaxId];
1552 theMinPnt[0] = aMinPnt[0];
1553 theMinPnt[1] = aMinPnt[1];
1554 theMinPnt[2] = aMinPnt[2];
1558 static void DistanceToPosition(vtkDataSet* theDataSet,
1559 float theDirection[3], float theDist, float thePos[3])
1561 float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1562 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1563 float aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1564 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1565 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1566 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1570 static void PositionToDistance(vtkDataSet* theDataSet,
1571 float theDirection[3], float thePos[3], float& theDist)
1573 float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1574 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1575 float aPrj = vtkMath::Dot(theDirection,thePos);
1576 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1580 void SMESH_ActorDef::SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane)
1582 thePlane->SetNormal(theDir);
1584 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1585 thePlane->SetOrigin(anOrigin);
1589 void SMESH_ActorDef::GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane)
1591 thePlane->GetNormal(theDir);
1594 thePlane->GetOrigin(anOrigin);
1595 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);