1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : VISU_PrsObject_i.cxx
6 // Author : Alexey PETROV
10 #include "VISU_PrsObject_i.hh"
11 #include "VISU_Extractor.hxx"
12 #include "VISU_FieldTransform.hxx"
13 #include "VISU_LookupTable.hxx"
14 #include "VISU_ScalarBarActor.hxx"
15 #include "VISU_Actor.h"
18 #include "QAD_Config.h"
20 #include <vtkUnstructuredGridReader.h>
21 #include <vtkUnstructuredGridWriter.h>
22 #include <vtkPolyDataWriter.h>
24 #include <vtkDataSet.h>
25 #include <vtkDataSetMapper.h>
26 #include <vtkProperty.h>
28 #include <vtkPolyData.h>
29 #include <vtkPolyDataMapper.h>
30 #include <vtkGeometryFilter.h>
32 #include <vtkWarpVector.h>
33 #include <vtkContourFilter.h>
34 #include <vtkAppendPolyData.h>
35 #include <vtkCutter.h>
37 #include <vtkCellDataToPointData.h>
39 #include <vtkGlyph3D.h>
40 #include <vtkHedgeHog.h>
41 #include <vtkPolyDataSource.h>
42 #include <vtkGlyphSource2D.h>
43 #include <vtkTransformPolyDataFilter.h>
44 #include <vtkCellCenters.h>
45 #include <vtkConeSource.h>
46 #include <vtkStreamLine.h>
47 #include <vtkMaskPoints.h>
50 static int MYDEBUG = 0;
51 static int MYDEBUGWITHFILES = 0;
53 static int MYDEBUG = 0;
54 static int MYDEBUGWITHFILES = 0;
56 static float EPS = 1.0E-3;
57 const float PI2 = 2.0*PI;
59 void WriteToFile(vtkPolyData* theDataSet, const string& theFileName){
60 vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
61 aWriter->SetFileName(theFileName.c_str());
62 aWriter->SetInput(theDataSet);
67 //==============================================================================
68 void SetIOR(SALOMEDS::SObject_var& theSObject, const char* theIOR){
69 SALOMEDS::GenericAttribute_var anAttr;
70 theSObject->FindAttribute(anAttr, "AttributeIOR");
71 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
72 CORBA::String_var aValue(theIOR);
73 anIOR->SetValue(aValue);
76 float CalcScaleFactor(float theBound[6], int theNbElem){
77 float aVolume = 1, vol, idim = 0;
78 for(int i = 0; i < 6; i += 2){
79 vol = fabs(theBound[i+1] - theBound[i]);
86 float aFactor = pow(aVolume,(float)1./idim);
90 VISU::Result_i* GetResult(SALOMEDS::SObject_ptr theSObject){
91 VISU::Result_var aResult = FindResult(theSObject);
92 if(!aResult->_is_nil())
93 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()));
98 //----------------------------------------------------------------
100 //----------------------------------------------------------------
101 void VISU::PrsObject_i::SetName( const char* theName )
104 SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
105 if ( !mySO->_is_nil() ) {
106 SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder();
107 SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute( mySO, "AttributeName" );
108 SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr );
109 aNameAttr->SetValue( theName );
112 QString VISU::PrsObject_i::GetEntry() {
113 CORBA::String_var anIOR = GetID();
114 SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(anIOR);
115 CORBA::String_var anEntry = aSObject->GetID();
120 //----------------------------------------------------------------
122 //----------------------------------------------------------------
123 VISU::Prs3d_i::Prs3d_i(Result_i* theResult) :
124 PrsObject_i(theResult->GetStudyDocument()),
127 myMapper = MapperType::New();
128 myGeomFilter = vtkGeometryFilter::New();
129 myGeomFilter->PointClippingOff();
130 myGeomFilter->CellClippingOff();
131 myGeomFilter->ExtentClippingOff();
132 myGeomFilter->MergingOff();
139 void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin)
141 Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin);
142 SetColor(aOrigin->GetColor());
143 myMapper->ShallowCopy(aOrigin->GetMapper());
146 void VISU::Prs3d_i::SetColor(const SALOMEDS::Color& theColor){
150 VISU::Prs3d_i::~Prs3d_i() {
151 CORBA::release(myStudy);
153 myGeomFilter->Delete();
156 void VISU::Prs3d_i::Destroy() {
157 CORBA::Object_var anObj = _this();
158 PortableServer::POA_ptr aPOA = Base_i::GetPOA();
159 PortableServer::ObjectId_var anId = aPOA->reference_to_id(anObj);
160 aPOA->deactivate_object(anId.in());
161 //this->_remove_ref();
166 * Create Actor referred on existing IO
168 bool VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO){
169 //MESSAGE("Prs3d_i::CreateActor");
172 static float eps = VTK_LARGE_FLOAT * 0.1 ;
173 float aLength = myMapper->GetInput()->GetLength();
175 MESSAGE("Prs3d_i::CreateActor >> Diagonal of the actor is too large : "<<aLength);
178 theActor->SetShrinkable(myMapper->GetInput()->GetNumberOfCells() > 10);
179 myMapper->SetResolveCoincidentTopologyToShiftZBuffer();
180 myMapper->SetResolveCoincidentTopologyZShift(0.02);
181 theActor->SetMapper(myMapper);
184 //Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry(),"VISU",GetName());
185 //There is a bug in gcc compiler - const Standard_CString is mapping as char * const not as const char *
186 //(where Standard_CString is defined as typedef char* Standard_CString)
187 Handle(SALOME_InteractiveObject) anIO =
188 new SALOME_InteractiveObject(strdup(GetEntry()),"VISU",(const Standard_CString)GetName());
189 theActor->setIO(anIO);
191 theActor->setIO(theIO);
193 theActor->setPrs3d(this);
197 void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) {
198 if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor");
200 theActor->Modified();
203 VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
204 throw(std::logic_error&)
206 if(MYDEBUG) MESSAGE(GetComment());
207 myName = (const char*)(VISU::Storable::FindValue(theMap,"myName"));
208 myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
209 myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
210 myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
214 void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){
215 Storable::DataToStream( theStr, "myName", myName.c_str() );
216 Storable::DataToStream( theStr, "myColor.R", myColor.R );
217 Storable::DataToStream( theStr, "myColor.G", myColor.G );
218 Storable::DataToStream( theStr, "myColor.B", myColor.B );
221 void VISU::Prs3d_i::Update(){
222 myMapper->Modified();
226 //----------------------------------------------------------------
228 //----------------------------------------------------------------
229 int VISU::Mesh_i::myNbPresent = 0;
231 QString VISU::Mesh_i::GenerateName() { return VISU::GenerateName("Mesh",myNbPresent++);}
233 const string VISU::Mesh_i::myComment = "MESH";
235 const char* VISU::Mesh_i::GetComment() const { return myComment.c_str();}
238 VISU::Mesh_i::Mesh_i(Result_i* theResult) :
239 PrsObject_i(theResult->GetStudyDocument()),
243 SALOMEDS::Color aColor = {0,1,1};
244 SetCellColor(aColor);
245 SetNodeColor(aColor);
246 SALOMEDS::Color aLinkColor = {83/255.,83/255.,83/255.};
247 SetLinkColor(aLinkColor);
250 void VISU::Mesh_i::SameAs(const Mesh_i* theOrigin)
252 return; // Same as command for mesh is not valid in current architecture
253 // VISU::Prs3d_i::SameAs(theOrigin);
254 // Mesh_i* aMesh = (Mesh_i*) theOrigin;
255 // SetCellColor(aMesh->GetCellColor());
256 // SetNodeColor(aMesh->GetNodeColor());
257 // SetLinkColor(aMesh->GetLinkColor());
258 // SetPresentationType(aMesh->GetPresentationType());
262 void VISU::Mesh_i::Destroy(){
263 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(GetEntry());
264 if(!aSObj->_is_nil()){
265 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
266 aStudyBuilder->RemoveAttribute(aSObj,"AttributeIOR");
271 VISU::Storable* VISU::Mesh_i::Create(const char* theMeshName, int theEntity){
272 myMeshName = theMeshName;
273 myEntity = theEntity;
278 VISU::Storable* VISU::Mesh_i::Create(const char* theMeshName, int theEntity, const char* theFamilyName){
279 myMeshName = theMeshName;
280 myEntity = theEntity;
281 mySubMeshName = theFamilyName;
284 VISU::Storable* VISU::Mesh_i::Create(const char* theMeshName, const char* theGroupName){
285 myMeshName = theMeshName;
287 mySubMeshName = theGroupName;
291 VISU::Storable* VISU::Mesh_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
292 throw(std::logic_error&)
294 Prs3d_i::Restore(theMap,false);
296 myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
297 myEntity = VISU::Storable::FindValue(theMap,"myEntity").toInt();
298 mySubMeshName = VISU::Storable::FindValue(theMap,"mySubMeshName").latin1();
300 myColor.R = VISU::Storable::FindValue(theMap,"myCellColor.R").toDouble();
301 myColor.G = VISU::Storable::FindValue(theMap,"myCellColor.G").toDouble();
302 myColor.B = VISU::Storable::FindValue(theMap,"myCellColor.B").toDouble();
304 myNodeColor.R = VISU::Storable::FindValue(theMap,"myNodeColor.R").toDouble();
305 myNodeColor.G = VISU::Storable::FindValue(theMap,"myNodeColor.G").toDouble();
306 myNodeColor.B = VISU::Storable::FindValue(theMap,"myNodeColor.B").toDouble();
308 myLinkColor.R = VISU::Storable::FindValue(theMap,"myLinkColor.R").toDouble();
309 myLinkColor.G = VISU::Storable::FindValue(theMap,"myLinkColor.G").toDouble();
310 myLinkColor.B = VISU::Storable::FindValue(theMap,"myLinkColor.B").toDouble();
317 void VISU::Mesh_i::ToStream(std::ostringstream& theStr){
318 Prs3d_i::ToStream(theStr);
320 Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
321 Storable::DataToStream( theStr, "myEntity", myEntity );
322 Storable::DataToStream( theStr, "mySubMeshName", mySubMeshName.c_str() );
324 Storable::DataToStream( theStr, "myCellColor.R", myColor.R );
325 Storable::DataToStream( theStr, "myCellColor.G", myColor.G );
326 Storable::DataToStream( theStr, "myCellColor.B", myColor.B );
328 Storable::DataToStream( theStr, "myNodeColor.R", myNodeColor.R );
329 Storable::DataToStream( theStr, "myNodeColor.G", myNodeColor.G );
330 Storable::DataToStream( theStr, "myNodeColor.B", myNodeColor.B );
332 Storable::DataToStream( theStr, "myLinkColor.R", myLinkColor.R );
333 Storable::DataToStream( theStr, "myLinkColor.G", myLinkColor.G );
334 Storable::DataToStream( theStr, "myLinkColor.B", myLinkColor.B );
337 VISU::Storable* VISU::MeshRestore(SALOMEDS::SObject_ptr theSObject,
338 const string& thePrefix, const Storable::TRestoringMap& theMap)
339 throw(std::logic_error&)
341 VISU::Result_i* pResult = GetResult(theSObject);
343 VISU::Mesh_i* pResent = new VISU::Mesh_i(pResult);
344 return pResent->Restore(theMap);
350 VISU::Mesh_i::~Mesh_i(){
351 if(MYDEBUG) MESSAGE("Mesh_i::~Mesh_i()");
355 VISU::Storable* VISU::Mesh_i::Build(int theRestoring){
357 if(myResult->GetInput() == NULL)
358 throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
359 if(!theRestoring) myName = (const char*)(GenerateName());
361 if(mySubMeshName == "")
362 myType = VISU::TENTITY;
364 myType = VISU::TFAMILY;
366 myType = VISU::TGROUP;
367 if(MYDEBUG) MESSAGE("Mesh_i::Build - myType = "<<myType);
368 //Building Input and comment for searching according label
372 myInput = myResult->GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity);
373 aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
374 VISU::TENTITY,myMeshName.c_str(),myEntity);
377 myInput = myResult->GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity,mySubMeshName);
378 aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
379 VISU::TFAMILY,myMeshName.c_str(),myEntity,mySubMeshName.c_str());
382 myInput = myResult->GetInput()->GetMeshOnGroup(myMeshName,mySubMeshName);
383 aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
384 VISU::TGROUP,myMeshName.c_str(),mySubMeshName.c_str());
387 if(myInput == NULL) throw std::runtime_error("Mesh_i::Build - myInput == NULL !!!");
389 vtkUnstructuredGrid *aDataSet = myInput->GetOutput();
390 //Avoid selection points that don't belong any of cells
391 myGeomFilter->SetInput(aDataSet);
392 myMapper->SetInput(myGeomFilter->GetOutput());
393 myMapper->ScalarVisibilityOff();
394 //Setting IOR on the label
396 string aResultEntry = myResult->GetEntry();
397 string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1());
398 if(anEntry == "") throw std::runtime_error("Mesh_i::Build - anEntry was not found !!!");
399 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(anEntry.c_str());
400 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
401 SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSObj,"AttributeIOR");
402 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
403 CORBA::String_var aString = GetID();
404 anIOR->SetValue(aString);
406 aDataSet->GetBounds(myBounds);
407 if(MYDEBUGWITHFILES){
408 string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER");
409 aFileName += "-Mesh.vtk";
410 ::WriteToFile(myGeomFilter->GetOutput(),aFileName.c_str());
413 }catch(std::runtime_error& exc){
414 MESSAGE("Follow exception was accured :\n"<<exc.what());
416 MESSAGE("Unknown exception was accured!");
422 VISU_Actor* VISU::Mesh_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) {
423 VISUMesh_Actor* anActor = VISUMesh_Actor::New();
424 if(MYDEBUG) MESSAGE("Prs3d_i::CreateActor");
425 if(VISU::Prs3d_i::CreateActor(anActor,theIO)){
426 UpdateActor(anActor);
434 void VISU::Mesh_i::UpdateActor(VISU_Actor* theActor) {
435 if(VISUMesh_Actor* anActor = dynamic_cast<VISUMesh_Actor*>(theActor)){
436 if(MYDEBUG) MESSAGE("Mesh_i::UpdateActor");
437 VISU::Prs3d_i::UpdateActor(theActor);
438 vtkProperty* aSurfaceProperty = anActor->GetProperty();
439 aSurfaceProperty->SetColor(myColor.R, myColor.G, myColor.B);
440 vtkProperty* anEdgeProperty = anActor->GetEdgeProperty();
441 anEdgeProperty->SetColor(myLinkColor.R, myLinkColor.G, myLinkColor.B);
447 //==============================================================================
448 int VISU::ScalarMap_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
449 const char* theFieldName, double theIteration){
451 const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName);
452 const VISU::TField::TValField& aValField = aField.myValField;
453 bool aRes = aValField.find((int)theIteration) != aValField.end();
454 if(MYDEBUG) MESSAGE("ScalarMap_i::IsPossible = "<<aRes)
456 }catch(std::runtime_error& exc){
457 MESSAGE("Follow exception was accured :\n"<<exc.what());
459 MESSAGE("Unknown exception was accured!");
464 int VISU::ScalarMap_i::myNbPresent = 0;
465 QString VISU::ScalarMap_i::GenerateName() { return VISU::GenerateName("ScalarMap",myNbPresent++);}
467 const string VISU::ScalarMap_i::myComment = "SCALARMAP";
468 const char* VISU::ScalarMap_i::GetComment() const { return myComment.c_str();}
470 VISU::ScalarMap_i::ScalarMap_i(Result_i* theResult, bool theAddToStudy) :
471 PrsObject_i(theResult->GetStudyDocument()),
474 myAddToStudy = theAddToStudy;
475 myInput = VISU_Extractor::New();
476 myFieldTransform = VISU_FieldTransform::New();
477 myMapperTable = VISU_LookupTable::New();
478 myBarTable = VISU_LookupTable::New();
483 void VISU::ScalarMap_i::Destroy(){
485 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(GetEntry());
486 if(!aSObj->_is_nil()){
487 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
488 aStudyBuilder->RemoveObject(aSObj);
494 void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin)
496 ScalarMap_i* aScalarMap = const_cast<ScalarMap_i*>(theOrigin);
497 VISU::Prs3d_i::SameAs(aScalarMap);
498 myField = aScalarMap->GetField();
499 myMeshName = myField->myMeshName;
500 myEntity = myField->myEntity;
501 myIteration = aScalarMap->GetIteration();
502 myFieldName = aScalarMap->GetFieldName();
504 SetScalarMode(aScalarMap->GetScalarMode());
505 SetRange(aScalarMap->GetMin(), aScalarMap->GetMax());
506 SetScaling(aScalarMap->GetScaling());
507 SetOrientation(aScalarMap->GetOrientation());
508 SetPosition(aScalarMap->GetPosX(), aScalarMap->GetPosY());
509 SetSize(aScalarMap->GetWidth(), aScalarMap->GetHeight());
510 SetNbColors(aScalarMap->GetNbColors());
511 SetLabels(aScalarMap->GetLabels());
512 SetTitle(aScalarMap->GetTitle());
519 * Creates Scalar Map and initialises it from resources
521 VISU::Storable* VISU::ScalarMap_i::Create(const char* theMeshName, VISU::Entity theEntity,
522 const char* theFieldName, CORBA::Double theIteration){
523 myIsFixedRange = false;
525 QString aOrient = QAD_CONFIG->getSetting("Visu:SBOrientation");
526 if ( !aOrient.isEmpty() )
527 myOrientation = (VISU::ScalarMap::Orientation) aOrient.toInt();
529 myOrientation = VISU::ScalarMap::VERTICAL;
532 QString aXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin");
533 if ( !aXorigin.isEmpty() )
534 myPosition[0] = aXorigin.toFloat();
536 if(myOrientation == VISU::ScalarMap::VERTICAL) {
537 myPosition[0] = 0.03;
543 QString aYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin");
544 if ( !aYorigin.isEmpty() )
545 myPosition[1] = aYorigin.toFloat();
547 if(myOrientation == VISU::ScalarMap::VERTICAL) {
550 myPosition[1] = 0.012;
555 QString aWidth = QAD_CONFIG->getSetting("Visu:SBWidth");
556 if ( !aWidth.isEmpty() )
557 myWidth = aWidth.toFloat();
559 myWidth =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.17:0.6;
561 QString aHeight = QAD_CONFIG->getSetting("Visu:SBHeight");
562 if ( !aHeight.isEmpty() )
563 myHeight = aHeight.toFloat();
565 myHeight =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12;
569 QString aColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors");
570 myNumberOfColors = (aColors.isEmpty())? 64 : aColors.toInt();
571 if (myNumberOfColors > 64)
572 myNumberOfColors = 64;
575 QString aLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels");
576 myNumberOfLabels = (aLabels.isEmpty())? 5 : aLabels.toInt();
577 if (myNumberOfLabels > 65)
578 myNumberOfLabels = 65;
581 QString aFixRange = QAD_CONFIG->getSetting("Visu:SBImposeRange");
582 myIsFixedRange = (aFixRange.compare("true") == 0);
584 QString aRangeMin = QAD_CONFIG->getSetting("Visu:SBMinimumValue");
585 myScalarRange[0] = (aRangeMin.isEmpty())? 0 : aRangeMin.toFloat();
587 QString aRangeMax = QAD_CONFIG->getSetting("Visu:SBMaximumValue");
588 myScalarRange[1] = (aRangeMax.isEmpty())? 0 : aRangeMax.toFloat();
590 QString aScaling = QAD_CONFIG->getSetting("Visu:SBScaling");
591 if(aScaling.compare("LOGARITHMIC") == 0)
592 myScaling = VISU::LOGARITHMIC;
594 myScaling = VISU::LINEAR;
596 // myName = GenerateName();
597 myMeshName = theMeshName;
598 myEntity = theEntity;
599 myFieldName =theFieldName;
601 myIteration = theIteration;
607 VISU::Storable* VISU::ScalarMap_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
608 throw(std::logic_error&)
610 Prs3d_i::Restore(theMap,false);
612 myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
614 myMeshName = (const char*)(VISU::Storable::FindValue(theMap,"myMeshName"));
615 myEntity = VISU::Storable::FindValue(theMap,"myEntity").toInt();
616 myFieldName = (const char*)(VISU::Storable::FindValue(theMap,"myFieldName"));
617 myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
619 myScalarMode = VISU::Storable::FindValue(theMap,"myScalarMode").toInt();
620 myScalarRange[0] = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
621 myScalarRange[1] = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
622 myIsFixedRange = VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt();
623 myScaling = (VISU::Scaling)VISU::Storable::FindValue(theMap,"myScaling").toInt();
625 myTitle = (const char*)(VISU::Storable::FindValue(theMap,"myTitle"));
626 myOrientation = (VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt();
627 myNumberOfColors = VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt();
628 myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
629 myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
630 myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
631 myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
632 myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
639 void VISU::ScalarMap_i::ToStream(std::ostringstream& theStr){
640 Prs3d_i::ToStream(theStr);
642 Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
643 Storable::DataToStream( theStr, "myEntity", myEntity );
644 Storable::DataToStream( theStr, "myFieldName", myFieldName.c_str() );
645 Storable::DataToStream( theStr, "myIteration", myIteration );
647 Storable::DataToStream( theStr, "myScalarMode", myScalarMode );
648 Storable::DataToStream( theStr, "myScalarRange[0]", myScalarRange[0] );
649 Storable::DataToStream( theStr, "myScalarRange[1]", myScalarRange[1] );
650 Storable::DataToStream( theStr, "myIsFixedRange", myIsFixedRange );
651 Storable::DataToStream( theStr, "myScaling", myScaling );
653 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
654 Storable::DataToStream( theStr, "myOrientation", myOrientation );
655 Storable::DataToStream( theStr, "myNumberOfColors", myNumberOfColors );
656 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
657 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
658 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
659 Storable::DataToStream( theStr, "myWidth", myWidth );
660 Storable::DataToStream( theStr, "myHeight", myHeight );
663 void VISU::ScalarMap_i::SetScaling(VISU::Scaling theScaling){
664 VISU_FieldTransform::TTransformFun aFun;
665 if(MYDEBUG) MESSAGE("ScalarMap_i::SetScaling - theScaling = "<<theScaling);
667 case VISU::LOGARITHMIC :
668 aFun = &Logarithmic10;
673 myScaling = theScaling;
674 vtkUnstructuredGrid *aDataSet = myInput->GetUnstructuredGridOutput();
675 myFieldTransform->SetInput(aDataSet);
676 myFieldTransform->SetTransformFunction(aFun);
677 myFieldTransform->SetScalarRange(myScalarRange);
678 if(MYDEBUGWITHFILES){
679 string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER");
680 aFileName += "-PrsScaling.vtk";
681 WriteToFile(myFieldTransform->GetUnstructuredGridOutput(),aFileName.c_str());
685 VISU::Scaling VISU::ScalarMap_i::GetScaling(){
690 void VISU::ScalarMap_i::SetRange(CORBA::Double theMin, CORBA::Double theMax) {
691 if(theMin > theMax) return;
692 myScalarRange[0] = theMin;
693 myScalarRange[1] = theMax;
694 myFieldTransform->SetScalarRange(myScalarRange);
695 myIsFixedRange = true;
696 if(MYDEBUG) MESSAGE("ScalarMap_i::SetRange = "<<myScalarRange[0]<<"; "<<myScalarRange[1]);
700 void VISU::ScalarMap_i::CalculateRange() {
701 GetFieldRange(myScalarRange);
704 void VISU::ScalarMap_i::GetFieldRange(float theRange[2]) {
706 myInput->GetUnstructuredGridOutput()->GetScalarRange(theRange);
709 void VISU::ScalarMap_i::SetScalarMode(CORBA::Long theScalarMode){
710 myScalarMode = theScalarMode;
711 vtkUnstructuredGridReader* aReader =
712 myResult->GetInput()->GetFieldOnMesh(myMeshName,(VISU::TEntity)myEntity,myFieldName,(int)myIteration);
713 if(aReader != NULL) {
714 if( MYDEBUG) MESSAGE("ScalarMap_i::SetScalarMode = "<<myIteration);
715 string aFieldName = VISU_Convertor::GenerateName(myFieldName,(int)myIteration);
716 myInput->Extract(aReader,aFieldName,myScalarMode,myField->myNbComp,myField->myEntity);
717 if(MYDEBUGWITHFILES){
718 string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER");
719 aFileName += "-ScalarMode.vtk";
720 WriteToFile(myInput->GetUnstructuredGridOutput(),aFileName.c_str());
725 VISU::Storable* VISU::ScalarMapRestore(SALOMEDS::SObject_ptr theSObject,
726 const string& thePrefix, const Storable::TRestoringMap& theMap)
727 throw(std::logic_error&)
729 VISU::Result_i* pResult = GetResult(theSObject);
731 VISU::ScalarMap_i* pResent = new VISU::ScalarMap_i(pResult);
732 return pResent->Restore(theMap);
738 VISU::ScalarMap_i::~ScalarMap_i(){
739 if(MYDEBUG) MESSAGE("ScalarMap_i::~ScalarMap_i()");
741 myFieldTransform->Delete();
742 myMapperTable->Delete();
743 myBarTable->Delete();
747 VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){
749 MESSAGE("ScalarMap_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
751 if(myResult->GetInput() == NULL)
752 throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
753 myField = &(myResult->GetInput()->GetField(myMeshName,(VISU::TEntity)myEntity,myFieldName));
754 if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!");
755 SetScalarMode(myScalarMode);
756 if(myInput->GetInput() == NULL) throw std::runtime_error("Can't build build vtk representation !!!");
757 vtkUnstructuredGrid *aDataSet = myInput->GetUnstructuredGridOutput();
758 SetScaling(myScaling);
759 aDataSet->GetBounds(myBounds);
760 CORBA::String_var anIOR = GetID();
761 const VISU::TField::TValField& aValField = myField->myValField;
762 const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second;
763 const VISU::TField::TTime& aTime = aValForTime.myTime;
766 if(theRestoring == 0){
767 if (!myIsFixedRange) aDataSet->GetScalarRange(myScalarRange);
768 aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime.myTime).c_str());
769 //aComment.sprintf("%s, %g",myFieldName.c_str(),aTime.first);
770 myTitle = (const char*)(aComment.simplifyWhiteSpace());
773 myName = (const char*)(GenerateName());
774 aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
775 VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp);
776 string aResultEntry = myResult->GetEntry();
777 string aRefFatherEntry = myResult->GetRefFatherEntry();
778 string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1());
779 if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
780 aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d;myComponentId=%d",
781 GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp,myScalarMode);
782 CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),
783 anIOR,myName.c_str(),"",aComment.latin1(),true);
786 MESSAGE("ScalarMap_i::Build - myFieldName = "<<myFieldName<<"; myName = "<<myName<<
787 "; myScalarRange[0] = "<<myScalarRange[0]<<"; myScalarRange[1] = "<<myScalarRange[1]<<
788 "; myNumberOfColors = "<<myNumberOfColors);
789 myGeomFilter->SetInput(DoHook(theRestoring));
790 myMapper->SetInput(myGeomFilter->GetOutput());
791 myMapper->SetColorModeToMapScalars();
792 myMapper->ScalarVisibilityOn();
794 }catch(std::runtime_error& exc){
795 MESSAGE("Follow exception was accured :\n"<<exc.what());
797 MESSAGE("Unknown exception was accured!");
803 VISU::ScalarMap_i::DataType* VISU::ScalarMap_i::DoHook(int theRestoring){
804 myMapper->ScalarVisibilityOn();
806 return myFieldTransform->GetUnstructuredGridOutput();
809 void VISU::ScalarMap_i::Update() {
810 if (!myIsFixedRange) CalculateRange();
812 int aScaling = GetScaling() == VISU::LOGARITHMIC? VTK_SCALE_LOG10: VTK_SCALE_LINEAR;
813 float aScalarRange[2] = {myScalarRange[0], myScalarRange[1]};
814 myMapperTable->SetScale(VTK_SCALE_LINEAR);
815 if(aScaling == VTK_SCALE_LOG10)
816 VISU_LookupTable::ComputeLogRange(myScalarRange,aScalarRange);
817 myMapperTable->SetRange(aScalarRange);
818 myMapper->SetScalarRange(aScalarRange);
819 myMapperTable->SetHueRange(0.667,0.0);
820 myMapperTable->SetNumberOfColors(myNumberOfColors);
821 myMapperTable->SetMapScale(myMapScale);
822 myMapperTable->Build();
823 myMapper->SetLookupTable(myMapperTable);
824 myMapper->MapScalars(1.0f);
826 myBarTable->SetHueRange(0.667,0.0);
827 myBarTable->SetNumberOfColors(myNumberOfColors);
828 myBarTable->SetRange(myScalarRange);
829 myBarTable->SetScale(aScaling);
832 VISU::Prs3d_i::Update();
835 void VISU::ScalarMap_i::SetMapScale(double theMapScale){
836 if(MYDEBUG) MESSAGE("ScalarMap_i::SetMapScale() - theMapScale = "<<theMapScale);
837 myMapScale = theMapScale;
841 VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) {
842 VISUScalarMap_Actor* anActor = VISUScalarMap_Actor::New();
843 if(VISU::Prs3d_i::CreateActor(anActor,theIO)){
844 anActor->SetBarVisibility(&myIsColored);
845 anActor->myFieldName = myFieldName;
846 anActor->GetProperty()->EdgeVisibilityOn();
847 UpdateActor(anActor);
855 void VISU::ScalarMap_i::UpdateActor(VISU_Actor* theActor) {
856 if(VISUScalarMap_Actor* anActor = dynamic_cast<VISUScalarMap_Actor*>(theActor)){
857 VISU::Prs3d_i::UpdateActor(theActor);
858 theActor->SetVisibility(theActor->GetVisibility());
859 VISU_ScalarBarActor * aScalarBar = anActor->GetScalarBar();
860 aScalarBar->SetLookupTable(myBarTable);
861 aScalarBar->SetTitle(myTitle.c_str());
862 aScalarBar->SetOrientation(myOrientation);
863 aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
864 aScalarBar->GetPositionCoordinate()->SetValue(myPosition[0],myPosition[1]);
865 aScalarBar->SetWidth(myWidth);
866 aScalarBar->SetHeight(myHeight);
867 aScalarBar->SetNumberOfLabels(myNumberOfLabels);
868 aScalarBar->Modified();
872 //==============================================================================
873 int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
874 const char* theFieldName, double theIteration){
876 if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration)) return 0;
877 const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName);
878 return aField.myNbComp > 1;
879 }catch(std::runtime_error& exc){
880 MESSAGE("Follow exception was accured :\n"<<exc.what());
882 MESSAGE("Unknown exception was accured!");
887 int VISU::DeformedShape_i::myNbPresent = 0;
888 QString VISU::DeformedShape_i::GenerateName() { return VISU::GenerateName("Def.Shape",myNbPresent++);}
890 const string VISU::DeformedShape_i::myComment = "DEFORMEDSHAPE";
891 const char* VISU::DeformedShape_i::GetComment() const { return myComment.c_str();}
893 VISU::DeformedShape_i::DeformedShape_i(Result_i* theResult, bool theAddToStudy) :
894 PrsObject_i(theResult->GetStudyDocument()),
896 ScalarMap_i(theResult, theAddToStudy)
898 if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i");
899 myWarpVector = vtkWarpVector::New();
902 void VISU::DeformedShape_i::Destroy(){
903 ScalarMap_i::Destroy();
906 void VISU::DeformedShape_i::SameAs(const DeformedShape_i* theOrigin)
908 DeformedShape_i* aDefShape = const_cast<DeformedShape_i*>(theOrigin);
909 setColored(aDefShape->isColored());
910 SetScale(aDefShape->GetScale());
911 VISU::ScalarMap_i::SameAs(theOrigin);
915 VISU::Storable* VISU::DeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity,
916 const char* theFieldName, double theIteration){
918 return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
921 VISU::Storable* VISU::DeformedShape_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
922 throw(std::logic_error&)
924 ScalarMap_i::Restore(theMap,false);
926 myFactor = VISU::Storable::FindValue(theMap,"myFactor").toDouble();
927 myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
934 void VISU::DeformedShape_i::ToStream(std::ostringstream& theStr){
935 ScalarMap_i::ToStream(theStr);
937 Storable::DataToStream( theStr, "myFactor", myFactor );
938 Storable::DataToStream( theStr, "myIsColored", myIsColored );
941 VISU::Storable* VISU::DeformedShapeRestore(SALOMEDS::SObject_ptr theSObject,
942 const string& thePrefix, const Storable::TRestoringMap& theMap)
943 throw(std::logic_error&)
945 VISU::Result_i* pResult = GetResult(theSObject);
947 VISU::DeformedShape_i* pResent = new VISU::DeformedShape_i(pResult);
948 return pResent->Restore(theMap);
954 VISU::DeformedShape_i::~DeformedShape_i(){
955 if(MYDEBUG) MESSAGE("DeformedShape_i::~DeformedShape_i()");
956 myWarpVector->Delete();
960 VISU::ScalarMap_i::DataType* VISU::DeformedShape_i::DoHook(int theRestoring){
961 if(theRestoring == 0)
962 myFactor = ScaleFactor()/GetMax();
963 if(MYDEBUG) MESSAGE("DeformedShape_i::DoHook() - myFactor = "<<myFactor);
965 return myWarpVector->GetOutput();
969 float VISU::DeformedShape_i::ScaleFactor() {
970 vtkUnstructuredGrid *aDataSet = myInput->GetUnstructuredGridOutput();
972 int nbCells = aDataSet->GetNumberOfCells(), nbPoints = aDataSet->GetNumberOfPoints();
973 return ::CalcScaleFactor(myBounds, nbCells? nbCells: nbPoints);
976 void VISU::DeformedShape_i::Update(){
977 if(myField->myNbComp > 1){
978 if(myField->myEntity == VISU::CELL_ENTITY){
979 vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
980 aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
981 aFilter->PassCellDataOn();
982 myWarpVector->SetInput(aFilter->GetUnstructuredGridOutput());
985 myWarpVector->SetInput(myFieldTransform->GetUnstructuredGridOutput());
986 myWarpVector->SetScaleFactor(myFactor*myMapScale);
987 myMapper->SetScalarVisibility(myIsColored);
989 ScalarMap_i::Update();
992 void VISU::DeformedShape_i::SetColor(const SALOMEDS::Color& theColor){
993 VISU::Prs3d_i::SetColor(theColor);
997 void VISU::DeformedShape_i::SetMapScale(double theMapScale){
998 myMapScale = theMapScale;
1002 VISU_Actor* VISU::DeformedShape_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) {
1003 VISU_Actor* anActor = VISU::ScalarMap_i::CreateActor(theIO);
1004 anActor->SetRepresentation(1);
1008 void VISU::DeformedShape_i::UpdateActor(VISU_Actor* theActor) {
1009 VISU::ScalarMap_i::UpdateActor(theActor);
1011 theActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
1014 //==============================================================================
1015 int VISU::CutPlanes_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
1016 const char* theFieldName, double theIteration){
1017 return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
1020 int VISU::CutPlanes_i::myNbPresent = 0;
1021 QString VISU::CutPlanes_i::GenerateName() { return VISU::GenerateName("CutPlanes",myNbPresent++);}
1023 const string VISU::CutPlanes_i::myComment = "CUTPLANES";
1024 const char* VISU::CutPlanes_i::GetComment() const { return myComment.c_str();}
1026 VISU::CutPlanes_i::CutPlanes_i(Result_i* theResult, bool theAddToStudy) :
1027 PrsObject_i(theResult->GetStudyDocument()),
1029 ScalarMap_i(theResult, theAddToStudy)
1031 if(MYDEBUG) MESSAGE("CutPlanes_i::CutPlanes_i");
1032 myAppendPolyData = vtkAppendPolyData::New();
1035 void VISU::CutPlanes_i::Destroy(){
1036 ScalarMap_i::Destroy();
1039 void VISU::CutPlanes_i::SameAs(const CutPlanes_i* theOrigin)
1041 CutPlanes_i* aCutPlanes = const_cast<CutPlanes_i*>(theOrigin);
1042 SetNbPlanes(aCutPlanes->GetNbPlanes());
1043 SetDisplacement(aCutPlanes->GetDisplacement());
1044 SetOrientationType(aCutPlanes->GetOrientationType());
1045 SetRotateX(aCutPlanes->GetRotateX());
1046 SetRotateY(aCutPlanes->GetRotateY());
1047 VISU::ScalarMap_i::SameAs(theOrigin);
1050 VISU::Storable* VISU::CutPlanes_i::Create(const char* theMeshName, VISU::Entity theEntity,
1051 const char* theFieldName, double theIteration){
1052 return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
1055 VISU::Storable* VISU::CutPlanes_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
1056 throw(std::logic_error&)
1058 ScalarMap_i::Restore(theMap,false);
1060 myNbPlanes = VISU::Storable::FindValue(theMap,"myNbPlanes").toInt();
1061 myDisplacement = VISU::Storable::FindValue(theMap,"myDisplacement").toDouble();
1062 myBasePlane = (VISU::CutPlanes::Orientation)VISU::Storable::FindValue(theMap,"myBasePlane").toInt();
1063 SetOrientationType(myBasePlane);
1065 aRot[0] = VISU::Storable::FindValue(theMap,"aRot[0]").toDouble();
1066 SetRotateX(aRot[0]);
1067 aRot[1] = VISU::Storable::FindValue(theMap,"aRot[1]").toDouble();
1068 SetRotateY(aRot[1]);
1075 void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
1076 ScalarMap_i::ToStream(theStr);
1078 Storable::DataToStream( theStr, "myNbPlanes", myNbPlanes );
1079 Storable::DataToStream( theStr, "myDisplacement", myDisplacement );
1080 Storable::DataToStream( theStr, "myBasePlane", myBasePlane );
1081 Storable::DataToStream( theStr, "aRot[0]", GetRotateX() );
1082 Storable::DataToStream( theStr, "aRot[1]", GetRotateY() );
1085 VISU::Storable* VISU::CutPlanesRestore(SALOMEDS::SObject_ptr theSObject,
1086 const string& thePrefix, const Storable::TRestoringMap& theMap)
1087 throw(std::logic_error&)
1089 VISU::Result_i* pResult = GetResult(theSObject);
1090 if(pResult != NULL){
1091 VISU::CutPlanes_i* pResent = new VISU::CutPlanes_i(pResult);
1092 return pResent->Restore(theMap);
1098 VISU::CutPlanes_i::~CutPlanes_i(){
1099 if(MYDEBUG) MESSAGE("CutPlanes_i::~CutPlanes_i()");
1100 myAppendPolyData->Delete();
1104 float* GetIdent(float theR[3][3]){
1105 for(int i = 0; i < 3; i++)
1106 for(int j = 0; j < 3; j++)
1107 theR[i][j] = (i==j? 1.0: 0.0);
1112 float* GetRx(float theRx[3][3], float thaAng){
1113 theRx[0][0] = 1.0; theRx[0][1] = 0.0; theRx[0][2] = 0.0;
1114 theRx[1][0] = 0.0; theRx[1][1] = cos(thaAng); theRx[1][2] = -sin(thaAng);
1115 theRx[2][0] = 0.0; theRx[2][1] = sin(thaAng); theRx[2][2] = cos(thaAng);
1120 float* GetRy(float theRy[3][3], float thaAng){
1121 theRy[0][0] = cos(thaAng); theRy[0][1] = 0.0; theRy[0][2] = sin(thaAng);
1122 theRy[1][0] = 0.0; theRy[1][1] = 1.0; theRy[1][2] = 0.0;
1123 theRy[2][0] = -sin(thaAng); theRy[2][1] = 0.0; theRy[2][2] = cos(thaAng);
1128 float* GetRz(float theRz[3][3], float thaAng){
1129 theRz[0][0] = cos(thaAng); theRz[0][1] = -sin(thaAng); theRz[0][2] = 0.0;
1130 theRz[1][0] = sin(thaAng); theRz[1][1] = cos(thaAng); theRz[1][2] = 0.0;
1131 theRz[2][0] = 0.0; theRz[2][1] = 0.0; theRz[2][2] = 1.0;
1136 void MulMatrix(float C[3][3], const float A[3][3], const float B[3][3]){ // C = A*B;
1137 for(int i = 0; i < 3; i++)
1138 for(int j = 0; j < 3; j++){
1140 for(int k = 0; k < 3; k++)
1141 C[i][j] += A[i][k]*B[k][j];
1146 void Sub(float C[3], const float A[3], float B[3]){ // AxB;
1147 for(int i = 0; i < 3; i++) C[i] = B[i] - A[i];
1150 float DotMul(const float A[3], const float B[3]){ // A*B;
1152 for(int i = 0; i < 3; i++) C += A[i]*B[i];
1156 void Mul(float C[3], const float A[3], float B[3]){ // AxB;
1157 C[0] = A[1]*B[2] - A[2]*B[1];
1158 C[1] = A[2]*B[0] - A[0]*B[2];
1159 C[2] = A[0]*B[1] - A[1]*B[0];
1162 void Mul(float C[3], const float A[3], float B){ // A*B;
1163 for(int i = 0; i < 3; i++) C[i] = A[i]*B;
1166 void CorrectPnt(float thePnt[3], const float BoundPrj[3]){
1167 for(int i = 0, j = 0; i < 3; ++i, j=2*i){
1168 if(thePnt[i] < BoundPrj[j]) thePnt[i] = BoundPrj[j];
1169 if(thePnt[i] > BoundPrj[j+1]) thePnt[i] = BoundPrj[j+1];
1173 void GetBoundProject(float BoundPrj[3], const float BoundBox[6], const float Dir[3]){
1174 float BoundPoints[8][3] = { {BoundBox[0],BoundBox[2],BoundBox[4]},
1175 {BoundBox[1],BoundBox[2],BoundBox[4]},
1176 {BoundBox[0],BoundBox[3],BoundBox[4]},
1177 {BoundBox[1],BoundBox[3],BoundBox[4]},
1178 {BoundBox[0],BoundBox[2],BoundBox[5]},
1179 {BoundBox[1],BoundBox[2],BoundBox[5]},
1180 {BoundBox[0],BoundBox[3],BoundBox[5]},
1181 {BoundBox[1],BoundBox[3],BoundBox[5]}};
1182 BoundPrj[0] = DotMul(Dir,BoundPoints[0]), BoundPrj[1] = BoundPrj[0];
1184 for(int i = 1; i < 8; i++){
1185 tmp = DotMul(Dir,BoundPoints[i]);
1186 if(BoundPrj[1] < tmp) BoundPrj[1] = tmp;
1187 if(BoundPrj[0] > tmp) BoundPrj[0] = tmp;
1189 BoundPrj[2] = BoundPrj[1] - BoundPrj[0];
1190 BoundPrj[1] = BoundPrj[0] + (1.0 - EPS)*BoundPrj[2];
1191 BoundPrj[0] = BoundPrj[0] + EPS*BoundPrj[2];
1192 BoundPrj[2] = BoundPrj[1] - BoundPrj[0];
1195 void VISU::CutPlanes_i::SetRotateX(CORBA::Double theAng){
1196 if(myBasePlane == VISU::CutPlanes::XY)
1198 else if(myBasePlane == VISU::CutPlanes::YZ)
1200 else if(myBasePlane == VISU::CutPlanes::ZX)
1204 CORBA::Double VISU::CutPlanes_i::GetRotateX(){
1205 if(myBasePlane == VISU::CutPlanes::XY)
1207 else if(myBasePlane == VISU::CutPlanes::YZ)
1209 else if(myBasePlane == VISU::CutPlanes::ZX)
1213 void VISU::CutPlanes_i::SetRotateY(CORBA::Double theAng){
1214 if(myBasePlane == VISU::CutPlanes::XY)
1216 else if(myBasePlane == VISU::CutPlanes::YZ)
1218 else if(myBasePlane == VISU::CutPlanes::ZX)
1222 CORBA::Double VISU::CutPlanes_i::GetRotateY(){
1223 if(myBasePlane == VISU::CutPlanes::XY)
1225 else if(myBasePlane == VISU::CutPlanes::YZ)
1227 else if(myBasePlane == VISU::CutPlanes::ZX)
1231 void GetDir(float theDir[3], float theAng[3],
1232 const VISU::CutPlanes::Orientation& theBasePlane)
1235 float aRx[3][3], aRy[3][3], aRz[3][3], aRotation[3][3];
1236 if(theBasePlane == VISU::CutPlanes::XY){ // X-Y
1237 if(fabs(theAng[0]) > EPS) ::GetRx(aRx,theAng[0]); else ::GetIdent(aRx);
1238 if(fabs(theAng[1]) > EPS) ::GetRy(aRy,theAng[1]); else ::GetIdent(aRy);
1239 ::MulMatrix(aRotation,aRx,aRy);
1241 }else if(theBasePlane == VISU::CutPlanes::YZ){ // Y-Z
1242 if(fabs(theAng[1]) > EPS) ::GetRy(aRy,theAng[1]); else ::GetIdent(aRy);
1243 if(fabs(theAng[2]) > EPS) ::GetRz(aRz,theAng[2]); else ::GetIdent(aRz);
1244 ::MulMatrix(aRotation,aRy,aRz);
1246 }else if(theBasePlane == VISU::CutPlanes::ZX){ // Z-X
1247 if(fabs(theAng[2]) > EPS) ::GetRz(aRz,theAng[2]); else ::GetIdent(aRz);
1248 if(fabs(theAng[0]) > EPS) ::GetRx(aRx,theAng[0]); else ::GetIdent(aRx);
1249 ::MulMatrix(aRotation,aRz,aRx);
1252 for(int i = 0; i < 3; i++) theDir[i] = aRotation[i][iPlane];
1255 void CutWithPlane(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet,
1256 float theDir[3], float theOrig[3])
1258 vtkCutter *aCutPlane = vtkCutter::New();
1259 aCutPlane->SetInput(theDataSet);
1260 vtkPlane *aPlane = vtkPlane::New();
1261 aPlane->SetOrigin(theOrig);
1263 aPlane->SetNormal(theDir);
1264 aCutPlane->SetCutFunction(aPlane);
1266 theAppendPolyData->AddInput(aCutPlane->GetOutput());
1267 aCutPlane->Delete();
1270 void CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet,
1271 int theNbPlanes, float theDir[3], float theBounds[6], float theDisplacement)
1273 float aInvDir[3], aBoundPrj[3], aOrig[3], aPosition;
1274 ::Mul(aInvDir,theDir,-1.0);
1275 ::GetBoundProject(aBoundPrj, theBounds, theDir);
1276 if(theNbPlanes > 1){
1277 float aDBoundPrj = aBoundPrj[2]/(theNbPlanes - 1);
1278 float aDisplacement = aDBoundPrj*theDisplacement;
1279 float aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement;
1280 for (int i = 0; i < theNbPlanes; i++){
1281 aPosition = aStartPosition + i*aDBoundPrj;
1282 float aDelta = (aBoundPrj[0] - aPosition) / aBoundPrj[2];
1284 aPosition = aBoundPrj[0];
1285 //if(fabs(aDelta) < EPS) aPosition = aBoundPrj[0]; else continue;
1286 aDelta = (aBoundPrj[2] - aPosition) / aBoundPrj[2];
1288 aPosition = aBoundPrj[2];
1289 //if(fabs(aDelta) < EPS) aPosition = aBoundPrj[2]; else continue;
1290 Mul(aOrig,theDir,aPosition);
1292 CutWithPlane(theAppendPolyData,theDataSet,theDir,aOrig);
1294 CutWithPlane(theAppendPolyData,theDataSet,aInvDir,aOrig);
1297 aPosition = aBoundPrj[0] + aBoundPrj[2]*theDisplacement;
1298 Mul(aOrig,theDir,aPosition);
1299 CutWithPlane(theAppendPolyData,theDataSet,theDir,aOrig);
1303 VISU::ScalarMap_i::DataType* VISU::CutPlanes_i::DoHook(int theRestoring){
1304 if(theRestoring == 0){
1306 myDisplacement = 0.5;
1307 myBasePlane = VISU::CutPlanes::XY;
1308 myAng[0] = myAng[1] = myAng[2] = 0.0;
1311 MESSAGE("CutPlanes_i::DoHook() - myNbPlanes = "<<myNbPlanes<<"; myBasePlane = "<<myBasePlane<<
1312 "; myAng[0] = "<<myAng[0]<<"; myAng[1] = "<<myAng[1]<<"; myAng[2] = "<<myAng[2]);
1314 return myAppendPolyData->GetOutput();
1317 void VISU::CutPlanes_i::Update(){
1318 int iEnd = myAppendPolyData->GetNumberOfInputs();
1319 if(MYDEBUG) MESSAGE("CutPlanes_i::Update - iEnd = "<<iEnd);
1320 for(int i = iEnd-1; i >= 0; i--)
1321 myAppendPolyData->RemoveInput(myAppendPolyData->GetInput(i));
1323 ::GetDir(aDir,myAng,myBasePlane);
1324 vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput();
1325 ::CutWithPlanes(myAppendPolyData,aDataSet,GetNbPlanes(),aDir,myBounds,myDisplacement);
1326 myMapper->ScalarVisibilityOn();
1327 VISU::ScalarMap_i::Update();
1330 //==============================================================================
1331 int VISU::CutLines_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
1332 const char* theFieldName, double theIteration){
1333 return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
1336 int VISU::CutLines_i::myNbPresent = 0;
1337 QString VISU::CutLines_i::GenerateName() { return VISU::GenerateName("CutLines",myNbPresent++);}
1339 const string VISU::CutLines_i::myComment = "CUTLINES";
1340 const char* VISU::CutLines_i::GetComment() const { return myComment.c_str();}
1342 VISU::CutLines_i::CutLines_i(Result_i* theResult, bool theAddToStudy) :
1343 PrsObject_i(theResult->GetStudyDocument()),
1345 ScalarMap_i(theResult, theAddToStudy)
1347 if(MYDEBUG) MESSAGE("CutLines_i::CutLines_i");
1348 myAppendPolyData = vtkAppendPolyData::New();
1351 void VISU::CutLines_i::Destroy(){
1352 ScalarMap_i::Destroy();
1355 void VISU::CutLines_i::SameAs(const CutLines_i* theOrigin)
1357 CutLines_i* aCutLines = const_cast<CutLines_i*>(theOrigin);
1358 SetNbLines(aCutLines->GetNbLines());
1359 SetDisplacement(aCutLines->GetDisplacement());
1360 SetDisplacement2(aCutLines->GetDisplacement2());
1361 SetOrientationType(aCutLines->GetOrientationType());
1362 SetOrientationType2(aCutLines->GetOrientationType2());
1363 SetRotateX(aCutLines->GetRotateX());
1364 SetRotateY(aCutLines->GetRotateY());
1365 SetRotateX2(aCutLines->GetRotateX2());
1366 SetRotateY2(aCutLines->GetRotateY2());
1367 VISU::ScalarMap_i::SameAs(theOrigin);
1370 VISU::Storable* VISU::CutLines_i::Create(const char* theMeshName, VISU::Entity theEntity,
1371 const char* theFieldName, double theIteration){
1372 return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
1375 VISU::Storable* VISU::CutLines_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
1376 throw(std::logic_error&)
1378 ScalarMap_i::Restore(theMap,false);
1379 myNbLines = VISU::Storable::FindValue(theMap,"myNbLines").toInt();
1380 myDisplacement[0] = VISU::Storable::FindValue(theMap,"myDisplacement[0]").toDouble();
1381 myDisplacement[1] = VISU::Storable::FindValue(theMap,"myDisplacement[1]").toDouble();
1382 myBasePlane[0] = (VISU::CutPlanes::Orientation)VISU::Storable::FindValue(theMap,"myBasePlane[0]").toInt();
1383 myBasePlane[1] = (VISU::CutPlanes::Orientation)VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt();
1384 SetOrientationType(myBasePlane[0]);
1385 SetOrientationType2(myBasePlane[1]);
1387 aRot[0] = VISU::Storable::FindValue(theMap,"aRot[0][0]").toDouble();
1388 SetRotateX(aRot[0]);
1389 aRot[1] = VISU::Storable::FindValue(theMap,"aRot[0][1]").toDouble();
1390 SetRotateY(aRot[1]);
1391 aRot[0] = VISU::Storable::FindValue(theMap,"aRot[1][0]").toDouble();
1392 SetRotateX2(aRot[0]);
1393 aRot[1] = VISU::Storable::FindValue(theMap,"aRot[1][1]").toDouble();
1394 SetRotateY2(aRot[1]);
1400 void VISU::CutLines_i::ToStream(std::ostringstream& theStr){
1401 ScalarMap_i::ToStream(theStr);
1402 Storable::DataToStream( theStr, "myNbLines", myNbLines );
1403 Storable::DataToStream( theStr, "myDisplacement[0]", myDisplacement[0] );
1404 Storable::DataToStream( theStr, "myDisplacement[1]", myDisplacement[1] );
1405 Storable::DataToStream( theStr, "myBasePlane[0]", myBasePlane[0] );
1406 Storable::DataToStream( theStr, "myBasePlane[1]", myBasePlane[1] );
1407 Storable::DataToStream( theStr, "aRot[0][0]", GetRotateX() );
1408 Storable::DataToStream( theStr, "aRot[0][1]", GetRotateY() );
1409 Storable::DataToStream( theStr, "aRot[1][0]", GetRotateX2() );
1410 Storable::DataToStream( theStr, "aRot[1][1]", GetRotateY2() );
1413 VISU::Storable* VISU::CutLinesRestore(SALOMEDS::SObject_ptr theSObject,
1414 const string& thePrefix, const Storable::TRestoringMap& theMap)
1415 throw(std::logic_error&)
1417 VISU::Result_i* pResult = GetResult(theSObject);
1418 if(pResult != NULL){
1419 VISU::CutLines_i* pResent = new VISU::CutLines_i(pResult);
1420 return pResent->Restore(theMap);
1426 VISU::CutLines_i::~CutLines_i(){
1427 if(MYDEBUG) MESSAGE("CutLines_i::~CutLines_i()");
1428 myAppendPolyData->Delete();
1431 void VISU::CutLines_i::SetRotateX(CORBA::Double theAng){
1432 if(myBasePlane[0] == VISU::CutPlanes::XY)
1433 myAng[0][0] = theAng;
1434 else if(myBasePlane[0] == VISU::CutPlanes::YZ)
1435 myAng[0][1] = theAng;
1436 else if(myBasePlane[0] == VISU::CutPlanes::ZX)
1437 myAng[0][2] = theAng;
1440 CORBA::Double VISU::CutLines_i::GetRotateX(){
1441 if(myBasePlane[0] == VISU::CutPlanes::XY)
1443 else if(myBasePlane[0] == VISU::CutPlanes::YZ)
1445 else if(myBasePlane[0] == VISU::CutPlanes::ZX)
1449 void VISU::CutLines_i::SetRotateY(CORBA::Double theAng){
1450 if(myBasePlane[0] == VISU::CutPlanes::XY)
1451 myAng[0][1] = theAng;
1452 else if(myBasePlane[0] == VISU::CutPlanes::YZ)
1453 myAng[0][2] = theAng;
1454 else if(myBasePlane[0] == VISU::CutPlanes::ZX)
1455 myAng[0][0] = theAng;
1458 CORBA::Double VISU::CutLines_i::GetRotateY(){
1459 if(myBasePlane[0] == VISU::CutPlanes::XY)
1461 else if(myBasePlane[0] == VISU::CutPlanes::YZ)
1463 else if(myBasePlane[0] == VISU::CutPlanes::ZX)
1467 void VISU::CutLines_i::SetRotateX2(CORBA::Double theAng){
1468 if(myBasePlane[1] == VISU::CutPlanes::XY)
1469 myAng[1][0] = theAng;
1470 else if(myBasePlane[1] == VISU::CutPlanes::YZ)
1471 myAng[1][1] = theAng;
1472 else if(myBasePlane[1] == VISU::CutPlanes::ZX)
1473 myAng[1][2] = theAng;
1476 CORBA::Double VISU::CutLines_i::GetRotateX2(){
1477 if(myBasePlane[1] == VISU::CutPlanes::XY)
1479 else if(myBasePlane[1] == VISU::CutPlanes::YZ)
1481 else if(myBasePlane[1] == VISU::CutPlanes::ZX)
1485 void VISU::CutLines_i::SetRotateY2(CORBA::Double theAng){
1486 if(myBasePlane[1] == VISU::CutPlanes::XY)
1487 myAng[1][1] = theAng;
1488 else if(myBasePlane[1] == VISU::CutPlanes::YZ)
1489 myAng[1][2] = theAng;
1490 else if(myBasePlane[1] == VISU::CutPlanes::ZX)
1491 myAng[1][0] = theAng;
1494 CORBA::Double VISU::CutLines_i::GetRotateY2(){
1495 if(myBasePlane[1] == VISU::CutPlanes::XY)
1497 else if(myBasePlane[1] == VISU::CutPlanes::YZ)
1499 else if(myBasePlane[1] == VISU::CutPlanes::ZX)
1503 VISU::ScalarMap_i::DataType* VISU::CutLines_i::DoHook(int theRestoring){
1504 if(theRestoring == 0){
1506 myDisplacement[0] = myDisplacement[1] = 0.5;
1507 myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
1508 myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
1509 myBasePlane[0] = VISU::CutPlanes::ZX;
1510 myBasePlane[1] = VISU::CutPlanes::XY;
1513 return myAppendPolyData->GetOutput();
1516 void ClearAppendPolyData(vtkAppendPolyData *theAppendPolyData){
1517 int iEnd = theAppendPolyData->GetNumberOfInputs();
1518 for(int i = iEnd-1; i >= 0; i--)
1519 theAppendPolyData->RemoveInput(theAppendPolyData->GetInput(i));
1522 void VISU::CutLines_i::Update(){
1523 ::ClearAppendPolyData(myAppendPolyData);
1524 vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
1527 ::GetDir(aDir[0],myAng[0],myBasePlane[0]);
1528 ::CutWithPlanes(anAppendPolyData,myFieldTransform->GetUnstructuredGridOutput(),1,aDir[0],myBounds,myDisplacement[0]);
1529 anAppendPolyData->Update();
1530 vtkPolyData *aPolyData = anAppendPolyData->GetOutput();
1531 if(MYDEBUG) MESSAGE("CutPlanes_i::Update - aPolyData->GetNumberOfCells() = "<<aPolyData->GetNumberOfCells());
1532 if(aPolyData->GetNumberOfCells() == 0){
1533 ::ClearAppendPolyData(anAppendPolyData);
1534 vtkGeometryFilter *aGeomFilter = vtkGeometryFilter::New();
1535 aGeomFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
1536 anAppendPolyData->AddInput(aGeomFilter->GetOutput());
1537 aGeomFilter->Delete();
1538 anAppendPolyData->Update();
1542 aPolyData = anAppendPolyData->GetOutput();
1543 aPolyData->GetBounds(aBounds);
1544 ::GetDir(aDir[1],myAng[1],myBasePlane[1]);
1545 ::CutWithPlanes(myAppendPolyData,aPolyData,GetNbLines(),aDir[1],aBounds,myDisplacement[1]);
1546 anAppendPolyData->Delete();
1547 //Calculate values for building of table
1548 ::Mul(myDirLn,aDir[0],aDir[1]);
1549 ::GetBoundProject(myBoundPrjLn, myBounds, myDirLn);
1550 Mul(myBasePnt,myDirLn,myBoundPrjLn[0]);
1551 CorrectPnt(myBasePnt,myBounds);
1552 myMapper->ScalarVisibilityOn();
1553 VISU::ScalarMap_i::Update();
1556 void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){
1557 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal");
1559 SALOMEDS::GenericAttribute_var anAttr;
1560 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
1561 anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal");
1562 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
1564 typedef set<long> TLineCont;
1565 typedef map<float,TLineCont> TXMap;
1566 typedef map<float,float> TXYMap;
1567 typedef vector<TXYMap> TCurveVect;
1569 const VISU::TField::TValField& aValField = myField->myValField;
1570 const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second;
1571 const VISU::TField::TTime& aTime = aValForTime.myTime;
1573 //aTitle.sprintf("%s %s",myTitle.c_str(),aTime.second.c_str());
1574 aTitle.sprintf("%s",myTitle.c_str());
1575 aTitle = aTitle.simplifyWhiteSpace();
1576 aTableOfReal->SetTitle(aTitle.latin1());
1578 myAppendPolyData->Update();
1579 int iLineEnd = myAppendPolyData->GetNumberOfInputs();
1580 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLineEnd = "<<iLineEnd);
1581 TCurveVect aCurveVect(iLineEnd);
1582 TLineCont aLineCont;
1584 for(int iLine = 0; iLine < iLineEnd; iLine++){
1585 vtkDataSet *aDataSet = myAppendPolyData->GetInput(iLine);
1587 int aNbPoints = aDataSet->GetNumberOfPoints();
1588 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "<<iLine<<"; aNbPoints = "<<aNbPoints);
1589 vtkPointData *aPointData = aDataSet->GetPointData();
1590 vtkDataArray *aScalars = aPointData->GetScalars();
1591 vtkCellDataToPointData *aFilter = NULL;
1593 aFilter = vtkCellDataToPointData::New();
1594 aFilter->SetInput(aDataSet);
1595 aFilter->PassCellDataOn();
1596 aDataSet = aFilter->GetOutput();
1599 aPointData = aDataSet->GetPointData();
1600 aScalars = aPointData->GetScalars();
1601 if(!aScalars) continue;
1602 aLineCont.insert(iLine);
1603 TXYMap& aXYMap = aCurveVect[iLine];
1604 float aPnt[3], aVect[3], aDist;
1605 for(int i = 0; i < aNbPoints; i++){
1606 aDataSet->GetPoint(i,aPnt);
1607 Sub(aVect,myBasePnt,aPnt);
1608 aDist = DotMul(aVect,myDirLn) / myBoundPrjLn[2];
1610 if(aDist < 0.0) aDist = 0.0;
1611 if(aDist > 1.0) aDist = 1.0;
1612 aXYMap[aDist] = aScalars->GetTuple1(i);
1613 //aXMap[aDist].insert(iLine);
1615 if(aFilter) aFilter->Delete();
1617 iLineEnd = aLineCont.size();
1619 MESSAGE("CutPlanes_i::BuildTableOfReal aLineCont.size() == 0 !!!");
1622 //Resorting of theXYMap
1623 for(int iLine = 0; iLine < iLineEnd; iLine++){
1624 TXYMap& aXYMap = aCurveVect[iLine], aNewXYMap;
1625 if(aXYMap.size() > 2){
1626 TXYMap::const_iterator aXYMapIter[2] = {aXYMap.begin(), ++aXYMap.begin()};
1627 aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second;
1628 for(; aXYMapIter[1] != aXYMap.end(); aXYMapIter[0]++, aXYMapIter[1]++){
1629 float aY[3] = {aXYMapIter[0]->second, aXYMapIter[1]->second, 0.0};
1630 aY[2] = (aY[0] + aY[1])/2.0;
1631 float aX[3] = {aXYMapIter[0]->first, aXYMapIter[1]->first, 0.0};
1632 aX[2] = (aX[0] + aX[1])/2.0;
1633 aNewXYMap[aX[2]] = aY[2];
1634 aXMap[aX[2]].insert(iLine);
1636 aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second;
1641 aTableOfReal->SetNbColumns(aXMap.size());
1642 TXMap::const_iterator aXMapIter = aXMap.begin();
1643 for(long i = 0; aXMapIter != aXMap.end(); aXMapIter++, i++){
1644 float aDist = aXMapIter->first;
1645 aTableOfReal->PutValue(aDist,1,i+1);
1646 aString.sprintf("%d",i);
1647 aTableOfReal->SetColumnTitle(i+1,aString.latin1());
1648 const TLineCont& aLineCont = aXMapIter->second;
1649 long jEnd = aLineCont.size();
1650 if(0&& MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<<aDist<<"; jEnd = "<<jEnd);
1651 TLineCont::const_iterator aLineContIter = aLineCont.begin();
1652 for(; aLineContIter != aLineCont.end(); aLineContIter++){
1653 long iLine = *aLineContIter;
1654 const TXYMap& aXYMap = aCurveVect[iLine];
1655 TXYMap::const_iterator aXYMapIter = aXYMap.find(aDist);
1656 if(aXYMapIter == aXYMap.end()) continue;
1657 float aVal = aXYMapIter->second;
1658 aTableOfReal->PutValue(aVal,iLine+2,i+1);
1662 aTableOfReal->SetRowTitle(1,"X");
1663 TLineCont::const_iterator aLineContIter = aLineCont.begin();
1664 QString aUnitName = myField->myUnitNames[0].c_str();
1665 if(myScalarMode != 0)
1666 aUnitName = myField->myUnitNames[myScalarMode-1].c_str();
1667 aUnitName = aUnitName.simplifyWhiteSpace();
1668 for(long i = 0; aLineContIter != aLineCont.end(); aLineContIter++, i++){
1669 long iLine = *aLineContIter;
1670 aString.sprintf("Y%d",iLine);
1671 aTableOfReal->SetRowTitle(i+2,aString.latin1());
1672 aTableOfReal->SetRowUnit(i+2,aUnitName.latin1());
1676 //==============================================================================
1677 int VISU::IsoSurfaces_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
1678 const char* theFieldName, double theIteration){
1679 return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
1682 int VISU::IsoSurfaces_i::myNbPresent = 0;
1683 QString VISU::IsoSurfaces_i::GenerateName() { return VISU::GenerateName("IsoSurfaces",myNbPresent++);}
1685 const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
1686 const char* VISU::IsoSurfaces_i::GetComment() const { return myComment.c_str();}
1688 VISU::IsoSurfaces_i::IsoSurfaces_i(Result_i* theResult, bool theAddToStudy) :
1689 PrsObject_i(theResult->GetStudyDocument()),
1691 ScalarMap_i(theResult, theAddToStudy)
1693 if(MYDEBUG) MESSAGE("IsoSurfaces_i::IsoSurfaces_i");
1694 myContourFilter = vtkContourFilter::New();
1697 void VISU::IsoSurfaces_i::Destroy(){
1698 ScalarMap_i::Destroy();
1701 void VISU::IsoSurfaces_i::SameAs(const IsoSurfaces_i* theOrigin) {
1702 IsoSurfaces_i* aIsoSurfaces = const_cast<IsoSurfaces_i*>(theOrigin);
1703 SetNbSurfaces(aIsoSurfaces->GetNbSurfaces());
1704 SetRange(aIsoSurfaces->GetRangeMin(), aIsoSurfaces->GetRangeMax());
1705 VISU::ScalarMap_i::SameAs(theOrigin);
1708 VISU::Storable* VISU::IsoSurfaces_i::Create(const char* theMeshName, VISU::Entity theEntity,
1709 const char* theFieldName, double theIteration){
1713 return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
1716 VISU::Storable* VISU::IsoSurfaces_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
1717 throw(std::logic_error&)
1719 ScalarMap_i::Restore(theMap,false);
1721 myNbSurface = VISU::Storable::FindValue(theMap,"myNbSurface").toInt();
1722 myRange[0] = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
1723 myRange[1] = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble();
1730 void VISU::IsoSurfaces_i::ToStream(std::ostringstream& theStr){
1731 ScalarMap_i::ToStream(theStr);
1733 Storable::DataToStream( theStr, "myNbSurface", myNbSurface );
1734 Storable::DataToStream( theStr, "myRange[0]", myRange[0] );
1735 Storable::DataToStream( theStr, "myRange[1]", myRange[1] );
1738 VISU::Storable* VISU::IsoSurfacesRestore(SALOMEDS::SObject_ptr theSObject,
1739 const string& thePrefix, const Storable::TRestoringMap& theMap)
1740 throw(std::logic_error&)
1742 VISU::Result_i* pResult = GetResult(theSObject);
1743 if(pResult != NULL){
1744 VISU::IsoSurfaces_i* pResent = new VISU::IsoSurfaces_i(pResult);
1745 return pResent->Restore(theMap);
1751 VISU::IsoSurfaces_i::~IsoSurfaces_i(){
1752 if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
1753 myContourFilter->Delete();
1756 void VISU::IsoSurfaces_i::SetRange(float theMin, float theMax){
1757 if(theMin <= theMax){
1758 myRange[0] = theMin; myRange[1] = theMax;
1762 VISU::ScalarMap_i::DataType* VISU::IsoSurfaces_i::DoHook(int theRestoring){
1763 if(MYDEBUG) MESSAGE("IsoSurfaces_i::DoHook() - myNbSurface = "<<myNbSurface);
1764 if(theRestoring == 0) {
1765 myRange[0] = myScalarRange[0];
1766 myRange[1] = myScalarRange[1];
1769 return myContourFilter->GetOutput();
1773 void VISU::IsoSurfaces_i::Update(){
1774 if(myField->myEntity == VISU::CELL_ENTITY){
1775 vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
1776 aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
1777 aFilter->PassCellDataOn();
1778 myContourFilter->SetInput(aFilter->GetOutput());
1781 myContourFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
1782 int aNbSurface = (int)(myMapScale*myNbSurface);
1783 if(aNbSurface < 1) aNbSurface = 1;
1784 if(GetScaling() == VISU::LOGARITHMIC){
1786 VISU_LookupTable::ComputeLogRange(myRange,aLogRange);
1787 myContourFilter->GenerateValues(aNbSurface,aLogRange);
1789 myContourFilter->GenerateValues(aNbSurface,myRange);
1790 myMapper->ScalarVisibilityOn();
1791 VISU::ScalarMap_i::Update();
1794 void VISU::IsoSurfaces_i::SetMapScale(double theMapScale){
1795 myMapScale = theMapScale;
1799 //==============================================================================
1800 int VISU::StreamLines_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
1801 const char* theFieldName, double theIteration){
1802 return DeformedShape_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
1805 int VISU::StreamLines_i::myNbPresent = 0;
1806 QString VISU::StreamLines_i::GenerateName() { return VISU::GenerateName("StreamLines",myNbPresent++);}
1808 const string VISU::StreamLines_i::myComment = "STREAMLINES";
1809 const char* VISU::StreamLines_i::GetComment() const { return myComment.c_str();}
1811 VISU::StreamLines_i::StreamLines_i(Result_i* theResult, bool theAddToStudy) :
1812 PrsObject_i(theResult->GetStudyDocument()),
1814 ScalarMap_i(theResult, theAddToStudy),
1815 DeformedShape_i(theResult, theAddToStudy)
1817 if(MYDEBUG) MESSAGE("StreamLines_i::StreamLines_i");
1818 myStream = vtkStreamLine::New();
1821 void VISU::StreamLines_i::Destroy(){
1822 DeformedShape_i::Destroy();
1825 VISU::Storable* VISU::StreamLines_i::Create(const char* theMeshName, VISU::Entity theEntity,
1826 const char* theFieldName, double theIteration)
1828 return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration);
1831 void VISU::StreamLines_i::SameAs(const StreamLines_i* theOrigin) {
1833 StreamLines_i* aIsoLines = const_cast<StreamLines_i*>(theOrigin);
1834 SetDirection(aIsoLines->GetDirection());
1835 SetStepLength(aIsoLines->GetStepLength());
1836 SetIntegrationStep(aIsoLines->GetIntegrationStep());
1837 SetPropagationTime(aIsoLines->GetPropagationTime());
1838 VISU::DeformedShape_i::SameAs(theOrigin);
1839 SetUsedPoints(aIsoLines->GetUsedPoints());
1842 VISU::Storable* VISU::StreamLines_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
1843 throw(std::logic_error&)
1845 DeformedShape_i::Restore(theMap,false);
1847 myStepLength = VISU::Storable::FindValue(theMap,"myStepLength").toDouble();
1848 myIntegrationStep = VISU::Storable::FindValue(theMap,"myIntegrationStep").toDouble();
1849 myPropagationTime = VISU::Storable::FindValue(theMap,"myPropagationTime").toDouble();
1850 myDirection = (VISU::StreamLines::Direction) VISU::Storable::FindValue(theMap,"myDirection").toInt();
1851 mySourceEntry = VISU::Storable::FindValue(theMap,"mySourceEntry").latin1();
1852 myPercents = VISU::Storable::FindValue(theMap,"myPercents").toDouble();
1860 void VISU::StreamLines_i::ToStream(std::ostringstream& theStr){
1861 DeformedShape_i::ToStream(theStr);
1863 Storable::DataToStream( theStr, "myStepLength", myStepLength );
1864 Storable::DataToStream( theStr, "myIntegrationStep", myIntegrationStep );
1865 Storable::DataToStream( theStr, "myPropagationTime", myPropagationTime );
1866 Storable::DataToStream( theStr, "myDirection", (int)myDirection );
1867 Storable::DataToStream( theStr, "mySourceEntry", mySourceEntry.c_str());
1868 Storable::DataToStream( theStr, "myPercents", myPercents );
1872 VISU::Storable* VISU::StreamLinesRestore(SALOMEDS::SObject_ptr theSObject,
1873 const string& thePrefix, const Storable::TRestoringMap& theMap)
1874 throw(std::logic_error&)
1876 VISU::Result_i* pResult = GetResult(theSObject);
1877 if(pResult != NULL){
1878 VISU::StreamLines_i* pResent = new VISU::StreamLines_i(pResult);
1879 return pResent->Restore(theMap);
1885 VISU::StreamLines_i::~StreamLines_i(){
1886 if(MYDEBUG) MESSAGE("StreamLines_i::~StreamLines_i()");
1890 void VISU::StreamLines_i::SetSource(VISU::Prs3d_ptr thePrs3d){
1891 if(thePrs3d->_is_nil()) {
1895 myPrs3di = dynamic_cast<VISU::Prs3d_i*>(GetServant(thePrs3d));
1896 CORBA::String_var aString = thePrs3d->GetID();
1897 SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(aString);
1898 aString = aSObject->GetID();
1899 mySourceEntry = aString.in();
1903 VISU::Prs3d_ptr VISU::StreamLines_i::GetSource(){
1904 VISU::Prs3d_var aPrs3d;
1905 if(MYDEBUG) MESSAGE("StreamLines_i::GetSource() mySourceEntry = '"<<mySourceEntry<<"'");
1906 if(mySourceEntry != ""){
1907 SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(mySourceEntry.c_str());
1908 CORBA::Object_var anObj = SObjectToObject(aSObject);
1909 if(!CORBA::is_nil(anObj)){
1910 aPrs3d = VISU::Prs3d::_narrow(anObj);
1911 if(!aPrs3d->_is_nil())
1912 myPrs3di = dynamic_cast<VISU::Prs3d_i*>(GetServant(aPrs3d.in()));
1915 return aPrs3d._retn();
1918 // in this method we calculate minimal width of the dataset
1919 // at least three integration steps could be in this width
1920 float VISU::StreamLines_i::GetMaxIntegrationStep() {
1921 float aMaxSizeY = fabs(myBounds[2] - myBounds[3]);
1922 float aMaxSizeZ = fabs(myBounds[4] - myBounds[5]);
1923 float aMinMax = fabs(myBounds[0] - myBounds[1]);
1924 if (aMinMax < 1.0e-20 || (aMaxSizeY < aMinMax && aMaxSizeY > 1.0e-20)) aMinMax = aMaxSizeY;
1925 if (aMinMax < 1.0e-20 || (aMaxSizeZ < aMinMax && aMaxSizeZ > 1.0e-20)) aMinMax = aMaxSizeZ;
1926 return aMinMax / 2.0;
1929 float VISU::StreamLines_i::GetMinIntegrationStep() {
1932 if (fabs(myBounds[0] - myBounds[1]) > 1.0e-20 ) {
1933 aVolume *= fabs(myBounds[0] - myBounds[1]);
1936 if (fabs(myBounds[2] - myBounds[3]) > 1.0e-20 ) {
1937 aVolume *= fabs(myBounds[2] - myBounds[3]);
1940 if (fabs(myBounds[4] - myBounds[5]) > 1.0e-20 ) {
1941 aVolume *= fabs(myBounds[4] - myBounds[5]);
1944 if (degree < 0.5) return 0.0; // absolutely empty object
1945 float anAverageVolume = aVolume / 1.0e+8; // we have to use no more, than 1GB memory (approx)
1946 return pow((double)(anAverageVolume), (double)(1.0 / degree));
1949 float VISU::StreamLines_i::GetBasePropagationTime() {
1950 return myFieldTransform->GetUnstructuredGridOutput()->GetLength() / (GetMax() + GetMin()) * 2.0;
1953 VISU::ScalarMap_i::DataType* VISU::StreamLines_i::DoHook(int theRestoring){
1954 if(theRestoring == 0){
1955 myDirection = VISU::StreamLines::BOTH;
1956 vtkDataSet *aDataSet = myFieldTransform->GetUnstructuredGridOutput();
1959 myIntegrationStep = GetMaxIntegrationStep() / 10.0;
1960 float aMinMax = aDataSet->GetLength() /
1961 (sqrt((float)(aDataSet->GetNumberOfPoints() + aDataSet->GetNumberOfCells()))+1.0);
1962 if (aMinMax > myIntegrationStep) myIntegrationStep = (myIntegrationStep * 9.0 + aMinMax) / 10.0;
1963 if (myIntegrationStep < GetMinIntegrationStep()) myIntegrationStep = GetMinIntegrationStep();
1965 myPropagationTime = GetBasePropagationTime();
1966 myStepLength = myPropagationTime / 20.;
1967 if (myStepLength > myIntegrationStep * 2) myStepLength = myIntegrationStep * 2;
1968 if (myStepLength < myPropagationTime / 100.) myStepLength = myPropagationTime / 100.;
1974 return myStream->GetOutput();
1978 void SetStreamerSource(vtkStreamer *theStreamer, vtkDataSet* theDataSet,
1979 VISU::Prs3d_i* thePrs3di, float thePercents)
1982 theDataSet = thePrs3di->GetMapper()->GetInput();
1983 theDataSet->Modified();
1984 theDataSet->Update();
1985 vtkMaskPoints *aMaskPoints = vtkMaskPoints::New();
1986 aMaskPoints->SetInput(theDataSet);
1987 //aMaskPoints->RandomModeOn();
1988 int aNbPoints = (int)(theDataSet->GetNumberOfPoints()*thePercents);
1989 if(MYDEBUG) MESSAGE("SetStreamerSource aNbPoints = "<<theDataSet->GetNumberOfPoints()<<";\t"<<aNbPoints);
1990 aMaskPoints->SetMaximumNumberOfPoints(aNbPoints);
1991 theStreamer->SetSource(aMaskPoints->GetOutput());
1992 aMaskPoints->Delete();
1995 void VISU::StreamLines_i::Update(){
1996 //apo - myStream->DebugOn();
1997 VISU::Prs3d_var aPrs3d = GetSource();
1998 if(myField->myNbComp > 1){
1999 myStream->SetStepLength(myStepLength);
2000 myStream->SetIntegrationStepLength(myIntegrationStep);
2001 myStream->SetMaximumPropagationTime(myPropagationTime);
2002 if(myField->myEntity == VISU::CELL_ENTITY){
2003 vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
2004 aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
2005 aFilter->PassCellDataOn();
2006 myStream->SetInput(aFilter->GetOutput());
2008 vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells
2009 centers->SetInput(myFieldTransform->GetUnstructuredGridOutput());
2010 centers->VertexCellsOn();
2011 //myStream->SetSource(centers->GetOutput());
2012 SetStreamerSource(myStream,centers->GetOutput(),myPrs3di,myPercents);
2015 myStream->SetInput(myFieldTransform->GetUnstructuredGridOutput());
2016 //myStream->SetSource(myFieldTransform->GetUnstructuredGridOutput());
2017 SetStreamerSource(myStream,myFieldTransform->GetUnstructuredGridOutput(),myPrs3di,myPercents);
2019 switch (myDirection) {
2020 case VISU::StreamLines::FORWARD:
2021 myStream->SetIntegrationDirectionToForward();
2023 case VISU::StreamLines::BACKWARD:
2024 myStream->SetIntegrationDirectionToBackward();
2026 case VISU::StreamLines::BOTH:
2027 myStream->SetIntegrationDirectionToIntegrateBothDirections();
2030 myStream->Modified();
2031 VISU::DeformedShape_i::Update();
2034 //==============================================================================
2035 int VISU::Vectors_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
2036 const char* theFieldName, double theIteration){
2037 return DeformedShape_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
2040 int VISU::Vectors_i::myNbPresent = 0;
2041 QString VISU::Vectors_i::GenerateName() { return VISU::GenerateName("Vectors",myNbPresent++);}
2043 const string VISU::Vectors_i::myComment = "VECTORS";
2044 const char* VISU::Vectors_i::GetComment() const { return myComment.c_str();}
2046 VISU::Vectors_i::Vectors_i(Result_i* theResult, bool theAddToStudy) :
2047 PrsObject_i(theResult->GetStudyDocument()),
2049 ScalarMap_i(theResult, theAddToStudy),
2050 DeformedShape_i(theResult, theAddToStudy)
2052 if(MYDEBUG) MESSAGE("Vectors_i::Vectors_i");
2053 myGlyph = vtkGlyph3D::New();
2054 myHog = vtkHedgeHog::New();
2057 void VISU::Vectors_i::Destroy(){
2058 DeformedShape_i::Destroy();
2061 void VISU::Vectors_i::SameAs(const VISU::Vectors_i* theOrigin) {
2062 Vectors_i* aVectors = const_cast<Vectors_i*>(theOrigin);
2063 SetLineWidth(aVectors->GetLineWidth());
2064 SetGlyphType(aVectors->GetGlyphType());
2065 SetGlyphPos(aVectors->GetGlyphPos());
2066 VISU::DeformedShape_i::SameAs(theOrigin);
2069 VISU::Storable* VISU::Vectors_i::Create(const char* theMeshName, VISU::Entity theEntity,
2070 const char* theFieldName, double theIteration){
2072 myTypeGlyph = VISU::Vectors::ARROW;
2073 myPosGlyph = VISU::Vectors::CENTER;
2074 return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration);
2077 VISU::Storable* VISU::Vectors_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding)
2078 throw(std::logic_error&)
2080 DeformedShape_i::Restore(theMap,false);
2082 myTypeGlyph = (VISU::Vectors::GlyphType)VISU::Storable::FindValue(theMap,"myTypeGlyph").toInt();
2083 myLineWidth = VISU::Storable::FindValue(theMap,"myLineWidth").toDouble();
2084 myPosGlyph = (VISU::Vectors::GlyphPos)VISU::Storable::FindValue(theMap,"myPosGlyph").toInt();
2091 void VISU::Vectors_i::ToStream(std::ostringstream& theStr){
2092 DeformedShape_i::ToStream(theStr);
2094 Storable::DataToStream( theStr, "myTypeGlyph", myTypeGlyph );
2095 Storable::DataToStream( theStr, "myLineWidth", myLineWidth );
2096 Storable::DataToStream( theStr, "myPosGlyph", myPosGlyph );
2099 VISU::Storable* VISU::VectorsRestore(SALOMEDS::SObject_ptr theSObject,
2100 const string& thePrefix, const Storable::TRestoringMap& theMap)
2101 throw(std::logic_error&)
2103 VISU::Result_i* pResult = GetResult(theSObject);
2104 if(pResult != NULL){
2105 VISU::Vectors_i* pResent = new VISU::Vectors_i(pResult);
2106 return pResent->Restore(theMap);
2112 VISU::ScalarMap_i::DataType* VISU::Vectors_i::DoHook(int theRestoring){
2113 if(theRestoring == 0){
2114 myTypeGlyph = VISU::Vectors::ARROW;
2116 myPosGlyph = VISU::Vectors::TAIL;
2117 myFactor = ScaleFactor()/GetMax();
2120 MESSAGE("Vectors_i::DoHook() - myFactor = "<<myFactor<<"; myTypeGlyph = "<<myTypeGlyph<<
2121 "; myLineWidth = "<<myLineWidth<<"; myPosGlyph = "<<myPosGlyph);
2123 if (myTypeGlyph == VISU::Vectors::NONE) return myHog->GetOutput();
2124 return myGlyph->GetOutput();
2127 VISU::Vectors_i::~Vectors_i(){
2128 if(MYDEBUG) MESSAGE("Vectors_i::~Vectors_i()");
2133 void VISU::Vectors_i::Update() {
2134 switch (myTypeGlyph) {
2135 case VISU::Vectors::ARROW:
2137 vtkGlyphSource2D *aGlyphSource = vtkGlyphSource2D::New();
2138 aGlyphSource->SetGlyphTypeToArrow();
2139 aGlyphSource->SetFilled(0);
2140 if(myPosGlyph == VISU::Vectors::TAIL)
2141 aGlyphSource->SetCenter(0.5, 0.0, 0.0);
2142 else if(myPosGlyph == VISU::Vectors::HEAD)
2143 aGlyphSource->SetCenter(-0.5, 0.0, 0.0);
2144 myGlyph->SetSource(aGlyphSource->GetOutput());
2145 aGlyphSource->Delete();
2149 case VISU::Vectors::CONE2:
2150 case VISU::Vectors::CONE6:
2152 vtkConeSource *aGlyphSource = vtkConeSource::New(); //by default
2153 if (myTypeGlyph == VISU::Vectors::CONE6)
2154 aGlyphSource->SetResolution(7);
2156 aGlyphSource->SetResolution(3);
2157 aGlyphSource->SetHeight(1.0);
2158 aGlyphSource->SetRadius(.1);
2159 vtkTransform *aTransform = vtkTransform::New();
2161 if(myPosGlyph == VISU::Vectors::TAIL)
2162 aGlyphSource->SetCenter(0.5, 0.0, 0.0);
2163 else if(myPosGlyph == VISU::Vectors::HEAD)
2164 aGlyphSource->SetCenter(-0.5, 0.0, 0.0);
2166 vtkTransformPolyDataFilter *aFilter = vtkTransformPolyDataFilter::New();
2167 aFilter->SetInput(aGlyphSource->GetOutput());
2168 aGlyphSource->Delete();
2169 aFilter->SetTransform(aTransform);
2170 aTransform->Delete();
2171 myGlyph->SetSource(aGlyphSource->GetOutput());
2175 case VISU::Vectors::NONE:
2177 if(myField->myEntity == VISU::CELL_ENTITY){
2178 vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells
2179 centers->SetInput(myFieldTransform->GetUnstructuredGridOutput());
2180 centers->VertexCellsOn();
2181 myHog->SetInput(centers->GetOutput());
2184 myHog->SetInput(myFieldTransform->GetInput());
2186 myHog->SetScaleFactor(myFactor);
2188 myMapper->SetInput(myHog->GetOutput());
2193 if(myField->myNbComp > 1){
2194 if(myField->myEntity == VISU::CELL_ENTITY){
2195 vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells
2196 centers->SetInput(myFieldTransform->GetUnstructuredGridOutput());
2197 centers->VertexCellsOn();
2198 myGlyph->SetInput(centers->GetOutput());
2201 myGlyph->SetInput(myFieldTransform->GetUnstructuredGridOutput());
2202 myGlyph->SetVectorModeToUseVector();
2203 myGlyph->SetScaleModeToScaleByVector();
2204 //myGlyph->SetColorModeToColorByVector();
2205 myGlyph->SetColorModeToColorByScalar();
2206 myGlyph->SetScaleFactor(2*myFactor);
2208 myGlyph->Modified();
2209 VISU::DeformedShape_i::Update();
2212 VISU_Actor* VISU::Vectors_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) {
2213 VISU_Actor* anActor = VISU::DeformedShape_i::CreateActor(theIO);
2217 void VISU::Vectors_i::UpdateActor(VISU_Actor* theActor) {
2218 VISU::DeformedShape_i::UpdateActor(theActor);
2219 theActor->GetProperty()->SetLineWidth(myLineWidth);
2220 theActor->GetProperty()->SetRepresentation(2);
2221 theActor->SetShrinkable(false);
2224 //==============================================================================