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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESH_DeviceActor.cxx
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_ExtractGeometry.h"
32 #include "SMESH_ControlsDef.hxx"
33 #include "SMESH_ActorUtils.h"
34 #include "SMESH_FaceOrientationFilter.h"
35 #include "VTKViewer_CellLocationsArray.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 <vtkScalarBarActor.h>
53 #include <vtkLookupTable.h>
54 #include <vtkDoubleArray.h>
55 #include <vtkCellData.h>
58 #include <vtkIdList.h>
59 #include <vtkCellArray.h>
60 #include <vtkUnsignedCharArray.h>
62 #include <vtkImplicitBoolean.h>
63 #include <vtkPassThroughFilter.h>
65 #include <vtkRenderer.h>
67 #include "utilities.h"
70 static int MYDEBUG = 0;
72 static int MYDEBUG = 0;
78 vtkStandardNewMacro(SMESH_DeviceActor);
84 if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
86 myIsShrinkable = false;
88 myIsHighlited = false;
90 myRepresentation = eSurface;
92 myProperty = vtkProperty::New();
93 myMapper = vtkPolyDataMapper::New();
95 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
96 myPolygonOffsetUnits);
98 myMapper->UseLookupTableScalarRangeOn();
99 myMapper->SetColorModeToMapScalars();
101 myShrinkFilter = vtkShrinkFilter::New();
103 myStoreClippingMapping = false;
105 myExtractGeometry = SMESH_ExtractGeometry::New();
106 myExtractGeometry->SetReleaseDataFlag(true);
107 myIsImplicitFunctionUsed = false;
109 myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
111 myMergeFilter = vtkMergeFilter::New();
113 myGeomFilter = VTKViewer_GeometryFilter::New();
115 myTransformFilter = VTKViewer_TransformFilter::New();
117 for(int i = 0; i < 6; i++)
118 myPassFilter.push_back(vtkPassThroughFilter::New());
120 // Orientation of faces
121 myIsFacesOriented = false;
123 vtkFloatingPointType anRGB[3] = { 1, 1, 1 };
124 SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
126 myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
128 myFaceOrientationDataMapper = vtkPolyDataMapper::New();
129 myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());
131 myFaceOrientation = vtkActor::New();
132 myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
133 myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]);
138 ::~SMESH_DeviceActor()
140 if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
142 myProperty->Delete();
146 myShrinkFilter->Delete();
148 myExtractUnstructuredGrid->Delete();
150 myMergeFilter->Delete();
152 myGeomFilter->Delete();
154 myExtractGeometry->Delete();
156 myTransformFilter->Delete();
158 for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
159 myPassFilter[i]->Delete();
162 // Orientation of faces
163 myFaceOrientationFilter->Delete();
165 myFaceOrientationDataMapper->RemoveAllInputs();
166 myFaceOrientationDataMapper->Delete();
168 myFaceOrientation->Delete();
174 ::SetStoreGemetryMapping(bool theStoreMapping)
176 myGeomFilter->SetStoreMapping(theStoreMapping);
177 SetStoreClippingMapping(theStoreMapping);
183 ::SetStoreClippingMapping(bool theStoreMapping)
185 myStoreClippingMapping = theStoreMapping;
186 myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
187 SetStoreIDMapping(theStoreMapping);
193 ::SetStoreIDMapping(bool theStoreMapping)
195 myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
201 ::Init(TVisualObjPtr theVisualObj,
202 vtkImplicitBoolean* theImplicitBoolean)
204 myVisualObj = theVisualObj;
205 myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
206 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
212 ::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
215 if(theIsImplicitFunctionUsed)
216 myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
218 myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
220 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
221 SetStoreClippingMapping(myStoreClippingMapping);
227 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
230 //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
231 myIsShrinkable = true;
233 myExtractUnstructuredGrid->SetInput(theGrid);
235 myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
237 myExtractGeometry->SetInput(myMergeFilter->GetOutput());
240 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
241 myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
244 myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
247 myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
248 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
251 myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
254 myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
255 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
258 myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
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 vtkScalarBarActor* 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);
304 myVisualObj->UpdateFunctor(theFunctor);
306 using namespace SMESH::Controls;
307 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
308 for(vtkIdType i = 0; i < aNbCells; i++){
309 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
310 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
311 double aValue = aNumericalFunctor->GetValue(anObjId);
312 aScalars->SetValue(i,aValue);
314 }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
315 for(vtkIdType i = 0; i < aNbCells; i++){
316 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
317 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
318 bool aValue = aPredicate->IsSatisfy(anObjId);
319 aScalars->SetValue(i,aValue);
323 aDataSet->GetCellData()->SetScalars(aScalars);
326 theLookupTable->SetRange(aScalars->GetRange());
327 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
328 theLookupTable->Build();
330 myMergeFilter->SetScalars(aDataSet);
333 GetMapper()->SetScalarVisibility(anIsInitialized);
334 theScalarBarActor->SetVisibility(anIsInitialized);
339 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
340 vtkScalarBarActor* theScalarBarActor,
341 vtkLookupTable* theLookupTable)
343 bool anIsInitialized = theFunctor;
344 myExtractUnstructuredGrid->ClearRegisteredCells();
345 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
346 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
347 myVisualObj->UpdateFunctor(theFunctor);
349 using namespace SMESH::Controls;
350 if (anIsInitialized){
351 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
352 SMESH::Controls::Length2D::TValues aValues;
354 aLength2D->GetValues(aValues);
355 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
356 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
358 aDataSet->SetPoints(aGrid->GetPoints());
360 vtkIdType aNbCells = aValues.size();
362 vtkDoubleArray *aScalars = vtkDoubleArray::New();
363 aScalars->SetNumberOfComponents(1);
364 aScalars->SetNumberOfTuples(aNbCells);
366 vtkIdType aCellsSize = 3*aNbCells;
367 vtkCellArray* aConnectivity = vtkCellArray::New();
368 aConnectivity->Allocate( aCellsSize, 0 );
370 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
371 aCellTypesArray->SetNumberOfComponents( 1 );
372 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
374 vtkIdList *anIdList = vtkIdList::New();
375 anIdList->SetNumberOfIds(2);
377 Length2D::TValues::const_iterator anIter = aValues.begin();
378 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
379 const Length2D::Value& aValue = *anIter;
381 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
382 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
384 if(aNode[0] >= 0 && aNode[1] >= 0){
385 anIdList->SetId( 0, aNode[0] );
386 anIdList->SetId( 1, aNode[1] );
387 aConnectivity->InsertNextCell( anIdList );
388 aCellTypesArray->InsertNextValue( VTK_LINE );
389 aScalars->SetValue(aVtkId,aValue.myLength);
393 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
394 aCellLocationsArray->SetNumberOfComponents( 1 );
395 aCellLocationsArray->SetNumberOfTuples( aNbCells );
397 aConnectivity->InitTraversal();
398 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
399 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
401 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
402 SetUnstructuredGrid(aDataSet);
404 aDataSet->GetCellData()->SetScalars(aScalars);
407 theLookupTable->SetRange(aScalars->GetRange());
408 theLookupTable->Build();
410 myMergeFilter->SetScalars(aDataSet);
413 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
414 SMESH::Controls::MultiConnection2D::MValues aValues;
416 aMultiConnection2D->GetValues(aValues);
417 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
418 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
419 aDataSet->SetPoints(aGrid->GetPoints());
421 vtkIdType aNbCells = aValues.size();
422 vtkDoubleArray *aScalars = vtkDoubleArray::New();
423 aScalars->SetNumberOfComponents(1);
424 aScalars->SetNumberOfTuples(aNbCells);
426 vtkIdType aCellsSize = 3*aNbCells;
427 vtkCellArray* aConnectivity = vtkCellArray::New();
428 aConnectivity->Allocate( aCellsSize, 0 );
430 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
431 aCellTypesArray->SetNumberOfComponents( 1 );
432 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
434 vtkIdList *anIdList = vtkIdList::New();
435 anIdList->SetNumberOfIds(2);
437 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
438 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
439 const MultiConnection2D::Value& aValue = (*anIter).first;
441 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
442 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
444 if(aNode[0] >= 0 && aNode[1] >= 0){
445 anIdList->SetId( 0, aNode[0] );
446 anIdList->SetId( 1, aNode[1] );
447 aConnectivity->InsertNextCell( anIdList );
448 aCellTypesArray->InsertNextValue( VTK_LINE );
449 aScalars->SetValue(aVtkId,(*anIter).second);
453 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
454 aCellLocationsArray->SetNumberOfComponents( 1 );
455 aCellLocationsArray->SetNumberOfTuples( aNbCells );
457 aConnectivity->InitTraversal();
458 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
459 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
461 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
462 SetUnstructuredGrid(aDataSet);
464 aDataSet->GetCellData()->SetScalars(aScalars);
467 theLookupTable->SetRange(aScalars->GetRange());
468 theLookupTable->Build();
470 myMergeFilter->SetScalars(aDataSet);
474 GetMapper()->SetScalarVisibility(anIsInitialized);
475 theScalarBarActor->SetVisibility(anIsInitialized);
480 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
482 myExtractUnstructuredGrid->ClearRegisteredCells();
483 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
484 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
485 myVisualObj->UpdateFunctor(theFunctor);
487 using namespace SMESH::Controls;
488 if(FreeBorders* aFreeBorders = dynamic_cast<FreeBorders*>(theFunctor.get())){
489 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
490 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
491 vtkIdType aNbCells = aGrid->GetNumberOfCells();
492 for( vtkIdType i = 0; i < aNbCells; i++ ){
493 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
494 if(aFreeBorders->IsSatisfy(anObjId))
495 myExtractUnstructuredGrid->RegisterCell(i);
497 if(!myExtractUnstructuredGrid->IsCellsRegistered())
498 myExtractUnstructuredGrid->RegisterCell(-1);
499 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
500 }else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get())){
501 SMESH::Controls::FreeEdges::TBorders aBorders;
502 aFreeEdges->GetBoreders(aBorders);
503 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
504 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
505 aDataSet->SetPoints(aGrid->GetPoints());
507 vtkIdType aNbCells = aBorders.size();
508 vtkIdType aCellsSize = 3*aNbCells;
509 vtkCellArray* aConnectivity = vtkCellArray::New();
510 aConnectivity->Allocate( aCellsSize, 0 );
512 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
513 aCellTypesArray->SetNumberOfComponents( 1 );
514 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
516 vtkIdList *anIdList = vtkIdList::New();
517 anIdList->SetNumberOfIds(2);
519 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
520 for(; anIter != aBorders.end(); anIter++){
521 const FreeEdges::Border& aBorder = *anIter;
523 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
524 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
526 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
527 if(aNode[0] >= 0 && aNode[1] >= 0){
528 anIdList->SetId( 0, aNode[0] );
529 anIdList->SetId( 1, aNode[1] );
530 aConnectivity->InsertNextCell( anIdList );
531 aCellTypesArray->InsertNextValue( VTK_LINE );
535 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
536 aCellLocationsArray->SetNumberOfComponents( 1 );
537 aCellLocationsArray->SetNumberOfTuples( aNbCells );
539 aConnectivity->InitTraversal();
540 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
541 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
543 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
545 SetUnstructuredGrid(aDataSet);
557 unsigned long mTime = this->Superclass::GetMTime();
558 mTime = max(mTime,myExtractGeometry->GetMTime());
559 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
560 mTime = max(mTime,myMergeFilter->GetMTime());
561 mTime = max(mTime,myGeomFilter->GetMTime());
562 mTime = max(mTime,myTransformFilter->GetMTime());
563 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
570 ::SetTransform(VTKViewer_Transform* theTransform)
572 myTransformFilter->SetTransform(theTransform);
580 if ( !myIsShrinkable ) return;
581 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
583 myShrinkFilter->SetInput( aDataSet );
584 myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() );
593 if ( !myIsShrunk ) return;
594 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
596 myPassFilter[ 1 ]->SetInput( aDataSet );
597 myPassFilter[ 1 ]->Modified();
606 ::SetFacesOriented(bool theIsFacesOriented)
608 if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() )
610 myIsFacesOriented = theIsFacesOriented;
611 if( theIsFacesOriented )
612 myFaceOrientationFilter->SetInput( aDataSet );
613 UpdateFaceOrientation();
619 ::UpdateFaceOrientation()
621 bool aShowFaceOrientation = myIsFacesOriented;
622 aShowFaceOrientation &= GetVisibility();
623 aShowFaceOrientation &= myRepresentation == eSurface;
624 myFaceOrientation->SetVisibility(aShowFaceOrientation);
630 ::SetRepresentation(EReperesent theMode)
634 myGeomFilter->SetInside(true);
635 myGeomFilter->SetWireframeMode(false);
636 GetProperty()->SetRepresentation(0);
639 myGeomFilter->SetInside(false);
640 myGeomFilter->SetWireframeMode(true);
641 GetProperty()->SetRepresentation(theMode);
644 myGeomFilter->SetInside(true);
645 myGeomFilter->SetWireframeMode(true);
646 GetProperty()->SetRepresentation(1);
649 myGeomFilter->SetInside(false);
650 myGeomFilter->SetWireframeMode(false);
651 GetProperty()->SetRepresentation(theMode);
653 myRepresentation = theMode;
654 UpdateFaceOrientation();
655 GetProperty()->Modified();
656 myMapper->Modified();
663 ::SetVisibility(int theMode)
665 if(!myExtractUnstructuredGrid->GetInput() ||
666 GetUnstructuredGrid()->GetNumberOfCells())
668 vtkLODActor::SetVisibility(theMode);
670 vtkLODActor::SetVisibility(false);
672 UpdateFaceOrientation();
680 if(!GetUnstructuredGrid()->GetNumberOfCells()){
681 vtkLODActor::SetVisibility(false);
683 return vtkLODActor::GetVisibility();
689 ::AddToRender(vtkRenderer* theRenderer)
691 theRenderer->AddActor(this);
692 theRenderer->AddActor(myFaceOrientation);
697 ::RemoveFromRender(vtkRenderer* theRenderer)
699 theRenderer->RemoveActor(this);
700 theRenderer->RemoveActor(myFaceOrientation);
706 ::GetNodeObjId(int theVtkID)
708 vtkIdType anID = theVtkID;
710 if(IsImplicitFunctionUsed())
711 anID = myExtractGeometry->GetNodeObjId(theVtkID);
713 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
714 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
718 vtkFloatingPointType*
720 ::GetNodeCoord(int theObjID)
722 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
723 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
724 vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
725 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
732 ::GetElemObjId(int theVtkID)
734 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
738 vtkIdType anId2 = anId;
739 if(IsImplicitFunctionUsed())
740 anId2 = myExtractGeometry->GetElemObjId(anId);
744 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
748 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
750 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
756 ::GetElemCell(int theObjID)
758 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
759 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
760 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
762 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
771 return myShrinkFilter->GetShrinkFactor();
776 ::SetShrinkFactor(vtkFloatingPointType theValue)
778 theValue = theValue > 0.1? theValue: 0.8;
779 myShrinkFilter->SetShrinkFactor(theValue);
786 ::SetHighlited(bool theIsHighlited)
788 if ( myIsHighlited == theIsHighlited )
790 myIsHighlited = theIsHighlited;
796 ::Render(vtkRenderer *ren, vtkMapper* m)
798 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
799 vtkFloatingPointType aStoredFactor, aStoredUnit;
800 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
802 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
803 vtkFloatingPointType aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
805 static vtkFloatingPointType EPS = .01;
808 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
809 vtkLODActor::Render(ren,m);
811 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
812 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
818 ::SetPolygonOffsetParameters(vtkFloatingPointType factor,
819 vtkFloatingPointType units)
821 myPolygonOffsetFactor = factor;
822 myPolygonOffsetUnits = units;