1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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(); -- it is vtkSmartPointer
146 myProperty->Delete();
148 myExtractGeometry->Delete();
150 myMergeFilter->Delete();
151 myExtractUnstructuredGrid->Delete();
153 // Orientation of faces
154 myFaceOrientationFilter->Delete();
155 myFaceOrientationDataMapper->RemoveAllInputs();
156 myFaceOrientationDataMapper->Delete();
157 myFaceOrientation->Delete();
159 myGeomFilter->Delete();
161 myTransformFilter->Delete();
163 for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
164 myPassFilter[i]->Delete();
166 myShrinkFilter->Delete();
172 ::SetStoreGemetryMapping(bool theStoreMapping)
174 myGeomFilter->SetStoreMapping(theStoreMapping);
175 // for optimization, switch the mapping explicitly in each filter/algorithm
176 //SetStoreClippingMapping(theStoreMapping);
182 ::SetStoreClippingMapping(bool theStoreMapping)
184 myStoreClippingMapping = theStoreMapping;
185 myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
187 // Mapping in myExtractUnstructuredGrid and myGeomFilter is ON in the pickable DeviceActor only.
188 // To show labels, the mapping is computed explicitly via myExtractUnstructuredGrid->BuildOut2InMap();
189 //SetStoreIDMapping(theStoreMapping);
195 ::SetStoreIDMapping(bool theStoreMapping)
197 myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
203 ::Init(TVisualObjPtr theVisualObj,
204 vtkImplicitBoolean* theImplicitBoolean)
206 myVisualObj = theVisualObj;
207 myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
208 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
213 ::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
216 if(theIsImplicitFunctionUsed)
217 myPassFilter[ anId ]->SetInputConnection( myExtractGeometry->GetOutputPort() );
219 myPassFilter[ anId ]->SetInputConnection( myMergeFilter->GetOutputPort() );
221 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
222 SetStoreClippingMapping(myStoreClippingMapping);
228 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
230 myExtractUnstructuredGrid->SetInputData(theGrid);
234 myIsShrinkable = true;
236 myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
238 //Pass diameters of the balls
239 if(myMapper->GetBallEnabled()) {
240 myMergeFilter->SetScalarsConnection(myExtractUnstructuredGrid->GetOutputPort());
243 myExtractGeometry->SetInputConnection(myMergeFilter->GetOutputPort());
246 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
247 myPassFilter[ anId + 1]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
250 myTransformFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
253 myPassFilter[ anId ]->SetInputConnection( myTransformFilter->GetOutputPort() );
254 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
257 myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
260 myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() );
261 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
264 myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
265 if( myPlaneCollection->GetNumberOfItems() )
266 myMapper->SetClippingPlanes( myPlaneCollection );
268 vtkLODActor::SetMapper( myMapper );
275 ::SetPlaneCollection( vtkPlaneCollection* theCollection )
277 myPlaneCollection = theCollection;
280 VTKViewer_ExtractUnstructuredGrid*
282 ::GetExtractUnstructuredGrid()
284 return myExtractUnstructuredGrid;
287 #include "SMDS_Mesh.hxx"
291 ::GetUnstructuredGrid()
293 myExtractUnstructuredGrid->Update();
294 return myExtractUnstructuredGrid->GetOutput();
300 ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
301 SMESH_ScalarBarActor* theScalarBarActor,
302 vtkLookupTable* theLookupTable)
304 bool anIsInitialized = theFunctor != NULL;
306 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
308 // SetStoreIDMapping(true);
309 // myExtractUnstructuredGrid->Update();
310 vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
312 aDataSet->ShallowCopy(aGrid);
314 vtkDoubleArray *aScalars = vtkDoubleArray::New();
315 vtkIdType aNbCells = aGrid->GetNumberOfCells();
316 aScalars->SetNumberOfComponents(1);
317 aScalars->SetNumberOfTuples(aNbCells);
318 double* range = 0;// = aScalars->GetRange();
320 myVisualObj->UpdateFunctor(theFunctor);
322 using namespace SMESH::Controls;
323 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
325 myExtractUnstructuredGrid->BuildOut2InMap();
326 for(vtkIdType i = 0; i < aNbCells; i++)
328 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
329 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
330 double aValue = aNumericalFunctor->GetValue(anObjId);
331 aScalars->SetValue(i,aValue);
333 range = aScalars->GetRange();
334 if ( range[1] - range[0] < ( qMax(qAbs(range[0]),qAbs(range[1])) + 1e-100 ) * 1e-6 )
337 for(vtkIdType i = 0; i < aNbCells; i++)
338 aScalars->SetValue(i,range[0]);
341 else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get()))
343 myExtractUnstructuredGrid->BuildOut2InMap();
344 for(vtkIdType i = 0; i < aNbCells; i++)
346 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
347 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
348 bool aValue = aPredicate->IsSatisfy(anObjId);
349 aScalars->SetValue(i,aValue);
351 range = aScalars->GetRange();
354 aDataSet->GetCellData()->SetScalars(aScalars);
357 theLookupTable->SetRange( range );
358 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
359 theLookupTable->Build();
361 myMergeFilter->SetScalarsData(aDataSet);
364 GetMapper()->SetScalarVisibility(anIsInitialized);
365 theScalarBarActor->SetVisibility(anIsInitialized);
370 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
371 SMESH_ScalarBarActor* theScalarBarActor,
372 vtkLookupTable* theLookupTable)
374 bool anIsInitialized = theFunctor != NULL;
375 myExtractUnstructuredGrid->ClearRegisteredCells();
376 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
377 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
378 myVisualObj->UpdateFunctor(theFunctor);
380 using namespace SMESH::Controls;
381 if (anIsInitialized){
382 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
383 SMESH::Controls::Length2D::TValues aValues;
385 aLength2D->GetValues(aValues);
386 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
387 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
389 aDataSet->SetPoints(aGrid->GetPoints());
391 vtkIdType aNbCells = aValues.size();
393 vtkDoubleArray *aScalars = vtkDoubleArray::New();
394 aScalars->SetNumberOfComponents(1);
395 aScalars->SetNumberOfTuples(aNbCells);
397 vtkIdType aCellsSize = 3*aNbCells;
398 vtkCellArray* aConnectivity = vtkCellArray::New();
399 aConnectivity->Allocate( aCellsSize, 0 );
401 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
402 aCellTypesArray->SetNumberOfComponents( 1 );
403 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
405 vtkIdList *anIdList = vtkIdList::New();
406 anIdList->SetNumberOfIds(2);
408 Length2D::TValues::const_iterator anIter = aValues.begin();
410 for(; anIter != aValues.end(); anIter++){
411 const Length2D::Value& aValue = *anIter;
413 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
414 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
416 if(aNode[0] >= 0 && aNode[1] >= 0){
417 anIdList->SetId( 0, aNode[0] );
418 anIdList->SetId( 1, aNode[1] );
419 aConnectivity->InsertNextCell( anIdList );
420 aCellTypesArray->InsertNextValue( VTK_LINE );
421 aScalars->SetValue(aNbCells,aValue.myLength);
425 aCellTypesArray->SetNumberOfTuples( aNbCells );
426 aScalars->SetNumberOfTuples( aNbCells );
428 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
429 aCellLocationsArray->SetNumberOfComponents( 1 );
430 aCellLocationsArray->SetNumberOfTuples( aNbCells );
432 aConnectivity->InitTraversal();
433 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
434 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
436 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray, aConnectivity );
437 SetUnstructuredGrid(aDataSet);
439 aDataSet->GetCellData()->SetScalars(aScalars);
442 theLookupTable->SetRange(aScalars->GetRange());
443 theLookupTable->Build();
445 myMergeFilter->SetScalarsData(aDataSet);
448 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
449 SMESH::Controls::MultiConnection2D::MValues aValues;
451 aMultiConnection2D->GetValues(aValues);
452 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
453 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
454 aDataSet->SetPoints(aGrid->GetPoints());
456 vtkIdType aNbCells = aValues.size();
457 vtkDoubleArray *aScalars = vtkDoubleArray::New();
458 aScalars->SetNumberOfComponents(1);
459 aScalars->SetNumberOfTuples(aNbCells);
461 vtkIdType aCellsSize = 3*aNbCells;
462 vtkCellArray* aConnectivity = vtkCellArray::New();
463 aConnectivity->Allocate( aCellsSize, 0 );
465 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
466 aCellTypesArray->SetNumberOfComponents( 1 );
467 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
469 vtkIdList *anIdList = vtkIdList::New();
470 anIdList->SetNumberOfIds(2);
472 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
474 for(; anIter != aValues.end(); anIter++){
475 const MultiConnection2D::Value& aValue = (*anIter).first;
477 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
478 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
480 if(aNode[0] >= 0 && aNode[1] >= 0){
481 anIdList->SetId( 0, aNode[0] );
482 anIdList->SetId( 1, aNode[1] );
483 aConnectivity->InsertNextCell( anIdList );
484 aCellTypesArray->InsertNextValue( VTK_LINE );
485 aScalars->SetValue( aNbCells,(*anIter).second);
489 aCellTypesArray->SetNumberOfTuples( aNbCells );
490 aScalars->SetNumberOfTuples( aNbCells );
492 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
493 aCellLocationsArray->SetNumberOfComponents( 1 );
494 aCellLocationsArray->SetNumberOfTuples( aNbCells );
496 aConnectivity->InitTraversal();
497 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
498 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
500 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
501 SetUnstructuredGrid(aDataSet);
503 aDataSet->GetCellData()->SetScalars(aScalars);
506 theLookupTable->SetRange(aScalars->GetRange());
507 theLookupTable->Build();
509 myMergeFilter->SetScalarsData(aDataSet);
513 GetMapper()->SetScalarVisibility(anIsInitialized);
514 theScalarBarActor->SetVisibility(anIsInitialized);
519 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
521 myExtractUnstructuredGrid->ClearRegisteredCells();
522 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
523 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
524 myVisualObj->UpdateFunctor(theFunctor);
526 using namespace SMESH::Controls;
527 Predicate* aPredicate = 0;
528 if (( aPredicate = dynamic_cast<FreeBorders *>(theFunctor.get())) ||
529 ( aPredicate = dynamic_cast<FreeFaces *>(theFunctor.get())) ||
530 ( aPredicate = dynamic_cast<BareBorderVolume *>(theFunctor.get())) ||
531 ( aPredicate = dynamic_cast<BareBorderFace *>(theFunctor.get())) ||
532 ( aPredicate = dynamic_cast<OverConstrainedVolume*>(theFunctor.get())) ||
533 ( aPredicate = dynamic_cast<CoincidentElements1D *>(theFunctor.get())) ||
534 ( aPredicate = dynamic_cast<CoincidentElements2D *>(theFunctor.get())) ||
535 ( aPredicate = dynamic_cast<CoincidentElements3D *>(theFunctor.get())) ||
536 ( aPredicate = dynamic_cast<OverConstrainedFace *>(theFunctor.get())))
538 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
539 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
540 vtkIdType aNbCells = aGrid->GetNumberOfCells();
541 for( vtkIdType i = 0; i < aNbCells; i++ ){
542 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
543 if(aPredicate->IsSatisfy(anObjId))
544 myExtractUnstructuredGrid->RegisterCell(i);
546 if(!myExtractUnstructuredGrid->IsCellsRegistered())
547 myExtractUnstructuredGrid->RegisterCell(-1);
548 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
550 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
552 SMESH::Controls::FreeEdges::TBorders aBorders;
553 aFreeEdges->GetBoreders(aBorders);
554 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
555 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
556 aDataSet->SetPoints(aGrid->GetPoints());
558 vtkIdType aNbCells = aBorders.size();
559 vtkIdType aCellsSize = 3*aNbCells;
560 vtkCellArray* aConnectivity = vtkCellArray::New();
561 aConnectivity->Allocate( aCellsSize, 0 );
563 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
564 aCellTypesArray->SetNumberOfComponents( 1 );
565 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
567 vtkIdList *anIdList = vtkIdList::New();
568 anIdList->SetNumberOfIds(2);
570 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
571 for(; anIter != aBorders.end(); anIter++){
572 const FreeEdges::Border& aBorder = *anIter;
574 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
575 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
577 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
578 if(aNode[0] >= 0 && aNode[1] >= 0){
579 anIdList->SetId( 0, aNode[0] );
580 anIdList->SetId( 1, aNode[1] );
581 aConnectivity->InsertNextCell( anIdList );
582 aCellTypesArray->InsertNextValue( VTK_LINE );
586 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
587 aCellLocationsArray->SetNumberOfComponents( 1 );
588 aCellLocationsArray->SetNumberOfTuples( aNbCells );
590 aConnectivity->InitTraversal();
591 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
592 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
594 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
596 SetUnstructuredGrid(aDataSet);
599 else if (( aPredicate = dynamic_cast<FreeNodes *>(theFunctor.get())) ||
600 ( aPredicate = dynamic_cast<CoincidentNodes*>(theFunctor.get())))
602 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
603 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
604 for( vtkIdType i = 0; i < aNbNodes; i++ ){
605 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
606 if(aPredicate->IsSatisfy(anObjId))
607 myExtractUnstructuredGrid->RegisterCell(i);
609 if(!myExtractUnstructuredGrid->IsCellsRegistered())
610 myExtractUnstructuredGrid->RegisterCell(-1);
611 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
622 // cout << this->myExtractUnstructuredGrid
623 // << " " << this->Superclass::GetMTime()
624 // << " " << myExtractGeometry->GetMTime()
625 // << " " << myExtractUnstructuredGrid->GetMTime()
626 // << " " << myMergeFilter->GetMTime()
627 // << " " << myGeomFilter->GetMTime()
628 // << " " << myTransformFilter->GetMTime()
629 // << " " << myFaceOrientationFilter->GetMTime() << endl;
631 unsigned long mTime = this->Superclass::GetMTime();
632 mTime = max(mTime,myExtractGeometry->GetMTime());
633 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
634 mTime = max(mTime,myMergeFilter->GetMTime());
635 mTime = max(mTime,myGeomFilter->GetMTime());
636 mTime = max(mTime,myTransformFilter->GetMTime());
637 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
644 ::SetTransform(VTKViewer_Transform* theTransform)
646 myTransformFilter->SetTransform(theTransform);
654 if ( !myIsShrinkable ) return;
655 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
657 myShrinkFilter->SetInputConnection( aDataSet );
658 myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() );
667 if ( !myIsShrunk ) return;
668 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
670 myPassFilter[ 1 ]->SetInputConnection( aDataSet );
671 myPassFilter[ 1 ]->Modified();
680 ::SetFacesOriented(bool theIsFacesOriented)
682 if ( vtkAlgorithmOutput* aDataSet = myTransformFilter->GetOutputPort() )
684 myIsFacesOriented = theIsFacesOriented;
685 if( theIsFacesOriented )
686 myFaceOrientationFilter->SetInputConnection( aDataSet );
687 UpdateFaceOrientation();
693 ::SetFacesOrientationColor(double r,double g,double b)
695 myFaceOrientation->GetProperty()->SetColor( r, g, b );
700 ::GetFacesOrientationColor(double& r,double& g,double& b)
702 myFaceOrientation->GetProperty()->GetColor( r, g, b );
707 ::SetFacesOrientationScale(double theScale)
709 myFaceOrientationFilter->SetOrientationScale( theScale );
714 ::GetFacesOrientationScale()
716 return myFaceOrientationFilter->GetOrientationScale();
721 ::SetFacesOrientation3DVectors(bool theState)
723 myFaceOrientationFilter->Set3dVectors( theState );
728 ::GetFacesOrientation3DVectors()
730 return myFaceOrientationFilter->Get3dVectors();
735 ::UpdateFaceOrientation()
737 bool aShowFaceOrientation = myIsFacesOriented;
738 aShowFaceOrientation &= vtkLODActor::GetVisibility(); //GetVisibility(); -- avoid calling GetUnstructuredGrid()
739 aShowFaceOrientation &= myRepresentation == eSurface;
740 myFaceOrientation->SetVisibility(aShowFaceOrientation);
746 ::SetRepresentation(EReperesent theMode)
750 myGeomFilter->SetInside(true);
751 myGeomFilter->SetWireframeMode(false);
752 GetProperty()->SetRepresentation(0);
755 myGeomFilter->SetInside(false);
756 myGeomFilter->SetWireframeMode(true);
757 GetProperty()->SetRepresentation(theMode);
760 myGeomFilter->SetInside(true);
761 myGeomFilter->SetWireframeMode(true);
762 GetProperty()->SetRepresentation(1);
765 myGeomFilter->SetInside(false);
766 myGeomFilter->SetWireframeMode(false);
767 GetProperty()->SetRepresentation(theMode);
769 SetMarkerEnabled(theMode == ePoint);
770 myRepresentation = theMode;
771 UpdateFaceOrientation();
772 GetProperty()->Modified();
773 myMapper->Modified();
780 ::SetVisibility(int theMode)
783 ( !myExtractUnstructuredGrid->GetInput() ||
784 GetUnstructuredGrid()->GetNumberOfCells()))
786 vtkLODActor::SetVisibility(theMode);
788 vtkLODActor::SetVisibility(false);
790 UpdateFaceOrientation();
798 int visibi = vtkLODActor::GetVisibility();
799 if(visibi && !GetUnstructuredGrid()->GetNumberOfCells()){
800 vtkLODActor::SetVisibility(false);
809 ::AddToRender(vtkRenderer* theRenderer)
811 theRenderer->AddActor(this);
812 theRenderer->AddActor(myFaceOrientation);
817 ::RemoveFromRender(vtkRenderer* theRenderer)
819 theRenderer->RemoveActor(this);
820 theRenderer->RemoveActor(myFaceOrientation);
826 ::GetNodeObjId(int theVtkID)
828 vtkIdType anID = theVtkID;
830 if(IsImplicitFunctionUsed())
831 anID = myExtractGeometry->GetNodeObjId(theVtkID);
833 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
834 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
840 ::GetNodeCoord(int theObjID)
842 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
843 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
844 double* aCoord = (anID >=0 && anID < aDataSet->GetNumberOfPoints()) ? aDataSet->GetPoint(anID) : NULL;
845 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
852 ::GetElemObjId(int theVtkID)
854 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
858 vtkIdType anId2 = anId;
859 if(IsImplicitFunctionUsed())
860 anId2 = myExtractGeometry->GetElemObjId(anId);
864 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
868 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
870 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
876 ::GetElemCell(int theObjID)
878 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
879 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
880 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
882 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
891 return myShrinkFilter->GetShrinkFactor();
896 ::SetShrinkFactor(double theValue)
898 theValue = theValue > 0.1? theValue: 0.8;
899 myShrinkFilter->SetShrinkFactor(theValue);
906 ::SetHighlited(bool theIsHighlited)
908 if ( myIsHighlited == theIsHighlited )
910 myIsHighlited = theIsHighlited;
916 ::Render(vtkRenderer *ren, vtkMapper* m)
918 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
919 double aStoredFactor, aStoredUnit;
920 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
922 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
923 double aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
925 static double EPS = .01;
928 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
929 vtkLODActor::Render(ren,m);
931 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
932 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
938 ::SetPolygonOffsetParameters(double factor,
941 myPolygonOffsetFactor = factor;
942 myPolygonOffsetUnits = units;
946 * On/Off representation 2D quadratic element as arked polygon
948 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
949 myGeomFilter->SetQuadraticArcMode(theFlag);
953 * Return true if 2D quadratic element displayed as arked polygon
955 bool SMESH_DeviceActor::GetQuadraticArcMode(){
956 return myGeomFilter->GetQuadraticArcMode();
959 * Set Max angle for representation 2D quadratic element as arked polygon
961 void SMESH_DeviceActor::SetQuadraticArcAngle(double theMaxAngle){
962 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
966 * Return Max angle of the representation 2D quadratic element as arked polygon
968 double SMESH_DeviceActor::GetQuadraticArcAngle(){
969 return myGeomFilter->GetQuadraticArcAngle();
973 * Set point marker enabled
974 * \param theMarkerEnabled flag to enable/disable point marker
976 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
978 myMapper->SetMarkerEnabled( theMarkerEnabled );
982 * Set point marker enabled
983 * \param theBallEnabled flag to enable/disable ball drawing
985 void SMESH_DeviceActor::SetBallEnabled( bool theBallEnabled ) {
986 myMapper->SetBallEnabled( theBallEnabled );
990 * Set point marker scale factor
991 * \param theBallScale double value which specifies a scale factor of ball element
993 void SMESH_DeviceActor::SetBallScale( double theBallScale )
995 myMapper->SetBallScale( theBallScale );
996 myMapper->Modified();
1000 * Set standard point marker
1001 * \param theMarkerType type of the marker
1003 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
1005 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
1009 * Set custom point marker
1010 * \param theMarkerId id of the marker texture
1011 * \param theMarkerTexture marker texture
1013 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
1015 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
1019 * Get type of the point marker
1020 * \return type of the point marker
1022 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
1024 return myMapper->GetMarkerType();
1028 Get scale of the point marker
1029 \return scale of the point marker
1031 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
1033 return myMapper->GetMarkerScale();
1037 * Get texture identifier of the point marker
1038 * \return texture identifier of the point marker
1040 int SMESH_DeviceActor::GetMarkerTexture()
1042 return myMapper->GetMarkerTexture();
1046 * Get scale factor of ball element
1047 * \return scale factor of ball element
1049 double SMESH_DeviceActor::GetBallScale()
1051 return myMapper->GetBallScale();
1054 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
1055 myGeomFilter->SetAppendCoincident3D(theFlag);
1058 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
1059 return myGeomFilter->GetAppendCoincident3D();