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 <vtkPlaneCollection.h>
68 #include "utilities.h"
71 static int MYDEBUG = 0;
73 static int MYDEBUG = 0;
79 vtkStandardNewMacro(SMESH_DeviceActor);
85 if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
87 myIsShrinkable = false;
89 myIsHighlited = false;
91 myRepresentation = eSurface;
93 myProperty = vtkProperty::New();
94 myMapper = VTKViewer_PolyDataMapper::New();
95 myPlaneCollection = vtkPlaneCollection::New();
97 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
98 myPolygonOffsetUnits);
100 myMapper->UseLookupTableScalarRangeOn();
101 myMapper->SetColorModeToMapScalars();
103 myShrinkFilter = vtkShrinkFilter::New();
105 myStoreClippingMapping = false;
107 myExtractGeometry = SMESH_ExtractGeometry::New();
108 myExtractGeometry->SetReleaseDataFlag(true);
109 myIsImplicitFunctionUsed = false;
111 myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
113 myMergeFilter = vtkMergeFilter::New();
115 myGeomFilter = VTKViewer_GeometryFilter::New();
117 myTransformFilter = VTKViewer_TransformFilter::New();
119 for(int i = 0; i < 6; i++)
120 myPassFilter.push_back(vtkPassThroughFilter::New());
122 // Orientation of faces
123 myIsFacesOriented = false;
125 double anRGB[3] = { 1, 1, 1 };
126 SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
128 myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
130 myFaceOrientationDataMapper = vtkPolyDataMapper::New();
131 myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort());
133 myFaceOrientation = vtkActor::New();
134 myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
135 myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]);
140 ::~SMESH_DeviceActor()
142 if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
145 myPlaneCollection->Delete();
147 myProperty->Delete();
149 myExtractGeometry->Delete();
151 myMergeFilter->Delete();
152 myExtractUnstructuredGrid->Delete();
154 // Orientation of faces
155 myFaceOrientationFilter->Delete();
156 myFaceOrientationDataMapper->RemoveAllInputs();
157 myFaceOrientationDataMapper->Delete();
158 myFaceOrientation->Delete();
160 myGeomFilter->Delete();
162 myTransformFilter->Delete();
164 for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
165 myPassFilter[i]->Delete();
167 myShrinkFilter->Delete();
173 ::SetStoreGemetryMapping(bool theStoreMapping)
175 myGeomFilter->SetStoreMapping(theStoreMapping);
176 SetStoreClippingMapping(theStoreMapping);
182 ::SetStoreClippingMapping(bool theStoreMapping)
184 myStoreClippingMapping = theStoreMapping;
185 myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
186 SetStoreIDMapping(theStoreMapping);
192 ::SetStoreIDMapping(bool theStoreMapping)
194 myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
200 ::Init(TVisualObjPtr theVisualObj,
201 vtkImplicitBoolean* theImplicitBoolean)
203 myVisualObj = theVisualObj;
204 myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
205 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
211 ::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
214 if(theIsImplicitFunctionUsed)
215 myPassFilter[ anId ]->SetInputConnection( myExtractGeometry->GetOutputPort() );
217 myPassFilter[ anId ]->SetInputConnection( myMergeFilter->GetOutputPort() );
219 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
220 SetStoreClippingMapping(myStoreClippingMapping);
226 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
229 //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
230 myIsShrinkable = true;
232 myExtractUnstructuredGrid->SetInputData(theGrid);
234 myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
236 //Pass diameters of the balls
237 if(myMapper->GetBallEnabled()) {
238 myMergeFilter->SetScalarsConnection(myExtractUnstructuredGrid->GetOutputPort());
241 myExtractGeometry->SetInputConnection(myMergeFilter->GetOutputPort());
244 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
245 myPassFilter[ anId + 1]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
248 myTransformFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
251 myPassFilter[ anId ]->SetInputConnection( myTransformFilter->GetOutputPort() );
252 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
255 myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
258 myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() );
259 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
262 myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
263 if( myPlaneCollection->GetNumberOfItems() )
264 myMapper->SetClippingPlanes( myPlaneCollection );
266 vtkLODActor::SetMapper( myMapper );
273 ::SetPlaneCollection( vtkPlaneCollection* theCollection )
275 myPlaneCollection = theCollection;
278 VTKViewer_ExtractUnstructuredGrid*
280 ::GetExtractUnstructuredGrid()
282 return myExtractUnstructuredGrid;
288 ::GetUnstructuredGrid()
290 myExtractUnstructuredGrid->Update();
291 return myExtractUnstructuredGrid->GetOutput();
297 ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
298 SMESH_ScalarBarActor* theScalarBarActor,
299 vtkLookupTable* theLookupTable)
301 bool anIsInitialized = theFunctor;
303 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
305 SetStoreIDMapping(true);
306 myExtractUnstructuredGrid->Update();
307 vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
309 aDataSet->ShallowCopy(aGrid);
311 vtkDoubleArray *aScalars = vtkDoubleArray::New();
312 vtkIdType aNbCells = aGrid->GetNumberOfCells();
313 aScalars->SetNumberOfComponents(1);
314 aScalars->SetNumberOfTuples(aNbCells);
315 double* range;// = aScalars->GetRange();
317 myVisualObj->UpdateFunctor(theFunctor);
319 using namespace SMESH::Controls;
320 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
322 for(vtkIdType i = 0; i < aNbCells; i++){
323 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
324 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
325 double aValue = aNumericalFunctor->GetValue(anObjId);
326 aScalars->SetValue(i,aValue);
328 range = aScalars->GetRange();
329 if ( range[1] - range[0] < ( qMax(qAbs(range[0]),qAbs(range[1])) + 1e-100 ) * 1e-6 )
332 for(vtkIdType i = 0; i < aNbCells; i++)
333 aScalars->SetValue(i,range[0]);
336 else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get()))
338 for(vtkIdType i = 0; i < aNbCells; i++){
339 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
340 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
341 bool aValue = aPredicate->IsSatisfy(anObjId);
342 aScalars->SetValue(i,aValue);
344 range = aScalars->GetRange();
347 aDataSet->GetCellData()->SetScalars(aScalars);
350 theLookupTable->SetRange( range );
351 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
352 theLookupTable->Build();
354 myMergeFilter->SetScalarsData(aDataSet);
357 GetMapper()->SetScalarVisibility(anIsInitialized);
358 theScalarBarActor->SetVisibility(anIsInitialized);
363 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
364 SMESH_ScalarBarActor* theScalarBarActor,
365 vtkLookupTable* theLookupTable)
367 bool anIsInitialized = theFunctor;
368 myExtractUnstructuredGrid->ClearRegisteredCells();
369 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
370 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
371 myVisualObj->UpdateFunctor(theFunctor);
373 using namespace SMESH::Controls;
374 if (anIsInitialized){
375 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
376 SMESH::Controls::Length2D::TValues aValues;
378 aLength2D->GetValues(aValues);
379 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
380 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
382 aDataSet->SetPoints(aGrid->GetPoints());
384 vtkIdType aNbCells = aValues.size();
386 vtkDoubleArray *aScalars = vtkDoubleArray::New();
387 aScalars->SetNumberOfComponents(1);
388 aScalars->SetNumberOfTuples(aNbCells);
390 vtkIdType aCellsSize = 3*aNbCells;
391 vtkCellArray* aConnectivity = vtkCellArray::New();
392 aConnectivity->Allocate( aCellsSize, 0 );
394 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
395 aCellTypesArray->SetNumberOfComponents( 1 );
396 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
398 vtkIdList *anIdList = vtkIdList::New();
399 anIdList->SetNumberOfIds(2);
401 Length2D::TValues::const_iterator anIter = aValues.begin();
402 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
403 const Length2D::Value& aValue = *anIter;
405 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
406 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
408 if(aNode[0] >= 0 && aNode[1] >= 0){
409 anIdList->SetId( 0, aNode[0] );
410 anIdList->SetId( 1, aNode[1] );
411 aConnectivity->InsertNextCell( anIdList );
412 aCellTypesArray->InsertNextValue( VTK_LINE );
413 aScalars->SetValue(aVtkId,aValue.myLength);
417 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
418 aCellLocationsArray->SetNumberOfComponents( 1 );
419 aCellLocationsArray->SetNumberOfTuples( aNbCells );
421 aConnectivity->InitTraversal();
422 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
423 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
425 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
426 SetUnstructuredGrid(aDataSet);
428 aDataSet->GetCellData()->SetScalars(aScalars);
431 theLookupTable->SetRange(aScalars->GetRange());
432 theLookupTable->Build();
434 myMergeFilter->SetScalarsData(aDataSet);
437 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
438 SMESH::Controls::MultiConnection2D::MValues aValues;
440 aMultiConnection2D->GetValues(aValues);
441 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
442 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
443 aDataSet->SetPoints(aGrid->GetPoints());
445 vtkIdType aNbCells = aValues.size();
446 vtkDoubleArray *aScalars = vtkDoubleArray::New();
447 aScalars->SetNumberOfComponents(1);
448 aScalars->SetNumberOfTuples(aNbCells);
450 vtkIdType aCellsSize = 3*aNbCells;
451 vtkCellArray* aConnectivity = vtkCellArray::New();
452 aConnectivity->Allocate( aCellsSize, 0 );
454 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
455 aCellTypesArray->SetNumberOfComponents( 1 );
456 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
458 vtkIdList *anIdList = vtkIdList::New();
459 anIdList->SetNumberOfIds(2);
461 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
462 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
463 const MultiConnection2D::Value& aValue = (*anIter).first;
465 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
466 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
468 if(aNode[0] >= 0 && aNode[1] >= 0){
469 anIdList->SetId( 0, aNode[0] );
470 anIdList->SetId( 1, aNode[1] );
471 aConnectivity->InsertNextCell( anIdList );
472 aCellTypesArray->InsertNextValue( VTK_LINE );
473 aScalars->SetValue(aVtkId,(*anIter).second);
477 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
478 aCellLocationsArray->SetNumberOfComponents( 1 );
479 aCellLocationsArray->SetNumberOfTuples( aNbCells );
481 aConnectivity->InitTraversal();
482 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
483 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
485 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
486 SetUnstructuredGrid(aDataSet);
488 aDataSet->GetCellData()->SetScalars(aScalars);
491 theLookupTable->SetRange(aScalars->GetRange());
492 theLookupTable->Build();
494 myMergeFilter->SetScalarsData(aDataSet);
498 GetMapper()->SetScalarVisibility(anIsInitialized);
499 theScalarBarActor->SetVisibility(anIsInitialized);
504 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
506 myExtractUnstructuredGrid->ClearRegisteredCells();
507 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
508 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
509 myVisualObj->UpdateFunctor(theFunctor);
511 using namespace SMESH::Controls;
512 if ( dynamic_cast<FreeBorders *>(theFunctor.get()) ||
513 dynamic_cast<FreeFaces *>(theFunctor.get()) ||
514 dynamic_cast<BareBorderVolume *>(theFunctor.get()) ||
515 dynamic_cast<BareBorderFace *>(theFunctor.get()) ||
516 dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
517 dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
518 dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
519 dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
520 dynamic_cast<OverConstrainedFace *>(theFunctor.get()))
522 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
523 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
524 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
525 vtkIdType aNbCells = aGrid->GetNumberOfCells();
526 for( vtkIdType i = 0; i < aNbCells; i++ ){
527 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
528 if(aPredicate->IsSatisfy(anObjId))
529 myExtractUnstructuredGrid->RegisterCell(i);
531 if(!myExtractUnstructuredGrid->IsCellsRegistered())
532 myExtractUnstructuredGrid->RegisterCell(-1);
533 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
535 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
537 SMESH::Controls::FreeEdges::TBorders aBorders;
538 aFreeEdges->GetBoreders(aBorders);
539 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
540 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
541 aDataSet->SetPoints(aGrid->GetPoints());
543 vtkIdType aNbCells = aBorders.size();
544 vtkIdType aCellsSize = 3*aNbCells;
545 vtkCellArray* aConnectivity = vtkCellArray::New();
546 aConnectivity->Allocate( aCellsSize, 0 );
548 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
549 aCellTypesArray->SetNumberOfComponents( 1 );
550 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
552 vtkIdList *anIdList = vtkIdList::New();
553 anIdList->SetNumberOfIds(2);
555 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
556 for(; anIter != aBorders.end(); anIter++){
557 const FreeEdges::Border& aBorder = *anIter;
559 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
560 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
562 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
563 if(aNode[0] >= 0 && aNode[1] >= 0){
564 anIdList->SetId( 0, aNode[0] );
565 anIdList->SetId( 1, aNode[1] );
566 aConnectivity->InsertNextCell( anIdList );
567 aCellTypesArray->InsertNextValue( VTK_LINE );
571 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
572 aCellLocationsArray->SetNumberOfComponents( 1 );
573 aCellLocationsArray->SetNumberOfTuples( aNbCells );
575 aConnectivity->InitTraversal();
576 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
577 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
579 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
581 SetUnstructuredGrid(aDataSet);
584 else if(dynamic_cast<FreeNodes *>(theFunctor.get()) ||
585 dynamic_cast<CoincidentNodes*>(theFunctor.get()))
587 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
588 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
589 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
590 for( vtkIdType i = 0; i < aNbNodes; i++ ){
591 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
592 if(aPredicate->IsSatisfy(anObjId))
593 myExtractUnstructuredGrid->RegisterCell(i);
595 if(!myExtractUnstructuredGrid->IsCellsRegistered())
596 myExtractUnstructuredGrid->RegisterCell(-1);
597 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
608 unsigned long mTime = this->Superclass::GetMTime();
609 mTime = max(mTime,myExtractGeometry->GetMTime());
610 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
611 mTime = max(mTime,myMergeFilter->GetMTime());
612 mTime = max(mTime,myGeomFilter->GetMTime());
613 mTime = max(mTime,myTransformFilter->GetMTime());
614 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
621 ::SetTransform(VTKViewer_Transform* theTransform)
623 myTransformFilter->SetTransform(theTransform);
631 if ( !myIsShrinkable ) return;
632 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
634 myShrinkFilter->SetInputConnection( aDataSet );
635 myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() );
644 if ( !myIsShrunk ) return;
645 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
647 myPassFilter[ 1 ]->SetInputConnection( aDataSet );
648 myPassFilter[ 1 ]->Modified();
657 ::SetFacesOriented(bool theIsFacesOriented)
659 if ( vtkAlgorithmOutput* aDataSet = myTransformFilter->GetOutputPort() )
661 myIsFacesOriented = theIsFacesOriented;
662 if( theIsFacesOriented )
663 myFaceOrientationFilter->SetInputConnection( aDataSet );
664 UpdateFaceOrientation();
670 ::SetFacesOrientationColor(double r,double g,double b)
672 myFaceOrientation->GetProperty()->SetColor( r, g, b );
677 ::GetFacesOrientationColor(double& r,double& g,double& b)
679 myFaceOrientation->GetProperty()->GetColor( r, g, b );
684 ::SetFacesOrientationScale(double theScale)
686 myFaceOrientationFilter->SetOrientationScale( theScale );
691 ::GetFacesOrientationScale()
693 return myFaceOrientationFilter->GetOrientationScale();
698 ::SetFacesOrientation3DVectors(bool theState)
700 myFaceOrientationFilter->Set3dVectors( theState );
705 ::GetFacesOrientation3DVectors()
707 return myFaceOrientationFilter->Get3dVectors();
712 ::UpdateFaceOrientation()
714 bool aShowFaceOrientation = myIsFacesOriented;
715 aShowFaceOrientation &= GetVisibility();
716 aShowFaceOrientation &= myRepresentation == eSurface;
717 myFaceOrientation->SetVisibility(aShowFaceOrientation);
723 ::SetRepresentation(EReperesent theMode)
727 myGeomFilter->SetInside(true);
728 myGeomFilter->SetWireframeMode(false);
729 GetProperty()->SetRepresentation(0);
732 myGeomFilter->SetInside(false);
733 myGeomFilter->SetWireframeMode(true);
734 GetProperty()->SetRepresentation(theMode);
737 myGeomFilter->SetInside(true);
738 myGeomFilter->SetWireframeMode(true);
739 GetProperty()->SetRepresentation(1);
742 myGeomFilter->SetInside(false);
743 myGeomFilter->SetWireframeMode(false);
744 GetProperty()->SetRepresentation(theMode);
746 SetMarkerEnabled(theMode == ePoint);
747 myRepresentation = theMode;
748 UpdateFaceOrientation();
749 GetProperty()->Modified();
750 myMapper->Modified();
757 ::SetVisibility(int theMode)
759 if(!myExtractUnstructuredGrid->GetInput() ||
760 GetUnstructuredGrid()->GetNumberOfCells())
762 vtkLODActor::SetVisibility(theMode);
764 vtkLODActor::SetVisibility(false);
766 UpdateFaceOrientation();
774 if(!GetUnstructuredGrid()->GetNumberOfCells()){
775 vtkLODActor::SetVisibility(false);
777 return vtkLODActor::GetVisibility();
783 ::AddToRender(vtkRenderer* theRenderer)
785 theRenderer->AddActor(this);
786 theRenderer->AddActor(myFaceOrientation);
791 ::RemoveFromRender(vtkRenderer* theRenderer)
793 theRenderer->RemoveActor(this);
794 theRenderer->RemoveActor(myFaceOrientation);
800 ::GetNodeObjId(int theVtkID)
802 vtkIdType anID = theVtkID;
804 if(IsImplicitFunctionUsed())
805 anID = myExtractGeometry->GetNodeObjId(theVtkID);
807 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
808 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
814 ::GetNodeCoord(int theObjID)
816 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
817 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
818 double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
819 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
826 ::GetElemObjId(int theVtkID)
828 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
832 vtkIdType anId2 = anId;
833 if(IsImplicitFunctionUsed())
834 anId2 = myExtractGeometry->GetElemObjId(anId);
838 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
842 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
844 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
850 ::GetElemCell(int theObjID)
852 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
853 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
854 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
856 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
865 return myShrinkFilter->GetShrinkFactor();
870 ::SetShrinkFactor(double theValue)
872 theValue = theValue > 0.1? theValue: 0.8;
873 myShrinkFilter->SetShrinkFactor(theValue);
880 ::SetHighlited(bool theIsHighlited)
882 if ( myIsHighlited == theIsHighlited )
884 myIsHighlited = theIsHighlited;
890 ::Render(vtkRenderer *ren, vtkMapper* m)
892 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
893 double aStoredFactor, aStoredUnit;
894 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
896 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
897 double aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
899 static double EPS = .01;
902 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
903 vtkLODActor::Render(ren,m);
905 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
906 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
912 ::SetPolygonOffsetParameters(double factor,
915 myPolygonOffsetFactor = factor;
916 myPolygonOffsetUnits = units;
920 * On/Off representation 2D quadratic element as arked polygon
922 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
923 myGeomFilter->SetQuadraticArcMode(theFlag);
927 * Return true if 2D quadratic element displayed as arked polygon
929 bool SMESH_DeviceActor::GetQuadraticArcMode(){
930 return myGeomFilter->GetQuadraticArcMode();
933 * Set Max angle for representation 2D quadratic element as arked polygon
935 void SMESH_DeviceActor::SetQuadraticArcAngle(double theMaxAngle){
936 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
940 * Return Max angle of the representation 2D quadratic element as arked polygon
942 double SMESH_DeviceActor::GetQuadraticArcAngle(){
943 return myGeomFilter->GetQuadraticArcAngle();
947 * Set point marker enabled
948 * \param theMarkerEnabled flag to enable/disable point marker
950 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
952 myMapper->SetMarkerEnabled( theMarkerEnabled );
956 * Set point marker enabled
957 * \param theBallEnabled flag to enable/disable ball drawing
959 void SMESH_DeviceActor::SetBallEnabled( bool theBallEnabled ) {
960 myMapper->SetBallEnabled( theBallEnabled );
964 * Set standard point marker
965 * \param theMarkerType type of the marker
967 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
969 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
973 * Set custom point marker
974 * \param theMarkerId id of the marker texture
975 * \param theMarkerTexture marker texture
977 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
979 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
983 * Get type of the point marker
984 * \return type of the point marker
986 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
988 return myMapper->GetMarkerType();
992 Get scale of the point marker
993 \return scale of the point marker
995 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
997 return myMapper->GetMarkerScale();
1001 * Get texture identifier of the point marker
1002 * \return texture identifier of the point marker
1004 int SMESH_DeviceActor::GetMarkerTexture()
1006 return myMapper->GetMarkerTexture();
1009 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
1010 myGeomFilter->SetAppendCoincident3D(theFlag);
1013 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
1014 return myGeomFilter->GetAppendCoincident3D();