1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_DeviceActor.cxx
28 #include "SMESH_DeviceActor.h"
29 #include "SMESH_ScalarBarActor.h"
30 #include "SMESH_ExtractGeometry.h"
31 #include "SMESH_ControlsDef.hxx"
32 #include "SMESH_ActorUtils.h"
33 #include "SMESH_FaceOrientationFilter.h"
34 #include "VTKViewer_CellLocationsArray.h"
35 #include "VTKViewer_PolyDataMapper.h"
37 #include <VTKViewer_Transform.h>
38 #include <VTKViewer_TransformFilter.h>
39 #include <VTKViewer_ExtractUnstructuredGrid.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkShrinkFilter.h>
44 #include <vtkShrinkPolyData.h>
46 #include <vtkProperty.h>
47 #include <vtkPolyData.h>
48 #include <vtkMergeFilter.h>
49 #include <vtkPolyDataMapper.h>
50 #include <vtkUnstructuredGrid.h>
52 #include <vtkLookupTable.h>
53 #include <vtkDoubleArray.h>
54 #include <vtkCellData.h>
57 #include <vtkIdList.h>
58 #include <vtkCellArray.h>
59 #include <vtkUnsignedCharArray.h>
61 #include <vtkImplicitBoolean.h>
62 #include <vtkPassThroughFilter.h>
64 #include <vtkRenderer.h>
66 #include "utilities.h"
69 static int MYDEBUG = 0;
71 static int MYDEBUG = 0;
77 vtkStandardNewMacro(SMESH_DeviceActor);
83 if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
85 myIsShrinkable = false;
87 myIsHighlited = false;
89 myRepresentation = eSurface;
91 myProperty = vtkProperty::New();
92 myMapper = VTKViewer_PolyDataMapper::New();
94 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
95 myPolygonOffsetUnits);
97 myMapper->UseLookupTableScalarRangeOn();
98 myMapper->SetColorModeToMapScalars();
100 myShrinkFilter = vtkShrinkFilter::New();
102 myStoreClippingMapping = false;
104 myExtractGeometry = SMESH_ExtractGeometry::New();
105 myExtractGeometry->SetReleaseDataFlag(true);
106 myIsImplicitFunctionUsed = false;
108 myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
110 myMergeFilter = vtkMergeFilter::New();
112 myGeomFilter = VTKViewer_GeometryFilter::New();
114 myTransformFilter = VTKViewer_TransformFilter::New();
116 for(int i = 0; i < 6; i++)
117 myPassFilter.push_back(vtkPassThroughFilter::New());
119 // Orientation of faces
120 myIsFacesOriented = false;
122 double anRGB[3] = { 1, 1, 1 };
123 SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
125 myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
127 myFaceOrientationDataMapper = vtkPolyDataMapper::New();
128 myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort());
130 myFaceOrientation = vtkActor::New();
131 myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
132 myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]);
137 ::~SMESH_DeviceActor()
139 if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
143 myProperty->Delete();
145 myExtractGeometry->Delete();
147 myMergeFilter->Delete();
148 myExtractUnstructuredGrid->Delete();
150 // Orientation of faces
151 myFaceOrientationFilter->Delete();
152 myFaceOrientationDataMapper->RemoveAllInputs();
153 myFaceOrientationDataMapper->Delete();
154 myFaceOrientation->Delete();
156 myGeomFilter->Delete();
158 myTransformFilter->Delete();
160 for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
161 myPassFilter[i]->Delete();
163 myShrinkFilter->Delete();
169 ::SetStoreGemetryMapping(bool theStoreMapping)
171 myGeomFilter->SetStoreMapping(theStoreMapping);
172 SetStoreClippingMapping(theStoreMapping);
178 ::SetStoreClippingMapping(bool theStoreMapping)
180 myStoreClippingMapping = theStoreMapping;
181 myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
182 SetStoreIDMapping(theStoreMapping);
188 ::SetStoreIDMapping(bool theStoreMapping)
190 myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
196 ::Init(TVisualObjPtr theVisualObj,
197 vtkImplicitBoolean* theImplicitBoolean)
199 myVisualObj = theVisualObj;
200 myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
201 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
207 ::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
210 if(theIsImplicitFunctionUsed)
211 myPassFilter[ anId ]->SetInputConnection( myExtractGeometry->GetOutputPort() );
213 myPassFilter[ anId ]->SetInputConnection( myMergeFilter->GetOutputPort() );
215 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
216 SetStoreClippingMapping(myStoreClippingMapping);
222 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
225 //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
226 myIsShrinkable = true;
228 myExtractUnstructuredGrid->SetInputData(theGrid);
230 myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
232 //Pass diameters of the balls
233 if(myMapper->GetBallEnabled()) {
234 myMergeFilter->SetScalarsConnection(myExtractUnstructuredGrid->GetOutputPort());
237 myExtractGeometry->SetInputConnection(myMergeFilter->GetOutputPort());
240 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
241 myPassFilter[ anId + 1]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
244 myTransformFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
247 myPassFilter[ anId ]->SetInputConnection( myTransformFilter->GetOutputPort() );
248 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
251 myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
254 myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() );
255 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
258 myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
260 vtkLODActor::SetMapper( myMapper );
266 VTKViewer_ExtractUnstructuredGrid*
268 ::GetExtractUnstructuredGrid()
270 return myExtractUnstructuredGrid;
276 ::GetUnstructuredGrid()
278 myExtractUnstructuredGrid->Update();
279 return myExtractUnstructuredGrid->GetOutput();
285 ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
286 SMESH_ScalarBarActor* theScalarBarActor,
287 vtkLookupTable* theLookupTable)
289 bool anIsInitialized = theFunctor;
291 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
293 SetStoreIDMapping(true);
294 myExtractUnstructuredGrid->Update();
295 vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
297 aDataSet->ShallowCopy(aGrid);
299 vtkDoubleArray *aScalars = vtkDoubleArray::New();
300 vtkIdType aNbCells = aGrid->GetNumberOfCells();
301 aScalars->SetNumberOfComponents(1);
302 aScalars->SetNumberOfTuples(aNbCells);
303 double* range;// = aScalars->GetRange();
305 myVisualObj->UpdateFunctor(theFunctor);
307 using namespace SMESH::Controls;
308 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
310 for(vtkIdType i = 0; i < aNbCells; i++){
311 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
312 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
313 double aValue = aNumericalFunctor->GetValue(anObjId);
314 aScalars->SetValue(i,aValue);
316 range = aScalars->GetRange();
317 if ( range[1] - range[0] < ( qMax(qAbs(range[0]),qAbs(range[1])) + 1e-100 ) * 1e-6 )
320 for(vtkIdType i = 0; i < aNbCells; i++)
321 aScalars->SetValue(i,range[0]);
324 else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get()))
326 for(vtkIdType i = 0; i < aNbCells; i++){
327 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
328 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
329 bool aValue = aPredicate->IsSatisfy(anObjId);
330 aScalars->SetValue(i,aValue);
332 range = aScalars->GetRange();
335 aDataSet->GetCellData()->SetScalars(aScalars);
338 theLookupTable->SetRange( range );
339 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
340 theLookupTable->Build();
342 myMergeFilter->SetScalarsData(aDataSet);
345 GetMapper()->SetScalarVisibility(anIsInitialized);
346 theScalarBarActor->SetVisibility(anIsInitialized);
351 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
352 SMESH_ScalarBarActor* theScalarBarActor,
353 vtkLookupTable* theLookupTable)
355 bool anIsInitialized = theFunctor;
356 myExtractUnstructuredGrid->ClearRegisteredCells();
357 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
358 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
359 myVisualObj->UpdateFunctor(theFunctor);
361 using namespace SMESH::Controls;
362 if (anIsInitialized){
363 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
364 SMESH::Controls::Length2D::TValues aValues;
366 aLength2D->GetValues(aValues);
367 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
368 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
370 aDataSet->SetPoints(aGrid->GetPoints());
372 vtkIdType aNbCells = aValues.size();
374 vtkDoubleArray *aScalars = vtkDoubleArray::New();
375 aScalars->SetNumberOfComponents(1);
376 aScalars->SetNumberOfTuples(aNbCells);
378 vtkIdType aCellsSize = 3*aNbCells;
379 vtkCellArray* aConnectivity = vtkCellArray::New();
380 aConnectivity->Allocate( aCellsSize, 0 );
382 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
383 aCellTypesArray->SetNumberOfComponents( 1 );
384 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
386 vtkIdList *anIdList = vtkIdList::New();
387 anIdList->SetNumberOfIds(2);
389 Length2D::TValues::const_iterator anIter = aValues.begin();
390 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
391 const Length2D::Value& aValue = *anIter;
393 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
394 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
396 if(aNode[0] >= 0 && aNode[1] >= 0){
397 anIdList->SetId( 0, aNode[0] );
398 anIdList->SetId( 1, aNode[1] );
399 aConnectivity->InsertNextCell( anIdList );
400 aCellTypesArray->InsertNextValue( VTK_LINE );
401 aScalars->SetValue(aVtkId,aValue.myLength);
405 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
406 aCellLocationsArray->SetNumberOfComponents( 1 );
407 aCellLocationsArray->SetNumberOfTuples( aNbCells );
409 aConnectivity->InitTraversal();
410 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
411 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
413 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
414 SetUnstructuredGrid(aDataSet);
416 aDataSet->GetCellData()->SetScalars(aScalars);
419 theLookupTable->SetRange(aScalars->GetRange());
420 theLookupTable->Build();
422 myMergeFilter->SetScalarsData(aDataSet);
425 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
426 SMESH::Controls::MultiConnection2D::MValues aValues;
428 aMultiConnection2D->GetValues(aValues);
429 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
430 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
431 aDataSet->SetPoints(aGrid->GetPoints());
433 vtkIdType aNbCells = aValues.size();
434 vtkDoubleArray *aScalars = vtkDoubleArray::New();
435 aScalars->SetNumberOfComponents(1);
436 aScalars->SetNumberOfTuples(aNbCells);
438 vtkIdType aCellsSize = 3*aNbCells;
439 vtkCellArray* aConnectivity = vtkCellArray::New();
440 aConnectivity->Allocate( aCellsSize, 0 );
442 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
443 aCellTypesArray->SetNumberOfComponents( 1 );
444 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
446 vtkIdList *anIdList = vtkIdList::New();
447 anIdList->SetNumberOfIds(2);
449 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
450 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
451 const MultiConnection2D::Value& aValue = (*anIter).first;
453 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
454 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
456 if(aNode[0] >= 0 && aNode[1] >= 0){
457 anIdList->SetId( 0, aNode[0] );
458 anIdList->SetId( 1, aNode[1] );
459 aConnectivity->InsertNextCell( anIdList );
460 aCellTypesArray->InsertNextValue( VTK_LINE );
461 aScalars->SetValue(aVtkId,(*anIter).second);
465 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
466 aCellLocationsArray->SetNumberOfComponents( 1 );
467 aCellLocationsArray->SetNumberOfTuples( aNbCells );
469 aConnectivity->InitTraversal();
470 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
471 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
473 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
474 SetUnstructuredGrid(aDataSet);
476 aDataSet->GetCellData()->SetScalars(aScalars);
479 theLookupTable->SetRange(aScalars->GetRange());
480 theLookupTable->Build();
482 myMergeFilter->SetScalarsData(aDataSet);
486 GetMapper()->SetScalarVisibility(anIsInitialized);
487 theScalarBarActor->SetVisibility(anIsInitialized);
492 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
494 myExtractUnstructuredGrid->ClearRegisteredCells();
495 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
496 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
497 myVisualObj->UpdateFunctor(theFunctor);
499 using namespace SMESH::Controls;
500 if ( dynamic_cast<FreeBorders *>(theFunctor.get()) ||
501 dynamic_cast<FreeFaces *>(theFunctor.get()) ||
502 dynamic_cast<BareBorderVolume *>(theFunctor.get()) ||
503 dynamic_cast<BareBorderFace *>(theFunctor.get()) ||
504 dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
505 dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
506 dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
507 dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
508 dynamic_cast<OverConstrainedFace *>(theFunctor.get()))
510 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
511 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
512 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
513 vtkIdType aNbCells = aGrid->GetNumberOfCells();
514 for( vtkIdType i = 0; i < aNbCells; i++ ){
515 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
516 if(aPredicate->IsSatisfy(anObjId))
517 myExtractUnstructuredGrid->RegisterCell(i);
519 if(!myExtractUnstructuredGrid->IsCellsRegistered())
520 myExtractUnstructuredGrid->RegisterCell(-1);
521 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
523 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
525 SMESH::Controls::FreeEdges::TBorders aBorders;
526 aFreeEdges->GetBoreders(aBorders);
527 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
528 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
529 aDataSet->SetPoints(aGrid->GetPoints());
531 vtkIdType aNbCells = aBorders.size();
532 vtkIdType aCellsSize = 3*aNbCells;
533 vtkCellArray* aConnectivity = vtkCellArray::New();
534 aConnectivity->Allocate( aCellsSize, 0 );
536 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
537 aCellTypesArray->SetNumberOfComponents( 1 );
538 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
540 vtkIdList *anIdList = vtkIdList::New();
541 anIdList->SetNumberOfIds(2);
543 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
544 for(; anIter != aBorders.end(); anIter++){
545 const FreeEdges::Border& aBorder = *anIter;
547 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
548 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
550 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
551 if(aNode[0] >= 0 && aNode[1] >= 0){
552 anIdList->SetId( 0, aNode[0] );
553 anIdList->SetId( 1, aNode[1] );
554 aConnectivity->InsertNextCell( anIdList );
555 aCellTypesArray->InsertNextValue( VTK_LINE );
559 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
560 aCellLocationsArray->SetNumberOfComponents( 1 );
561 aCellLocationsArray->SetNumberOfTuples( aNbCells );
563 aConnectivity->InitTraversal();
564 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
565 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
567 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
569 SetUnstructuredGrid(aDataSet);
572 else if(dynamic_cast<FreeNodes *>(theFunctor.get()) ||
573 dynamic_cast<CoincidentNodes*>(theFunctor.get()))
575 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
576 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
577 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
578 for( vtkIdType i = 0; i < aNbNodes; i++ ){
579 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
580 if(aPredicate->IsSatisfy(anObjId))
581 myExtractUnstructuredGrid->RegisterCell(i);
583 if(!myExtractUnstructuredGrid->IsCellsRegistered())
584 myExtractUnstructuredGrid->RegisterCell(-1);
585 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
596 unsigned long mTime = this->Superclass::GetMTime();
597 mTime = max(mTime,myExtractGeometry->GetMTime());
598 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
599 mTime = max(mTime,myMergeFilter->GetMTime());
600 mTime = max(mTime,myGeomFilter->GetMTime());
601 mTime = max(mTime,myTransformFilter->GetMTime());
602 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
609 ::SetTransform(VTKViewer_Transform* theTransform)
611 myTransformFilter->SetTransform(theTransform);
619 if ( !myIsShrinkable ) return;
620 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
622 myShrinkFilter->SetInputConnection( aDataSet );
623 myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() );
632 if ( !myIsShrunk ) return;
633 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
635 myPassFilter[ 1 ]->SetInputConnection( aDataSet );
636 myPassFilter[ 1 ]->Modified();
645 ::SetFacesOriented(bool theIsFacesOriented)
647 if ( vtkAlgorithmOutput* aDataSet = myTransformFilter->GetOutputPort() )
649 myIsFacesOriented = theIsFacesOriented;
650 if( theIsFacesOriented )
651 myFaceOrientationFilter->SetInputConnection( aDataSet );
652 UpdateFaceOrientation();
658 ::SetFacesOrientationColor(double r,double g,double b)
660 myFaceOrientation->GetProperty()->SetColor( r, g, b );
665 ::GetFacesOrientationColor(double& r,double& g,double& b)
667 myFaceOrientation->GetProperty()->GetColor( r, g, b );
672 ::SetFacesOrientationScale(double theScale)
674 myFaceOrientationFilter->SetOrientationScale( theScale );
679 ::GetFacesOrientationScale()
681 return myFaceOrientationFilter->GetOrientationScale();
686 ::SetFacesOrientation3DVectors(bool theState)
688 myFaceOrientationFilter->Set3dVectors( theState );
693 ::GetFacesOrientation3DVectors()
695 return myFaceOrientationFilter->Get3dVectors();
700 ::UpdateFaceOrientation()
702 bool aShowFaceOrientation = myIsFacesOriented;
703 aShowFaceOrientation &= GetVisibility();
704 aShowFaceOrientation &= myRepresentation == eSurface;
705 myFaceOrientation->SetVisibility(aShowFaceOrientation);
711 ::SetRepresentation(EReperesent theMode)
715 myGeomFilter->SetInside(true);
716 myGeomFilter->SetWireframeMode(false);
717 GetProperty()->SetRepresentation(0);
720 myGeomFilter->SetInside(false);
721 myGeomFilter->SetWireframeMode(true);
722 GetProperty()->SetRepresentation(theMode);
725 myGeomFilter->SetInside(true);
726 myGeomFilter->SetWireframeMode(true);
727 GetProperty()->SetRepresentation(1);
730 myGeomFilter->SetInside(false);
731 myGeomFilter->SetWireframeMode(false);
732 GetProperty()->SetRepresentation(theMode);
734 SetMarkerEnabled(theMode == ePoint);
735 myRepresentation = theMode;
736 UpdateFaceOrientation();
737 GetProperty()->Modified();
738 myMapper->Modified();
745 ::SetVisibility(int theMode)
747 if(!myExtractUnstructuredGrid->GetInput() ||
748 GetUnstructuredGrid()->GetNumberOfCells())
750 vtkLODActor::SetVisibility(theMode);
752 vtkLODActor::SetVisibility(false);
754 UpdateFaceOrientation();
762 if(!GetUnstructuredGrid()->GetNumberOfCells()){
763 vtkLODActor::SetVisibility(false);
765 return vtkLODActor::GetVisibility();
771 ::AddToRender(vtkRenderer* theRenderer)
773 theRenderer->AddActor(this);
774 theRenderer->AddActor(myFaceOrientation);
779 ::RemoveFromRender(vtkRenderer* theRenderer)
781 theRenderer->RemoveActor(this);
782 theRenderer->RemoveActor(myFaceOrientation);
788 ::GetNodeObjId(int theVtkID)
790 vtkIdType anID = theVtkID;
792 if(IsImplicitFunctionUsed())
793 anID = myExtractGeometry->GetNodeObjId(theVtkID);
795 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
796 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
802 ::GetNodeCoord(int theObjID)
804 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
805 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
806 double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
807 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
814 ::GetElemObjId(int theVtkID)
816 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
820 vtkIdType anId2 = anId;
821 if(IsImplicitFunctionUsed())
822 anId2 = myExtractGeometry->GetElemObjId(anId);
826 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
830 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
832 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
838 ::GetElemCell(int theObjID)
840 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
841 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
842 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
844 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
853 return myShrinkFilter->GetShrinkFactor();
858 ::SetShrinkFactor(double theValue)
860 theValue = theValue > 0.1? theValue: 0.8;
861 myShrinkFilter->SetShrinkFactor(theValue);
868 ::SetHighlited(bool theIsHighlited)
870 if ( myIsHighlited == theIsHighlited )
872 myIsHighlited = theIsHighlited;
878 ::Render(vtkRenderer *ren, vtkMapper* m)
880 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
881 double aStoredFactor, aStoredUnit;
882 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
884 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
885 double aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
887 static double EPS = .01;
890 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
891 vtkLODActor::Render(ren,m);
893 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
894 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
900 ::SetPolygonOffsetParameters(double factor,
903 myPolygonOffsetFactor = factor;
904 myPolygonOffsetUnits = units;
908 * On/Off representation 2D quadratic element as arked polygon
910 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
911 myGeomFilter->SetQuadraticArcMode(theFlag);
915 * Return true if 2D quadratic element displayed as arked polygon
917 bool SMESH_DeviceActor::GetQuadraticArcMode(){
918 return myGeomFilter->GetQuadraticArcMode();
921 * Set Max angle for representation 2D quadratic element as arked polygon
923 void SMESH_DeviceActor::SetQuadraticArcAngle(double theMaxAngle){
924 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
928 * Return Max angle of the representation 2D quadratic element as arked polygon
930 double SMESH_DeviceActor::GetQuadraticArcAngle(){
931 return myGeomFilter->GetQuadraticArcAngle();
935 * Set point marker enabled
936 * \param theMarkerEnabled flag to enable/disable point marker
938 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
940 myMapper->SetMarkerEnabled( theMarkerEnabled );
944 * Set point marker enabled
945 * \param theBallEnabled flag to enable/disable ball drawing
947 void SMESH_DeviceActor::SetBallEnabled( bool theBallEnabled ) {
948 myMapper->SetBallEnabled( theBallEnabled );
952 * Set standard point marker
953 * \param theMarkerType type of the marker
955 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
957 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
961 * Set custom point marker
962 * \param theMarkerId id of the marker texture
963 * \param theMarkerTexture marker texture
965 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
967 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
971 * Get type of the point marker
972 * \return type of the point marker
974 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
976 return myMapper->GetMarkerType();
980 Get scale of the point marker
981 \return scale of the point marker
983 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
985 return myMapper->GetMarkerScale();
989 * Get texture identifier of the point marker
990 * \return texture identifier of the point marker
992 int SMESH_DeviceActor::GetMarkerTexture()
994 return myMapper->GetMarkerTexture();
997 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
998 myGeomFilter->SetAppendCoincident3D(theFlag);
1001 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
1002 return myGeomFilter->GetAppendCoincident3D();