12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678 |
- #include <algorithm>
- #include <set>
- #include <QString>
- #include <QFileInfo>
- #include "../QVTKRenderer/qvtkrenderer.h"
- #include "../mesh/mesh.h"
- #include "../MeshDS/MeshBase.h"
- #include "../mesh/mesh_ugrid.h"
- #include "../visualization_VTK/vtkVISUnContour.h"
- #include "../visualization_VTK/vtkvisunstructuredgridsource.h"
- #include "ResultMeshManager.h"
- #include "../visualization_VTK/vtkVISMeshToVTKSource.h"
- #include "../mesh/mesh_tecplot.h"
- #include "../mesh/Mesh_Frd.h"
- #include "../visualization_VTK/vtkvisunshademesh.h"
- #include "../visualization_VTK/vtkVISUnGlyph.h"
- //#include "contourinimation.h"
- #include "../display/slicewidget.h"
- //#include "streamwidget.h"
- //#include "xyplot_2d.h"
- #include <vtkAppendFilter.h>
- #include <QDebug>
- #include <QMessageBox>
- #include <vtkTextActor.h>
- #include "../visualization_VTK/vtkvismeshbasetovtksource.h"
- #include "vtkPoints.h"
- //ResultMeshManager* ResultMeshManager::m_pInstance = 0;
- /**
- * @brief singleton methed, get class instance.
- *
- * @param[in]
- * @return the class instance.
- * @author zhaoyu
- * @date 20221202
- */
- //ResultMeshManager* ResultMeshManager::getInstance()
- //{
- // if (m_pInstance == 0)
- // {
- // m_pInstance = new ResultMeshManager;
- // }
- // return m_pInstance;
- //}
- /**
- * @brief the constructor.
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221202
- */
- ResultMeshManager::ResultMeshManager()
- {
- meshObj_ = 0;
- m_currId = -1;
- scalarIndex = -1;
- range_[0] = 0;
- range_[1] = 0;
- scalarLeave = 10;
- titleSize_ = 6;
- labelSize_ = 5;
- // animationWidget_ = NULL;
- contourWidget_ = NULL;
- lineWidget_ = NULL;
- vectorWidget_ = NULL;
- solidSurfaceW_ = NULL;
- sliceW_ = NULL;
- streamW_ = NULL;
- // xyplot2dW_ = NULL;
- changeRangeFlag = false;
- surfaceHideFlag = true;
- displayType = -1;
- scaleFactor_ = 0.02;
- solveTimes_.clear();
- zoneNameVec_.clear();
- currShowZoneNameSet_.clear();
- surfaceActorColor_.clear();
- scalarName_.clear();
- allZoneScalarName_.clear();
- surfaceActorColor_.push_back(0);
- surfaceActorColor_.push_back(0);
- surfaceActorColor_.push_back(1);
- surfaceActorTransparency_ = 1;
- addDataSource_ = NULL;
- currAddDataSource_ = NULL;
- unSliceVec_.clear();
- streamLine_ = NULL;
- render_ = NULL;
- titleText_ = NULL;
- MeshVec_.clear();
- ModalMeshVec_.clear();
- initPointsData = NULL;
- dispNameVec.clear();
- HaveModalMeshFlag = false;
- meshType = 0;
- xyplot2dSlice_ = NULL;
- currentVISGridVec_.clear();
- }
- /**
- * @brief the destructor.
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221202
- */
- ResultMeshManager::~ResultMeshManager()
- {
- this->Clear();
- }
- /**
- * @brief clear the mesh information.
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221202
- */
- void ResultMeshManager::Clear()
- {
- if (meshObj_)
- {
- //delete meshObj_;
- meshObj_ = NULL;
- }
- m_currId = -1;
- scalarIndex = -1;
- range_[0] = 0;
- range_[1] = 0;
- scalarLeave = 10;
- titleSize_ = 6;
- labelSize_ = 5;
- changeRangeFlag = false;
- surfaceHideFlag = true;
- displayType = -1;
- scaleFactor_ = 0.02;
- solveTimes_.clear();
- zoneNameVec_.clear();
- currShowZoneNameSet_.clear();
- nameTypeMap_.clear();
- showHideVec_.clear();
- surfaceActorColor_.clear();
- scalarName_.clear();
- allZoneScalarName_.clear();
- //vtk vis procs.
- for(map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.begin(); it != vtkVisZoneMeshMap_.end(); ++it)
- {
- for(map<string, vtkVISUnContour*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneMeshMap_.clear();
- for(map<double, map<string, vtkVISUnShadeMesh*>>::iterator it = vtkVisZoneUnShadeMeshMap_.begin(); it != vtkVisZoneUnShadeMeshMap_.end(); ++it)
- {
- for(map<string, vtkVISUnShadeMesh*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneUnShadeMeshMap_.clear();
- for(map<double, map<string, vtkVISUnGlyph*>>::iterator it = vtkVisZoneGlyphMap_.begin(); it != vtkVisZoneGlyphMap_.end(); ++it)
- {
- for(map<string, vtkVISUnGlyph*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneGlyphMap_.clear();
- if (!unSliceVec_.empty())
- {
- for (int i = 0; i < unSliceVec_.size(); i ++)
- {
- if(unSliceVec_.at(i) != NULL)
- {
- unSliceVec_.at(i)->Delete();
- unSliceVec_.at(i) = NULL;
- }
- }
- unSliceVec_.clear();
- }
- if (currentVISGridVec_.size() != 0)
- {
- /*for (int i = 0; i < currentVISGridVec_.size(); i ++)
- {
- delete currentVISGridVec_.at(i);
- }*/
- currentVISGridVec_.clear();
- }
- if (addDataSource_ != NULL)
- {
- delete addDataSource_;
- addDataSource_ = NULL;
- }
- if (currAddDataSource_ != NULL)
- {
- delete currAddDataSource_;
- currAddDataSource_ = NULL;
- }
- DeleteAllStream();
- if (streamLine_ != NULL)
- {
- streamLine_->Delete();
- streamLine_ = NULL;
- }
- if (xyplot2dSlice_ != NULL)
- {
- xyplot2dSlice_->Delete();
- xyplot2dSlice_ = NULL;
- }
- surfaceActorColor_.push_back(0);
- surfaceActorColor_.push_back(0);
- surfaceActorColor_.push_back(1);
- surfaceActorTransparency_ = 1;
- // if (animationWidget_ != NULL)
- // {
- // animationWidget_->RestoreWidget();
- // }
- if (contourWidget_ != NULL)
- {
- contourWidget_->RestoreWidget();
- }
- if (lineWidget_ != NULL)
- {
- lineWidget_->RestoreWidget();
- }
- if (vectorWidget_ != NULL)
- {
- //vectorWidget_->RestoreWidget();
- }
- if (solidSurfaceW_ != NULL)
- {
- //solidSurfaceW_->RestoreWidget();
- }
- // if (sliceW_ != NULL)
- // {
- // sliceW_->RestoreWidget();
- // }
- if (streamW_ != NULL)
- {
- //streamW_->RestoreWidget();
- }
- // if (xyplot2dW_ != NULL)
- // {
- // xyplot2dW_->RestoreWidget();
- // }
- if (render_ != NULL)
- {
- render_->HideAllActors();
- render_ = NULL;
- }
- MeshVec_.clear();
- TimeMeshVec_.clear();
- ModalMeshVec_.clear();
- if (initPointsData != NULL)
- {
- delete initPointsData;
- }
- initPointsData = NULL;
- dispNameVec.clear();
- HaveModalMeshFlag = false;
- meshType = 0;
- }
- /**
- * @brief load result mesh from file.
- *
- * @param[in] the mesh file path.
- * @return loading mesh is sucessful or not.
- * @author zhaoyu
- * @date 20221202
- */
- bool ResultMeshManager::LoadData(QString name)
- {
- bool loadstate = false;
- QFileInfo meshinfo(name);
- QString extType(meshinfo.completeSuffix().toLower());
- if (extType == "tec" || extType == "plt" )
- {
- meshObj_ = new Mesh_Tecplot;
- if (extType == "tec")
- ;
- else if (extType == "plt" )
- loadstate = meshObj_->Load_Binary(name.toStdString());
- }else if (extType.contains("frd"))
- {
- Mesh_Frd* mfrd = new Mesh_Frd;
- loadstate = mfrd->Load_Ascii(name.toStdString());
- if (loadstate)
- {
- dispNameVec = mfrd->GetDispVec();
- initPointsData = mfrd->GetBase()->GetPoints();
- TimeMeshVec_ = mfrd->GetMeshVec();
- ModalMeshVec_ = mfrd->GetModalMeshVec();
- if (ModalMeshVec_.size() != 0)
- HaveModalMeshFlag = true;
- MeshVec_ = TimeMeshVec_;
- }
- }
- else
- {
- QMessageBox::information(NULL,"Error","The import of this file format is temporarily not supported.",QMessageBox::Ok);
- }
- return loadstate;
- }
- /**
- * @brief display mesh in renderer. vtk vis mode.
- *
- * @param[in] the renderer to draw mesh.
- * @return
- * @author shiting
- * @date 20220729
- */
- void ResultMeshManager::DisplayMesh(QVTKRenderer *qvtkRenderer)
- {
- if (MeshVec_.size() == 0)
- {
- render_ = qvtkRenderer;
- if (meshObj_ == 0) return;
- if (qvtkRenderer == 0) return;
- solveTimes_.insert(meshObj_->GetSovleTime());
- size_t nzone = meshObj_->GetZoneNumber();
- vtkVISMeshToVTKSource* source = new vtkVISMeshToVTKSource;
- map<string, vtkVISUnContour*> contourMap;
- map<string, vtkVISUnGlyph*> glyphMap;
- map<string, vtkVISUnShadeMesh*> unMeshMap;
- source->MeshToVTK(meshObj_);
- int type = source->GetType();
- if (type == -1)//unKnow
- {
- }else if (type == 0)//structured
- {
- }else if (type == 1)//unstructured
- {
- for (int i = 0; i < nzone; i ++)
- {
- if (source->GetVtkUnMesh(i) != NULL)
- {
- map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(meshObj_->GetSovleTime());
- if (contourIt != vtkVisZoneMeshMap_.end())
- {
- contourMap = contourIt->second;
- }
- map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMeshIt = vtkVisZoneUnShadeMeshMap_.find(meshObj_->GetSovleTime());
- if (unMeshIt != vtkVisZoneUnShadeMeshMap_.end())
- {
- unMeshMap = unMeshIt->second;
- }
- map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(meshObj_->GetSovleTime());
- if (glyphIt != vtkVisZoneGlyphMap_.end())
- {
- glyphMap = glyphIt->second;
- }
- vtkVISUnstructuredGridSource* unGrid = source->GetVtkUnMesh(i);
- vtkVISUnContour* visobj = vtkVISUnContour::New();//contour
- visobj->SetRenderTo(qvtkRenderer->GetRenderer());
- vtkVISUnGlyph* unGlyph = vtkVISUnGlyph::New();//glyph3d
- unGlyph->SetRenderTo(qvtkRenderer->GetRenderer());
- vtkVISUnShadeMesh* unMesh = vtkVISUnShadeMesh::New();//unShadeMesh
- unMesh->SetRenderTo(qvtkRenderer->GetRenderer());
- visobj->SetDataSource(unGrid);
- unGlyph->SetDataSource(unGrid);
- unMesh->SetDataSource(unGrid);
- unMesh->CreateShadeMeshSurfaceDisplay(true);
- string zoneName = meshObj_->GetZoneName().at(i);
- if (!count(zoneNameVec_.begin(), zoneNameVec_.end(), zoneName))
- {
- zoneNameVec_.push_back(zoneName);
- }
- contourMap[zoneName] = visobj;
- glyphMap[zoneName] = unGlyph;
- unMeshMap[zoneName] = unMesh;
- }
- }
- }
- vtkVisZoneMeshMap_[meshObj_->GetSovleTime()] = contourMap;
- vtkVisZoneGlyphMap_[meshObj_->GetSovleTime()] = glyphMap;
- vtkVisZoneUnShadeMeshMap_[meshObj_->GetSovleTime()] = unMeshMap;
- }
- else
- {
- /*meshObj_ = MeshVec_.at(0);
- vtkVISMeshToVTKSource* source = new vtkVISMeshToVTKSource;
- source->MeshToVTK(meshObj_);
- vtkVISUnShadeMesh* unMesh = vtkVISUnShadeMesh::New();
- unMesh->SetRenderTo(qvtkRenderer->GetRenderer());
- unMesh->SetDataSource(source->GetVtkUnMesh(0));
- unMesh->CreateShadeMeshSurfaceDisplay(true);
- qvtkRenderer->ZoomToExtents();*/
- for (int i = 0; i < MeshVec_.size(); i ++)
- {
- meshObj_ = MeshVec_.at(i);
- render_ = qvtkRenderer;
- if (meshObj_ == 0) return;
- if (qvtkRenderer == 0) return;
- solveTimes_.insert(meshObj_->GetSovleTime());
- size_t nzone = meshObj_->GetZoneNumber();
- vtkVISMeshToVTKSource* source = new vtkVISMeshToVTKSource;
- map<string, vtkVISUnContour*> contourMap;
- map<string, vtkVISUnGlyph*> glyphMap;
- map<string, vtkVISUnShadeMesh*> unMeshMap;
- source->MeshToVTK(meshObj_);
- int type = source->GetType();
- if (type == -1)//unKnow
- {
- }else if (type == 0)//structured
- {
- }else if (type == 1)//unstructured
- {
- for (int i = 0; i < nzone; i ++)
- {
- if (source->GetVtkUnMesh(i) != NULL)
- {
- map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(meshObj_->GetSovleTime());
- if (contourIt != vtkVisZoneMeshMap_.end())
- {
- contourMap = contourIt->second;
- }
- map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMeshIt = vtkVisZoneUnShadeMeshMap_.find(meshObj_->GetSovleTime());
- if (unMeshIt != vtkVisZoneUnShadeMeshMap_.end())
- {
- unMeshMap = unMeshIt->second;
- }
- map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(meshObj_->GetSovleTime());
- if (glyphIt != vtkVisZoneGlyphMap_.end())
- {
- glyphMap = glyphIt->second;
- }
- vtkVISUnstructuredGridSource* unGrid = source->GetVtkUnMesh(i);
- vtkVISUnContour* visobj = vtkVISUnContour::New();//contour
- visobj->SetRenderTo(qvtkRenderer->GetRenderer());
- vtkVISUnGlyph* unGlyph = vtkVISUnGlyph::New();//glyph3d
- unGlyph->SetRenderTo(qvtkRenderer->GetRenderer());
- vtkVISUnShadeMesh* unMesh = vtkVISUnShadeMesh::New();//unShadeMesh
- unMesh->SetRenderTo(qvtkRenderer->GetRenderer());
- visobj->SetDataSource(unGrid);
- unGlyph->SetDataSource(unGrid);
- unMesh->SetDataSource(unGrid);
- unMesh->CreateShadeMeshSurfaceDisplay(true);
- string zoneName = meshObj_->GetZoneName().at(i);
- if (!count(zoneNameVec_.begin(), zoneNameVec_.end(), zoneName))
- {
- zoneNameVec_.push_back(zoneName);
- }
- contourMap[zoneName] = visobj;
- glyphMap[zoneName] = unGlyph;
- unMeshMap[zoneName] = unMesh;
- }
- }
- }
- vtkVisZoneMeshMap_[meshObj_->GetSovleTime()] = contourMap;
- vtkVisZoneGlyphMap_[meshObj_->GetSovleTime()] = glyphMap;
- vtkVisZoneUnShadeMeshMap_[meshObj_->GetSovleTime()] = unMeshMap;
- }
- }
- }
- /**
- * @brief set show or hide state
- *
- * @param[in] vector<bool>
- * @return
- * @author zhaoyu
- * @date 20221209
- */
- void ResultMeshManager::SetShowHideState(vector<bool> vec)
- {
- currShowZoneNameSet_.clear();
- showHideVec_.clear();
- showHideVec_ = vec;
- int i = 0;
- for (vector<string>::iterator it = zoneNameVec_.begin(); it != zoneNameVec_.end(); it ++)
- {
- if (vec.at(i))
- {
- currShowZoneNameSet_.insert(*it);
- }
- i ++;
- }
- }
- /**
- * @brief show all zones
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221209
- */
- void ResultMeshManager::ShowAll()
- {
- if (meshObj_ == 0) return;
- currShowZoneNameSet_.clear();
- for (int i = 0; i < zoneNameVec_.size(); i ++)
- {
- currShowZoneNameSet_.insert(zoneNameVec_.at(i));
- }
- showHideVec_.clear();
- for (int i = 0; i < zoneNameVec_.size(); i ++)
- {
- showHideVec_.push_back(true);
- }
- }
- /**
- * @brief display the mesh by index
- *
- * @param[in] mesh index
- * @return
- * @author zhaoyu
- * @date 20221205
- */
- void ResultMeshManager::DisplayMeshByIndex(int index)
- {
- bool scalarBarState = true;
- m_currId = index;
- HideSliceActors();
- HideXyplot2dSliceActors();
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- if (index >= 0 && index <= vtkVisZoneUnShadeMeshMap_.size())
- {
- map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMehsIt = vtkVisZoneUnShadeMeshMap_.find(time);
- //unshademesh
- if (surfaceHideFlag)
- {
- for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
- it2 != unMehsIt->second.end(); it2 ++)
- {
- if (currShowZoneNameSet_.count(it2->first))
- {
- it2->second->SetColor(surfaceActorColor_[0], surfaceActorColor_[1], surfaceActorColor_[2]);
- it2->second->SetOpacity(surfaceActorTransparency_);
- it2->second->ShowOn();
- }else
- {
- it2->second->ShowOff();
- }
- }
- }else
- {
- for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
- it2 != unMehsIt->second.end(); it2 ++)
- {
- it2->second->ShowOff();
- }
- }
- //contour or line
- if (displayType == 0 || displayType == 2)
- {
- HideAllGlyphActors();
- map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(time);
- InitRange(index);
- for (map<string, vtkVISUnContour*>::iterator it2 = contourIt->second.begin();
- it2 != contourIt->second.end(); it2 ++)
- {
- if (currShowZoneNameSet_.count(it2->first))
- {
- it2->second->SetContourType(displayType);
- it2->second->SetContourLevel(scalarLeave);
- /*if (scalarName_ != it2->second->GetScalarName())
- {
- char* name = (char*)scalarName_.c_str();
- it2->second->ModifyContourDisplay(name);
- it2->second->DeleteScalarBar();
- it2->second->CreateScalarBar();
- }*/
- char* name = (char*)scalarName_.c_str();
- it2->second->ModifyContourDisplay(name);
- it2->second->DeleteScalarBar();
- it2->second->CreateScalarBar();
- it2->second->ModifyDisplayScalarRange(range_[0], range_[1]);
- it2->second->ShowOffScalarBar();
- it2->second->ShowOn();
- if (scalarBarState)
- {
- scalarBarState = !(it2->second->UpdataScalarBar());
- if (!scalarBarState)
- {
- it2->second->ShowOnScalarBar();
- }
- }
- }else
- {
- it2->second->ShowOff();
- it2->second->ShowOffScalarBar();
- }
- }
- }else if (displayType == 3)//unglyph
- {
- HideAllContourActors();
- map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(time);
- for (map<string, vtkVISUnGlyph*>::iterator it2= glyphIt->second.begin();
- it2 != glyphIt->second.end(); it2 ++)
- {
- if (currShowZoneNameSet_.count(it2->first))
- {
- it2->second->InitGlyphDisplay(vectorScalarIndexVec.at(0),
- vectorScalarIndexVec.at(1),
- vectorScalarIndexVec.at(2));//cuode
- it2->second->SetGlyphScaleFactor(scaleFactor_);
- it2->second->ShowOn();
- }else
- {
- it2->second->ShowOff();
- }
- }
- }
- }
- render_->ZoomToExtents();
- }
- /**
- * @brief hide all actors in the renderer
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230224
- */
- void ResultMeshManager::HideAllActors()
- {
- render_->HideAllActors();
- }
- /**
- * @brief hide all contour actors in the renderer
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230224
- */
- void ResultMeshManager::HideAllUnshadeMeshActors()
- {
- if (meshObj_ == 0) return;
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMehsIt = vtkVisZoneUnShadeMeshMap_.find(time);
- for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
- it2 != unMehsIt->second.end(); it2 ++)
- {
- it2->second->ShowOff();
- }
- }
- /**
- * @brief hide all contour actors in the renderer
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230224
- */
- void ResultMeshManager::HideAllContourActors()
- {
- if (meshObj_ == 0) return;
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(time);
- for (map<string, vtkVISUnContour*>::iterator it2 = contourIt->second.begin();
- it2 != contourIt->second.end(); it2 ++)
- {
- it2->second->ShowOff();
- it2->second->ShowOffScalarBar();
- }
- }
- /**
- * @brief hide all vector actors in the renderer
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230224
- */
- void ResultMeshManager::HideAllGlyphActors()
- {
- if (meshObj_ == 0) return;
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(time);
- for (map<string, vtkVISUnGlyph*>::iterator it2= glyphIt->second.begin();
- it2 != glyphIt->second.end(); it2 ++)
- {
- it2->second->ShowOff();
- }
- }
- /**
- * @brief set index
- *
- * @param[in] index
- * @return
- * @author zhaoyu
- * @date 20221205
- */
- void ResultMeshManager::SetSaveIndex(int index)
- {
- m_currId = index;
- }
- int ResultMeshManager::GetCurrIndex()
- {
- return m_currId;
- }
- /**
- * @brief get zone name vector
- *
- * @param[in]
- * @return zoneNameVec_
- * @author zhaoyu
- * @date 20221206
- */
- vector<string> ResultMeshManager::GetZoneNameVec()
- {
- return zoneNameVec_;
- }
- /**
- * @brief get solve time vector
- *
- * @param[in]
- * @return solveTimes_
- * @author zhaoyu
- * @date 20221206
- */
- set<double> ResultMeshManager::GetSolveTime()
- {
- return solveTimes_;
- }
- /**
- * @brief add map data by mesh data
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221206
- */
- void ResultMeshManager::SetNameTypeMap()
- {
- if (meshObj_ == 0) return;
- for (int i = 0; i < meshObj_->GetScalarNumber(); i ++)
- {
- string name = meshObj_->GetScalarName().at(i);
- nameTypeMap_[name] = meshObj_->GetZoneScalarType().at(0).at(i + 3);
- //cout << name << ", " << meshObj_->GetZoneScalarType().at(0).at(i + 3) << endl;
- }
- }
- /**
- * @brief get name type map
- *
- * @param[in]
- * @return nameTypeMap_
- * @author zhaoyu
- * @date 20221206
- */
- map<string, int> ResultMeshManager::GetNameTypeMap()
- {
- return nameTypeMap_;
- }
- /**
- * @brief get scalar name vector
- *
- * @param[in]
- * @return vector<string> nameVec
- * @author zhaoyu
- * @date 20221208
- */
- vector<string> ResultMeshManager::GetMeshScalarNameVec()
- {
- if (meshObj_ == 0)
- {
- vector<string> nullVec;
- return nullVec;
- }
- return meshObj_->GetScalarName();
- }
- /**
- * @brief init scalar range
- *
- * @param[in] int current step
- * @return
- * @author zhaoyu
- * @date 20221209
- */
- void ResultMeshManager::InitRange(int index)
- {
- if(changeRangeFlag)//user set range
- {
- changeRangeFlag = false;
- }else// program calculated range
- {
- set<double> set_;
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == index)
- {
- time = *it;
- break;
- }
- num ++;
- }
- map<double, map<string, vtkVISUnContour*>>::iterator it1 = vtkVisZoneMeshMap_.find(time);
- set<double>::iterator it3;
- for (map<string, vtkVISUnContour*>::iterator unIt = it1->second.begin(); unIt != it1->second.end(); unIt ++)
- {
- if (currShowZoneNameSet_.count(unIt->first))
- {
- double range[2];
- //string str = meshObj_->GetScalarName().at(scalarIndex);
- char* scalarName = (char*)scalarName_.c_str();
- unIt->second->GetScalarRange(range, scalarName);
- set_.insert(range[0]);
- set_.insert(range[1]);
- }
- }
- if (set_.size() == 0)
- {
- range_[0] = 0;
- range_[1] = 0;
- }else
- {
- it3 = set_.begin();
- range_[0] = *it3;
- it3 = --set_.end();
- range_[1] = *it3;
- //cout << range_[0] << ", " << range_[1] << endl;
- }
- }
- SetWidgetRange();//init widget range parameter*/
- }
- /**
- * @brief Get scalar min range
- *
- * @param[in]
- * @return double min
- * @author zhaoyu
- * @date 20221210
- */
- double* ResultMeshManager::GetScalarRange()
- {
- return range_;
- }
- /**
- * @brief change scalar display
- *
- * @param[in] index
- * @return
- * @author zhaoyu
- * @date 20221210
- */
- void ResultMeshManager::ModifyScalarDisplay(int index)
- {
- if (scalarIndex != index)
- {
- scalarIndex = index;
- }
- }
- /**
- * @brief change scalar display
- *
- * @param[in] index
- * @return
- * @author zhaoyu
- * @date 20221210
- */
- void ResultMeshManager::ModifyScalarDisplay(string name)
- {
- if (scalarName_ != name && !(name.empty()))
- {
- scalarName_ = name;
- SetWidgetScalarName();
- InitRange(m_currId);
- }
- }
- /**
- * @brief get scalar display
- *
- * @param[in]
- * @return scalarIndex
- * @author zhaoyu
- * @date 20221210
- */
- int ResultMeshManager::GetScalarIndex()
- {
- return scalarIndex;
- }
- /**
- * @brief set scalar level
- *
- * @param[in] int level
- * @return
- * @author zhaoyu
- * @date 20221210
- */
- void ResultMeshManager::SetContourLevel(int level)
- {
- scalarLeave = level;
- }
- /**
- * @brief get scalar display
- *
- * @param[in]
- * @return scalarIndex
- * @author zhaoyu
- * @date 20221210
- */
- int ResultMeshManager::GetContourLevel()
- {
- return scalarLeave;
- }
- /**
- * @brief init contourWidget pointer
- *
- * @param[in] ContourDisplayW pointer
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetCotourWidget(ContourDisplayW* w)
- {
- contourWidget_ = w;
- if (meshObj_ != NULL)
- {
- contourWidget_->SetNameTypeMap(GetNameTypeMap());
- contourWidget_->SetScalarNameVec(GetMeshScalarNameVec());
- SetWidgetRange();
- SetWidgetScalarName();
- }
- }
- /**
- * @brief init lineWidget pointer
- *
- * @param[in] LineDisplayW pointer
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetLineWidget(LineDisplayW* w)
- {
- lineWidget_ = w;
- if (meshObj_ != NULL)
- {
- lineWidget_->SetNameTypeMap(GetNameTypeMap());
- lineWidget_->SetScalarNameVec(GetMeshScalarNameVec());
- SetWidgetRange();
- SetWidgetScalarName();
- }//
- }
- /**
- * @brief init vector Widget pointer
- *
- * @param[in] VectorW pointer
- * @return
- * @author zhaoyu
- * @date 20221226
- */
- void ResultMeshManager::SetVectorWidget(VectorW* w)
- {
- vectorWidget_ = w;
- if (meshObj_ != NULL)
- {
- vector<string> tmp = GetMeshScalarNameVec();//0504 append去除容器里元素的"\0000"
- for(auto &p:tmp){
- p=deleteSpaces(p);
- }
- vectorWidget_->GetData_u(tmp);
- vectorWidget_->GetData_v(tmp);
- vectorWidget_->GetData_w(tmp);
- vectorWidget_->SetScaleFactor(scaleFactor_);
- }
- }
- //void ResultMeshManager::SetAnimationWidget(ContourInimationW *w)
- //{
- // animationWidget_ = w;
- // if (meshObj_ != NULL)
- // {
- // w->SetTypeEnable(HaveModalMeshFlag);
- // animationWidget_->SetSolveTime(GetSolveTime());
- // animationWidget_->SetZoneNameVector(zoneNameVec_);
- // }
- //}
- void ResultMeshManager::SetSurfaceSolidWidget(SolidSurfaceWidget* w)
- {
- solidSurfaceW_ = w;
- }
- /**
- * @brief init slice Widget pointer
- *
- * @param[in] SsliceWidget pointer
- * @return
- * @author zhaoyu
- * @date 20230301
- */
- void ResultMeshManager::SetSliceWidget(SsliceWidget* w)
- {
- sliceW_ = w;
- if (meshObj_ != NULL)
- {
- sliceW_->GetZoneId(GetShowZoneId());
- sliceW_->GetScalarName(GetMeshScalarNameVec());
- }
- }
- /**
- * @brief init stream Widget pointer
- *
- * @param[in] stresmWidget pointer
- * @return
- * @author zhaoyu
- * @date 20230303
- */
- void ResultMeshManager::SetStremWidget(StreamDisplayWidget* w)
- {
- streamW_ = w;
- if (meshObj_ != NULL)
- {
- streamW_->SetData_u(GetMeshScalarNameVec());
- streamW_->SetData_v(GetMeshScalarNameVec());
- streamW_->SetData_w(GetMeshScalarNameVec());
- }
- }
- /**
- * @brief init xyplot2d Widget pointer
- *
- * @param[in] xyplot2d pointer
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- //void ResultMeshManager::SetXyplotWidget(XYPlot_2D* w)
- //{
- // xyplot2dW_ = w;
- // if (meshObj_ != NULL)
- // {
- // xyplot2dW_->SetArea(zoneNameVec_);
- // xyplot2dW_->SetYAxis(GetMeshScalarNameVec());
- // }
- //}
- /**
- * @brief init widgets range parameter
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetWidgetRange()
- {
- if (contourWidget_ != NULL)
- {
- contourWidget_->SetRange(range_);
- }
- if (lineWidget_ != NULL)
- {
- lineWidget_->SetRange(range_);
- }
- }
- /**
- * @brief init widgets scalar name
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetWidgetScalarName()
- {
- if (meshObj_ != NULL && (!scalarName_.empty()))
- {
- string name = scalarName_;
- if (contourWidget_ != NULL)
- {
- contourWidget_->SetCurrScalar(name);
- }
- if (lineWidget_ != NULL)
- {
- lineWidget_->SetCurrScalar(name);
- }
- }
- }
- /**
- * @brief set title size
- *
- * @param[in] int size
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetTitleSize(double size)
- {
- titleSize_ = size;
- //SetWidgetTitleSize();
- }
- /**
- * @brief init widget title size
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- //void ResultMeshManager::SetWidgetTitleSize()
- //{
- // if (contourWidget_ != NULL)
- // {
- // contourWidget_->SetTitleFont(titleSize_);
- // }
- //}
- /**
- * @brief set label size
- *
- * @param[in] int label size
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetLabelSize(double size)
- {
- labelSize_ = size;
- //SetWidgetLabelSize();
- }
- /**
- * @brief set widget label size
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- //void ResultMeshManager::SetWidgetLabelSize()
- //{
- // if (contourWidget_ != NULL)
- // {
- // contourWidget_->SetLabelFont(labelSize_);
- // }
- //}
- /**
- * @brief set level
- *
- * @param[in] int level
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetLevel(int level)
- {
- scalarLeave = level;
- SetWidgetLevel();
- }
- /**
- * @brief set widget level
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221213
- */
- void ResultMeshManager::SetWidgetLevel()
- {
- if (contourWidget_ != NULL)
- {
- contourWidget_->SetLevel(scalarLeave);
- }
- if (lineWidget_ != NULL)
- {
- lineWidget_->SetLevel(scalarLeave);
- }
- }
- /**
- * @brief user set range
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221214
- */
- void ResultMeshManager::SetRange(double* range)
- {
- range_[0] = range[0];
- range_[1] = range[1];
- changeRangeFlag = true;
- }
- /**
- * @brief user set range
- *
- * @param[in] type 0 is contour
- * type 2 is line
- * @return
- * @author zhaoyu
- * @date 20221214
- */
- void ResultMeshManager::SetDisplayType(int type)
- {
- displayType = type;
- }
- /**
- * @brief init contour widget and line widget parameter
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230110
- */
- void ResultMeshManager::InitWidgetsParameter()
- {
- // if (animationWidget_ != NULL)
- // {
- // animationWidget_->SetTypeEnable(HaveModalMeshFlag);
- // animationWidget_->SetSolveTime(GetSolveTime());
- // animationWidget_->SetZoneNameVector(zoneNameVec_);
- // }
- if (contourWidget_ != NULL)
- {
- contourWidget_->SetNameTypeMap(GetNameTypeMap());
- contourWidget_->SetScalarNameVec(GetMeshScalarNameVec());
- SetWidgetRange();
- SetWidgetScalarName();
- }
- if (lineWidget_ != NULL)
- {
- lineWidget_->SetNameTypeMap(GetNameTypeMap());
- lineWidget_->SetScalarNameVec(GetMeshScalarNameVec());
- SetWidgetRange();
- SetWidgetScalarName();
- }
- if (vectorWidget_ != NULL)
- {
- vectorWidget_->GetData_u(GetMeshScalarNameVec());
- vectorWidget_->GetData_v(GetMeshScalarNameVec());
- vectorWidget_->GetData_w(GetMeshScalarNameVec());
- vectorWidget_->SetScaleFactor(scaleFactor_);
- }
- if (sliceW_ != NULL)
- {
- sliceW_->GetScalarName(GetMeshScalarNameVec());
- sliceW_->GetZoneId(GetShowZoneId());
- }
- if (streamW_ != NULL)
- {
- streamW_->SetData_u(GetMeshScalarNameVec());
- streamW_->SetData_v(GetMeshScalarNameVec());
- streamW_->SetData_w(GetMeshScalarNameVec());
- }
- // if (xyplot2dW_ != NULL)
- // {
- // xyplot2dW_->SetArea(zoneNameVec_);
- // xyplot2dW_->SetYAxis(GetMeshScalarNameVec());
- // }
- }
- /**
- * @brief init contour widget and line widget parameter
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20221226
- */
- void ResultMeshManager::SetVectorScalarIndex(vector<int> indexVec)
- {
- vectorScalarIndexVec.clear();
- if (indexVec.at(0) == -1 ||
- indexVec.at(1) == -1 ||
- indexVec.at(2) == -1)
- {
- return;
- }else
- {
- vectorScalarIndexVec = indexVec;
- DisplayMeshByIndex(m_currId);
- }
- }
- /**
- * @brief set scaleFactor
- *
- * @param[in]double factor
- * @return
- * @author zhaoyu
- * @date 20230103
- */
- void ResultMeshManager::SetVectorScaleFactor(double factor)
- {
- scaleFactor_ = factor;
- }
- /**
- * @brief set surface actor color
- *
- * @param[in]color
- * @return
- * @author zhaoyu
- * @date 20230110
- */
- void ResultMeshManager::SetSurfaceColor(vector<double> color)
- {
- surfaceActorColor_ = color;
- }
- /**
- * @brief set surface actor transparency
- *
- * @param[in]value
- * @return
- * @author zhaoyu
- * @date 20230110
- */
- void ResultMeshManager::SetSurfaceTransparency(double value)
- {
- surfaceActorTransparency_ = value;
- }
- /**
- * @brief set surface actor state
- *
- * @param[in]bool flag
- * @return
- * @author zhaoyu
- * @date 20230110
- */
- void ResultMeshManager::SetSurfaceShowHideFlag(bool flag)
- {
- surfaceHideFlag = flag;
- }
- /**
- * @brief set scalar name
- *
- * @param[in]char* name
- * @return
- * @author zhaoyu
- * @date 20230111
- */
- void ResultMeshManager::SetScalarName(string name)
- {
- scalarName_ = name;
- }
- vector<int> ResultMeshManager::GetShowZoneId()
- {
- vector<int> zoneId;
- zoneId.clear();
- set<string>::iterator it;
- for (int i = 0; i < showHideVec_.size(); i ++)
- {
- if (showHideVec_.at(i))
- {
- zoneId.push_back(i);
- }
- }
- return zoneId;
- }
- void ResultMeshManager::InitSliceWidget()
- {
- HideAllUnshadeMeshActors();
- HideAllGlyphActors();
- HideAllContourActors();
- HideStreamActors();
- HideXyplot2dSliceActors();
- if (solidSurfaceW_ != NULL)
- {
- solidSurfaceW_->SetShowHideState(true);
- }
- }
- /**
- * @brief creat a vtkVISunstructuredGrid source that is added by all the show zone
- *
- * @param[in] time step
- * @return
- * @author zhaoyu
- * @date 20230217
- */
- void ResultMeshManager::MakeVISUnStructGrid()
- {
- if (meshObj_ == 0) return;
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- vector<vtkVISUnstructuredGridSource*> vec;
- map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
- if (it != vtkVisZoneMeshMap_.end())
- {
- for (map<string, vtkVISUnContour*>::iterator it2= it->second.begin();
- it2 != it->second.end(); it2 ++)
- {
- if (currShowZoneNameSet_.count(it2->first))
- {
- vtkVISUnstructuredGridSource* unGrid = vtkVISUnstructuredGridSource::New();
- unGrid = it2->second->GetDatSource();
- vec.push_back(unGrid);
- }
- }
- /*if (addDataSource_ != NULL)
- {
- //delete addDataSource_;
- addDataSource_ = NULL;
- }*/
- addDataSource_ = new vtkVISAddUnGridDataSource();
- addDataSource_->SetVISUnGridDataSource(vec);
- currentVISGridVec_.push_back(addDataSource_);
- }
- }
- /**
- * @brief get unslice position
- *
- * @param[in] unslice id
- * @return
- * @author zhaoyu
- * @date 20230221
- */
- vector<double> ResultMeshManager::GetUnslicePosition(int index)
- {
- double* data2;
- data2 = unSliceVec_.at(index)->GetSlicePlaneOrigin();
- vector<double> origin;
- origin.push_back(data2[0]);
- origin.push_back(data2[1]);
- origin.push_back(data2[2]);
- return origin;
- }
- /**
- * @brief get unslice source bounds
- *
- * @param[in] unslice id
- * @return
- * @author zhaoyu
- * @date 20230221
- */
- vector<double> ResultMeshManager::GetUnsliceSourceBounds(int index)
- {
- vector<double> bounds;
- if (unSliceVec_.at(index) != NULL)
- {
- double b[6];
- unSliceVec_.at(index)->GetSourceBounds_FD(b);
- for (int i = 0; i < 6; i ++)
- {
- bounds.push_back(b[i]);
- }
- }
- return bounds;
- }
- /**
- * @brief display a vtkVISUnstructGrid
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230221
- */
- void ResultMeshManager::DisplayUnstructGrid()
- {
- if (render_ == NULL)
- {
- return;
- }
- vtkVISUnSlice* unSlice_ = vtkVISUnSlice::New();
- unSlice_->SetRenderTo(render_->GetRenderer());
- string name = GetMeshScalarNameVec().at(0);
- unSlice_->SetDataSource(addDataSource_->GetSource());
- char* s = (char*)(name.c_str());
- char* v = NULL;
- unSlice_->SetSliceSource_FD(s, v);
- unSlice_->CreatUnShadeMeshDisplay();
- unSlice_->CreateSliceWidget_FD();
- unSlice_->CreateUnSliceContourDisplay_FD();
- unSlice_->CreateUnSliceContourLinesDisplay_FD();
- unSlice_->ShowOffUnSliceContourLinesDisplay();
- unSlice_->CreateUnSliceContourLinesLabelDisplay_FD();
- unSlice_->ShowOffUnSliceContourLinesLabelDisplay();
- unSliceVec_.push_back(unSlice_);
- render_->Update();
- }
- /**
- * @brief hide all slice actors in the renderer
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230225
- */
- void ResultMeshManager::HideSliceActors()
- {
- if (!unSliceVec_.empty())
- {
- for (int i = 0; i < unSliceVec_.size(); i ++)
- {
- if (unSliceVec_.at(i) != NULL)
- {
- unSliceVec_.at(i)->ShowOffSlicePlane();
- unSliceVec_.at(i)->ShowOffSlicePlaneWidget();
- unSliceVec_.at(i)->ShowOffUnShadeMesh();
- unSliceVec_.at(i)->ShowOffUnSliceMesh();
- unSliceVec_.at(i)->ShowOffUnSliceShade();
- unSliceVec_.at(i)->ShowOffCutActor();
- }
- }
- }
- }
- /**
- * @brief set slice state
- *
- * @param[in] all sliceWidget parameter
- * @return
- * @author zhaoyu
- * @date 20230225
- */
- void ResultMeshManager::SetAllSliceState(vector<int> sliceId, vector<bool> solidState, vector<bool> planeWidgetState, vector<vector<double>> nomal,
- vector<vector<double>> posision, vector<string> type, vector<string> contourName, vector<int> level,
- vector<bool> planeState, vector<bool>labelState)
- {
- for (int i = 0; i < sliceId.size(); i ++)
- {
- if (solidState.at(i))
- {
- unSliceVec_.at(sliceId.at(i))->ShowOnUnshadeMesh();
- }else
- {
- unSliceVec_.at(sliceId.at(i))->ShowOffUnShadeMesh();
- }
- if (planeWidgetState.at(i))
- {
- unSliceVec_.at(sliceId.at(i))->ShowOnSlicePlane();
- unSliceVec_.at(sliceId.at(i))->ShowOnSlicePlaneWidget();
- }else
- {
- unSliceVec_.at(sliceId.at(i))->ShowOffSlicePlane();
- unSliceVec_.at(sliceId.at(i))->ShowOffSlicePlaneWidget();
- }
- unSliceVec_.at(sliceId.at(i))->SetSlicePlaneNormal(nomal.at(i).at(0), nomal.at(i).at(1),nomal.at(i).at(2));
- unSliceVec_.at(sliceId.at(i))->SetSlicePlaneOrigin(posision.at(i).at(0), posision.at(i).at(1),posision.at(i).at(2));
- if (type.at(i) == "contour")
- {
- unSliceVec_.at(sliceId.at(i))->ShowOnUnSliceContourDisplay();
- unSliceVec_.at(sliceId.at(i))->ShowOffUnSliceContourLinesDisplay();
- }else if(type.at(i) == "line")
- {
- unSliceVec_.at(sliceId.at(i))->ShowOnUnSliceContourLinesDisplay();
- unSliceVec_.at(sliceId.at(i))->ShowOffUnSliceContourDisplay();
- }
- char* name = (char*)(contourName.at(i).c_str());
- unSliceVec_.at(sliceId.at(i))->ModifySliceSourceScalar_FD(name);
- unSliceVec_.at(sliceId.at(i))->ModifyUnSliceContourLevel(level.at(i));
- if (planeState.at(i))
- {
- //unSliceVec_.at(sliceId.at(i))->ShowOnSlicePlane();
- }else
- {
- unSliceVec_.at(sliceId.at(i))->ShowOffCutActor();
- }
- if (labelState.at(i))
- {
- unSliceVec_.at(sliceId.at(i))->ShowOnUnSliceContourLinesLabelDisplay();
- }else
- {
- unSliceVec_.at(sliceId.at(i))->ShowOffUnSliceContourLinesLabelDisplay();
- }
- }
- for (int i = 0; i < unSliceVec_.size(); i ++)
- {
- if (find(sliceId.begin(), sliceId.end(), i) == sliceId.end())
- {
- if (unSliceVec_.at(i) != NULL)
- {
- unSliceVec_.at(i)->ShowOffSlicePlane();
- unSliceVec_.at(i)->ShowOffSlicePlaneWidget();
- unSliceVec_.at(i)->ShowOffUnShadeMesh();
- unSliceVec_.at(i)->ShowOffUnSliceMesh();
- unSliceVec_.at(i)->ShowOffUnSliceShade();
- unSliceVec_.at(i)->ShowOffCutActor();
- unSliceVec_.at(i)->Delete();
- unSliceVec_.at(i) = NULL;
- }
- }
- }
- render_->Update();
- }
- /**
- * @brief updata slice widget parameter
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230301
- */
- void ResultMeshManager::UpdataSliceWidgetParameter()
- {
- if (sliceW_ == NULL)
- {
- return;
- }
- vector<int> sliceWId = sliceW_->GetSliceId();
- vector<vector<double>> normalVec;
- vector<vector<double>> originVec;
- for (int i = 0; i < sliceWId.size(); i ++)
- {
- double *data;
- data = unSliceVec_.at(sliceWId.at(i))->GetSlicePlaneNormal();
- vector<double> normal;
- normal.push_back(data[0]);
- normal.push_back(data[1]);
- normal.push_back(data[2]);
- normalVec.push_back(normal);
- double *data2;
- data2 = unSliceVec_.at(sliceWId.at(i))->GetSlicePlaneOrigin();
- vector<double> origin;
- origin.push_back(data2[0]);
- origin.push_back(data2[1]);
- origin.push_back(data2[2]);
- originVec.push_back(origin);
- }
- sliceW_->normal.clear();
- sliceW_->position.clear();
- sliceW_->normal = normalVec;
- sliceW_->position = originVec;
- }
- /**
- * @brief updata the source consisting of all current grids
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230306
- */
- void ResultMeshManager::UpdataCurrUnstructSource()
- {
- double time = 0.0;
- int num = 0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- vector<vtkVISUnstructuredGridSource*> vec;
- map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
- if (it != vtkVisZoneMeshMap_.end())
- {
- for (map<string, vtkVISUnContour*>::iterator it2= it->second.begin();
- it2 != it->second.end(); it2 ++)
- {
- if (currShowZoneNameSet_.count(it2->first))
- {
- vtkVISUnstructuredGridSource* unGrid = vtkVISUnstructuredGridSource::New();
- unGrid = it2->second->GetDatSource();
- vec.push_back(unGrid);
- }
- }
- if (currAddDataSource_ != NULL)
- {
- delete currAddDataSource_;
- currAddDataSource_ = NULL;
- }
- currAddDataSource_ = new vtkVISAddUnGridDataSource();
- currAddDataSource_->SetVISUnGridDataSource(vec);
- }
- }
- /**
- * @brief creat a vector from the scalar name passed in
- *
- * @param[in] three scalar names
- * @return
- * @author zhaoyu
- * @date 20230302
- */
- void ResultMeshManager::CreatVectorSource(string u, string v, string w)
- {
- UpdataCurrUnstructSource();
- char* v1 = (char*)(u.c_str());
- char* v2 = (char*)(v.c_str());
- char* v3 = (char*)(w.c_str());
- if (streamLine_ != NULL)
- {
- streamLine_->ShowOffStreamWidget();
- streamLine_->ShowOffStreamTraceLines();
- streamLine_->Delete();
- streamLine_ = NULL;
- }
- if (currAddDataSource_ != NULL)
- {
- streamLine_ = vtkVISUnStreamTrace::New();
- streamLine_->SetRenderTo(render_->GetRenderer());
- streamLine_->SetDataSource(currAddDataSource_->GetSource());
- streamLine_->SetStreamTraceSource(v1,v2,v3);
- string type = "line";
- streamLine_->SetSeedsType(type);
- streamLine_->CreateStreamTraceDisplayByVector();
- if (streamW_ != NULL)
- {
- streamW_->SetInitStepData(streamLine_->GetInitialStep());
- streamW_->SetMaxPropgationData(streamLine_->GetMaxPropagation());
- streamW_->SetMinStepData(streamLine_->GetMinimumStep());
- }
- }
- }
- /**
- * @brief display stream line
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230302
- */
- void ResultMeshManager::DisplayStreamLine(string direction, string type,
- double initStrp, double maxPropgation, double minStep, bool showState, bool ToolState)
- {
- if (streamLine_ != NULL)
- {
- char* direc = (char*)(direction.c_str());
- streamLine_->ModifyIntegraDirection(direc);
- //type
- streamLine_->ShowOffStreamTraceLines();
- char* streamType = (char*)type.c_str();
- streamLine_->ModifyStreamStyle(streamType);
- streamLine_->ModifyInitialStep(initStrp);
- streamLine_->ModifyMaxPropagation(maxPropgation);
- streamLine_->ModifyMinimumStep(minStep);
- if (showState)
- {
- streamLine_->ShowOnStreamTraceLines();
- }else
- {
- streamLine_->ShowOffStreamTraceLines();
- }
- if (ToolState)
- {
- streamLine_->ShowOnStreamWidget();
- }else
- {
- streamLine_->ShowOffStreamWidget();
- }
- }
- render_->Update();
- }
- /**
- * @brief set select state, true is On, false is OFF
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230310
- */
- void ResultMeshManager::SetStreamSelectState(bool flag)
- {
- if (streamLine_ == NULL)
- return;
- if (flag)
- {
- streamLine_->vtkSelectPointOn();
- }else
- {
- streamLine_->vtkSelectPointOff();
- }
- }
- /**
- * @brief delete all Stream
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230310
- */
- void ResultMeshManager::DeleteAllStream()
- {
- if (streamLine_ != NULL)
- {
- streamLine_->ShowOffStreamWidget();
- streamLine_->ShowOffStreamTraceLines();
- streamLine_->vtkSelectPointOff();
- render_->Update();
- streamLine_->Delete();
- streamLine_ = NULL;
- }
- }
- /**
- * @brief export the current render picture
- *
- * @param[in]
- * @return
- * @author hejingjing
- * @date 20230315
- */
- //void ResultMeshManager::GetExportPictures(QString file)
- //{
- // QFileInfo info(file);
- // if (render_!= NULL && (render_->GetRenderer()->VisibleActorCount() > 0))
- // {
- // captureF = vtkVISCaptureFigure::New();
- // captureF->SetCaptureFigureSource(render_->GetRenderer());
- // QString extType = info.suffix();
- // qDebug() << extType;
- // string st = file.toStdString();
- // char *str = (char*)st.c_str();//qstring转char
- // if(extType.contains( "JPEG" ))
- // {
- // captureF->CaptureRenderFigureAsJPEG(str);
- // }
- // else if(extType.contains("BMP"))
- // {
- // captureF->CaptureRenderFigureAsBMP(str);
- // }
- // else if(extType.contains("PNG"))
- // {
- // captureF->CaptureRenderFigureAsPNG(str);
- // }
- // else if(extType.contains("TIFF"))
- // {
- // captureF->CaptureRenderFigureAsTIFF(str);
- // }
- // else if(extType.contains("PNM"))
- // {
- // captureF->CaptureRenderFigureAsPNM(str);
- // }
- // }
- //}
- /**
- * @brief hide streamLine and lineWidget
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230320
- *
- * */
- void ResultMeshManager::HideStreamActors()
- {
- DeleteAllStream();
- }
- //void ResultMeshManager::SetTextWidget(TextWidget *w)
- //{
- // textW_ = w;
- //}
- /**
- * @brief set textwidget state
- *
- * @param[in] all textwidget parameter
- * @return
- * @author hejingjing
- * @date 20230321
- */
- void ResultMeshManager::GetActorText(string text_, vector<double> position_XY, double fontsize,vector<double> color)
- {
- if(titleText_ != NULL)
- {
- titleText_->SetVisibility(false);
- titleText_->Delete();
- }
- titleText_ = vtkTextActor::New();
- if(!text_.empty())
- {
- const char *TitleText = text_.c_str();
- titleText_->SetInput(TitleText);
- titleText_->SetDisplayPosition(position_XY.at(0),position_XY.at(1));
- titleText_->GetTextProperty()->SetFontSize(fontsize);
- titleText_->GetTextProperty()->SetColor(color.at(0),color.at(1),color.at(2));
- render_->GetRenderer()->AddActor2D(titleText_);
- render_->Update();
- }
- }
- /**
- * @brief update the scaled model
- *
- * @param[in] double scaled factor
- * @return
- * @author zhaoyu
- * @date 20230406
- */
- void ResultMeshManager::UpdataZoomModel(double factor)
- {
- if (initPointsData == NULL)
- return;
- if (dispNameVec.size() == 0)
- return;
- if (MeshVec_.size() == 0)
- return;
- ///creat old data
- for(map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.begin(); it != vtkVisZoneMeshMap_.end(); ++it)
- {
- for(map<string, vtkVISUnContour*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneMeshMap_.clear();
- for(map<double, map<string, vtkVISUnShadeMesh*>>::iterator it = vtkVisZoneUnShadeMeshMap_.begin(); it != vtkVisZoneUnShadeMeshMap_.end(); ++it)
- {
- for(map<string, vtkVISUnShadeMesh*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneUnShadeMeshMap_.clear();
- for(map<double, map<string, vtkVISUnGlyph*>>::iterator it = vtkVisZoneGlyphMap_.begin(); it != vtkVisZoneGlyphMap_.end(); ++it)
- {
- for(map<string, vtkVISUnGlyph*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneGlyphMap_.clear();
- for (int i = 0; i < MeshVec_.size(); i ++)
- {
- for (int j = 0; j < MeshVec_.at(i)->GetZoneNumber(); j ++)
- {
- double* X;
- double* Y;
- double* Z;
- PointsDS* p = new PointsDS;
- p->SetPointNumber(initPointsData->GetPointNumber());
- for (int k = 0; k < MeshVec_.at(i)->GetScalarName().size(); k ++)
- {
- if (MeshVec_.at(i)->GetScalarName().at(k) == dispNameVec.at(0))
- {
- X = MeshVec_.at(i)->GetScalarData().at(j).at(k + 3);
- }else if (MeshVec_.at(i)->GetScalarName().at(k) == dispNameVec.at(1))
- {
- Y = MeshVec_.at(i)->GetScalarData().at(j).at(k + 3);
- }else if (MeshVec_.at(i)->GetScalarName().at(k) == dispNameVec.at(2))
- {
- Z = MeshVec_.at(i)->GetScalarData().at(j).at(k + 3);
- }
- }
- for (int k = 0; k < initPointsData->GetPointNumber(); k ++)
- {
- double xyz[3];
- initPointsData->GetPoint(k, xyz);
- double x = xyz[0] + (factor*X[k]);
- double y = xyz[1] + (factor*Y[k]);
- double z = xyz[2] + (factor*Z[k]);
- p->SetPoint(k, x, y, z);
- }
- MeshVec_.at(i)->GetZoneMesh(j)->SetPoints(p);
- }
- }
- DisplayMesh(render_);
- HideAllActors();
- DisplayMeshByIndex(0);
- //animationWidget_->SlotStart();
- render_->ZoomToExtents();
- }
- /**
- * @brief refill mesh vector by type
- *
- * @param[in] int type, 0 is time step, 1 is modal step
- * @return
- * @author zhaoyu
- * @date 20230410
- */
- void ResultMeshManager::ChangeMeshType(int type)
- {
- if (meshType != type)
- {
- meshType = type;
- if (meshObj_)
- {
- //delete meshObj_;
- meshObj_ = NULL;
- }
- m_currId = -1;
- scalarIndex = -1;
- range_[0] = 0;
- range_[1] = 0;
- scalarLeave = 10;
- titleSize_ = 6;
- labelSize_ = 5;
- changeRangeFlag = false;
- surfaceHideFlag = true;
- displayType = -1;
- scaleFactor_ = 0.02;
- solveTimes_.clear();
- zoneNameVec_.clear();
- currShowZoneNameSet_.clear();
- nameTypeMap_.clear();
- showHideVec_.clear();
- surfaceActorColor_.clear();
- scalarName_.clear();
- allZoneScalarName_.clear();
- //vtk vis procs.
- for(map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.begin(); it != vtkVisZoneMeshMap_.end(); ++it)
- {
- for(map<string, vtkVISUnContour*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneMeshMap_.clear();
- for(map<double, map<string, vtkVISUnShadeMesh*>>::iterator it = vtkVisZoneUnShadeMeshMap_.begin(); it != vtkVisZoneUnShadeMeshMap_.end(); ++it)
- {
- for(map<string, vtkVISUnShadeMesh*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneUnShadeMeshMap_.clear();
- for(map<double, map<string, vtkVISUnGlyph*>>::iterator it = vtkVisZoneGlyphMap_.begin(); it != vtkVisZoneGlyphMap_.end(); ++it)
- {
- for(map<string, vtkVISUnGlyph*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
- {
- itin->second->Delete();
- }
- it->second.clear();
- }
- vtkVisZoneGlyphMap_.clear();
- if (!unSliceVec_.empty())
- {
- for (int i = 0; i < unSliceVec_.size(); i ++)
- {
- if(unSliceVec_.at(i) != NULL)
- {
- unSliceVec_.at(i)->Delete();
- unSliceVec_.at(i) = NULL;
- }
- }
- unSliceVec_.clear();
- }
- if (addDataSource_ != NULL)
- {
- delete addDataSource_;
- addDataSource_ = NULL;
- }
- if (currAddDataSource_ != NULL)
- {
- delete currAddDataSource_;
- currAddDataSource_ = NULL;
- }
- DeleteAllStream();
- if (streamLine_ != NULL)
- {
- streamLine_->Delete();
- streamLine_ = NULL;
- }
- if (xyplot2dSlice_ != NULL)
- {
- xyplot2dSlice_->Delete();
- xyplot2dSlice_ = NULL;
- }
- surfaceActorColor_.push_back(0);
- surfaceActorColor_.push_back(0);
- surfaceActorColor_.push_back(1);
- surfaceActorTransparency_ = 1;
- // if (contourWidget_ != NULL)
- // {
- // contourWidget_->RestoreWidget();
- // }
- // if (lineWidget_ != NULL)
- // {
- // lineWidget_->RestoreWidget();
- // }
- // if (vectorWidget_ != NULL)
- // {
- // vectorWidget_->RestoreWidget();
- // }
- // if (solidSurfaceW_ != NULL)
- // {
- // solidSurfaceW_->RestoreWidget();
- // }
- // if (sliceW_ != NULL)
- // {
- // sliceW_->RestoreWidget();
- // }
- // if (streamW_ != NULL)
- // {
- // streamW_->RestoreWidget();
- // }
- // if (xyplot2dW_ != NULL)
- // {
- // xyplot2dW_->RestoreWidget();
- // }
- render_->HideAllActors();
- if (type == 0)
- {
- MeshVec_ = TimeMeshVec_;
- DisplayMesh(render_);
- HideAllActors();
- ShowAll();
- DisplayMeshByIndex(0);
- SetNameTypeMap();
- InitWidgetsParameter();
- // animationWidget_->SlotStart();
- // animationWidget_->InitScaleFactor();
- render_->ZoomToExtents();
- }else if (type == 1)
- {
- MeshVec_ = ModalMeshVec_;
- DisplayMesh(render_);
- HideAllActors();
- ShowAll();
- DisplayMeshByIndex(0);
- SetNameTypeMap();
- InitWidgetsParameter();
- // animationWidget_->SlotStart();
- // animationWidget_->InitScaleFactor();
- render_->ZoomToExtents();
- }
- }
- }
- /**
- * @brief display select zone to slice
- *
- * @param[in] int meshindex, int scalarindex, int normalIndex
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- void ResultMeshManager::DisplayXyplot2dSlice(int meshIndex, int sIndex)
- {
- if (render_ == NULL)
- {
- return;
- }
- if (xyplot2dSlice_ != NULL)
- {
- xyplot2dSlice_->Delete();
- xyplot2dSlice_ = NULL;
- }
- if (meshObj_ == 0) return;
- int num = 0;
- double time = 0.0;
- for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
- {
- if (num == m_currId)
- {
- time = *it;
- break;
- }
- num ++;
- }
- vtkVISUnstructuredGridSource* source = NULL;
- map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
- if (it != vtkVisZoneMeshMap_.end())
- {
- map<string, vtkVISUnContour*>::iterator it2= it->second.find(zoneNameVec_.at(meshIndex));
- if (it2 != it->second.end())
- {
- source = it2->second->GetDatSource();
- }
- }
- if (source == NULL)
- {
- cout << "source data error" << endl;
- return;
- }
- vtkVISUnSlice* unSlice_ = vtkVISUnSlice::New();
- unSlice_->SetRenderTo(render_->GetRenderer());
- string name = GetMeshScalarNameVec().at(sIndex);
- unSlice_->SetDataSource(source);
- char* s = (char*)(name.c_str());
- char* v = NULL;
- unSlice_->SetSliceSource_FD(s, v);
- unSlice_->CreatUnShadeMeshDisplay();
- unSlice_->CreateSliceWidget_FD();
- unSlice_->CreateUnSliceContourDisplay_FD();
- unSlice_->CreateUnSliceContourLinesDisplay_FD();
- unSlice_->ShowOffUnSliceContourLinesDisplay();
- unSlice_->CreateUnSliceContourLinesLabelDisplay_FD();
- unSlice_->ShowOffUnSliceContourLinesLabelDisplay();
- xyplot2dSlice_ = unSlice_;
- render_->ZoomToExtents();
- }
- /**
- * @brief get xyplot 2d unslice position
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- vector<double> ResultMeshManager::GetXyplot2dUnslicePosition()
- {
- double* data2;
- vector<double> origin;
- if (xyplot2dSlice_ != NULL)
- {
- data2 = xyplot2dSlice_->GetSlicePlaneOrigin();
- origin.push_back(data2[0]);
- origin.push_back(data2[1]);
- origin.push_back(data2[2]);
- }else
- {
- origin.push_back(0);
- origin.push_back(0);
- origin.push_back(0);
- }
- return origin;
- }
- /**
- * @brief set xyplot 2d unslice normal
- *
- * @param[in] int normal index
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- void ResultMeshManager::SetXyplot2dSliceNormal(int normalIndex)
- {
- if (xyplot2dSlice_ != NULL)
- {
- if (normalIndex == 0)
- {
- xyplot2dSlice_->SetSlicePlaneNormalToX();
- }else if (normalIndex == 1)
- {
- xyplot2dSlice_->SetSlicePlaneNormalToY();
- }else if (normalIndex == 2)
- {
- xyplot2dSlice_->SetSlicePlaneNormalToZ();
- }
- }
- render_->Update();
- }
- /**
- * @brief set xyplot 2d unslice scalar index
- *
- * @param[in] int scalar index
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- void ResultMeshManager::SetXyplot2dSliceScalarIndex(int index)
- {
- if (xyplot2dSlice_ != NULL)
- {
- string name = GetMeshScalarNameVec().at(index);
- char* s = (char*)(name.c_str());
- xyplot2dSlice_->ModifySliceSourceScalar_FD(s);
- }
- render_->Update();
- }
- /**
- * @brief Hide xyplot 2d unslice
- *
- * @param[in]
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- void ResultMeshManager::HideXyplot2dSliceActors()
- {
- if (xyplot2dSlice_ != NULL)
- {
- xyplot2dSlice_->ShowOffSlicePlane();
- xyplot2dSlice_->ShowOffSlicePlaneWidget();
- xyplot2dSlice_->ShowOffUnShadeMesh();
- xyplot2dSlice_->ShowOffUnSliceMesh();
- xyplot2dSlice_->ShowOffUnSliceShade();
- xyplot2dSlice_->ShowOffCutActor();
- }
- }
- /**
- * @brief set xyplot2d unslice position
- *
- * @param[in] vector<double> p
- * @return
- * @author zhaoyu
- * @date 20230411
- */
- void ResultMeshManager::SetXyplot2dSlicePosition(vector<double> p)
- {
- if (xyplot2dSlice_ != NULL)
- {
- xyplot2dSlice_->SetSlicePlaneOrigin(p[0], p[1], p[2]);
- }
- render_->Update();
- }
- /*
- * @brief: get private scalar name
- * @param: void
- * @ret: scalarName
- * @birth: created by czm in 20230421
- */
- string ResultMeshManager::getScalarName()
- {
- return this->scalarName_;
- }
- /*
- * @brief: get private range
- * @param: void
- * @ret: range
- * @birth: created by czm in 20230421
- */
- double *ResultMeshManager::getRange()
- {
- return this->range_;
- }
- /*
- * @brief: get private meshobj_
- * @param: void
- * @ret: meshobj_
- * @birth: created by czm in 20230421
- */
- Mesh *ResultMeshManager::getMeshObj_()
- {
- return this->meshObj_;
- }
- /**
- * @brief get xyplot2d unslice data
- *
- * @param[in]
- * @return x1 value1 x2 value2
- * @author zhaoyu
- * @date 20230411
- */
- //vector<vector<double>> ResultMeshManager::GetXyplot2dUnsliceData()
- //{
- // vector<vector<double>> xyplot2dVec;
- // string xName;
- // string yName;
- // yName = GetMeshScalarNameVec().at(xyplot2dW_->GetYName());
- // vector<vector<double>> totalVector;
- // totalVector.clear();
- // if (xyplot2dSlice_ != NULL)
- // {
- // vector<vtkDoubleArray*> vec;
- // vec = xyplot2dSlice_->GetSliceData();
- // string xAxis = xyplot2dW_->GetXAxis();
- // double range[2];
- // double middle = 0;
- // int normalIndex = xyplot2dW_->GetNormalIndex();
- // int referenceIndex;
- // vector<double> x1;
- // vector<double> value1;
- // vector<double> x2;
- // vector<double> value2;
- // if (xAxis == "X")
- // {
- // xName = "X";
- // if (xyplot2dW_->GetNormalIndex() == 1)
- // {
- // vec.at(0)->GetRange(range, 2);
- // referenceIndex = 2;
- // middle = (range[0] + range[1])/2.0;
- // }else if (xyplot2dW_->GetNormalIndex() == 2)
- // {
- // vec.at(0)->GetRange(range, 1);
- // referenceIndex = 1;
- // middle = (range[0] + range[1])/2.0;
- // }
- // for (int i = 0; i < vec.at(0)->GetNumberOfTuples(); i ++)
- // {
- // double reference = vec.at(0)->GetTuple(i)[referenceIndex];
- // if (reference < middle || reference == middle)
- // {
- // x1.push_back(vec.at(0)->GetTuple(i)[0]);
- // value1.push_back(vec.at(1)->GetValue(i));
- // }else
- // {
- // x2.push_back(vec.at(0)->GetTuple(i)[0]);
- // value2.push_back(vec.at(1)->GetValue(i));
- // }
- // }
- // }else if (xAxis == "Y")
- // {
- // xName = "Y";
- // if (xyplot2dW_->GetNormalIndex() == 0)
- // {
- // vec.at(0)->GetRange(range, 2);
- // referenceIndex = 2;
- // middle = (range[0] + range[1])/2.0;
- // }else if (xyplot2dW_->GetNormalIndex() == 2)
- // {
- // vec.at(0)->GetRange(range, 0);
- // referenceIndex = 0;
- // middle = (range[0] + range[1])/2.0;
- // }
- // for (int i = 0; i < vec.at(0)->GetNumberOfTuples(); i ++)
- // {
- // double reference = vec.at(0)->GetTuple(i)[referenceIndex];
- // if (reference < middle || reference == middle)
- // {
- // x1.push_back(vec.at(0)->GetTuple(i)[1]);
- // value1.push_back(vec.at(1)->GetValue(i));
- // }else
- // {
- // x2.push_back(vec.at(0)->GetTuple(i)[1]);
- // value2.push_back(vec.at(1)->GetValue(i));
- // }
- // }
- // }else if (xAxis == "Z")
- // {
- // xName = "Z";
- // if (xyplot2dW_->GetNormalIndex() == 0)
- // {
- // vec.at(0)->GetRange(range, 1);
- // referenceIndex = 1;
- // middle = (range[0] + range[1])/2.0;
- // }else if (xyplot2dW_->GetNormalIndex() == 1)
- // {
- // vec.at(0)->GetRange(range, 0);
- // referenceIndex = 0;
- // middle = (range[0] + range[1])/2.0;
- // }
- // for (int i = 0; i < vec.at(0)->GetNumberOfTuples(); i ++)
- // {
- // double reference = vec.at(0)->GetTuple(i)[referenceIndex];
- // if (reference < middle || reference == middle)
- // {
- // x1.push_back(vec.at(0)->GetTuple(i)[2]);
- // value1.push_back(vec.at(1)->GetValue(i));
- // }else
- // {
- // x2.push_back(vec.at(0)->GetTuple(i)[2]);
- // value2.push_back(vec.at(1)->GetValue(i));
- // }
- // }
- // }
- // totalVector.push_back(x1);
- // totalVector.push_back(value1);
- // totalVector.push_back(x2);
- // totalVector.push_back(value2);
- // }
- // return totalVector;
- //}
- /**
- * @brief get xyplot2d axis name
- *
- * @param[in]
- * @return xName and yName
- * @author zhaoyu
- * @date 20230414
- */
- //vector<string> ResultMeshManager::GetXyplot2dAxisName()
- //{
- // vector<string> xyplotwdNameVec;
- // xyplotwdNameVec.clear();
- // string xAxis = "X";
- // string yName = "Y";
- // if (xyplot2dSlice_ != NULL)
- // {
- // xAxis = xyplot2dW_->GetXAxis();
- // yName;
- // yName = GetMeshScalarNameVec().at(xyplot2dW_->GetYName());
- // }
- // xyplotwdNameVec.push_back(xAxis);
- // xyplotwdNameVec.push_back(yName);
- // return xyplotwdNameVec;
- //}
- /**
- * @brief get qvtkrenderer
- *
- * @param[in]
- * @return QVTKRenderer *render_
- * @author zhaoyu
- * @date 20230417
- */
- QVTKRenderer *ResultMeshManager::GetQVtkRender()
- {
- return render_;
- }
- /*
- * @brief: remove string's spaces
- * @param: string
- * @ret: string
- * @birth: created by czm in 20230504
- */
- string ResultMeshManager::deleteSpaces(string str)
- {
- QChar h0 = 0x00;
- QString str_;
- if(QString::fromStdString(str).contains(h0)){
- str_=QString::fromStdString(str).replace(h0,"");
- }
- return str_.toStdString();
- }
|