1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761 |
- #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 "../display/contourdisplay.h"
- #include "../display/linedisplay.h"
- #include "../display/slicewidget.h"
- #include "../display/solidsurfacewidget.h"
- #include "../display/streamwidget.h"
- #include "../display/vectordisplay.h"
- #include "../display/contourinimationdisplay.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"
- #include "../widget/linedisplayWidget.h"
- #include "../widget/contourdispalyWidget.h"
- #include "../widget/slicedisplaywidget.h"
- #include "../widget/solidsurfaceDisplaywidget.h"
- #include "../widget/Sslicewidget.h"
- #include "../widget/streamDisplaywidget.h"
- #include "../widget/vectorDisplaywidget.h"
- #include "../widget/contourinimationw.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();
- showHideVec_.clear();
- vectorScalarIndexVec.clear();
- TimeMeshVec_.clear();
- source = NULL;
- unmesh = NULL;
- uncontour = NULL;
- uncontourVec_.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();
- /*vectorWidget_->dataU.clear();
- vectorWidget_->dataV.clear();
- vectorWidget_->dataW.clear();
- vectorWidget_->SetScaleFactor(0.02);*/
- }
- if (solidSurfaceW_ != NULL)
- {
- //solidSurfaceW_->RestoreWidget();
- //solidSurfaceW_->SetShowHideState(true);
- //solidSurfaceW_->SetTransparency(1);
- }
- if (sliceW_ != NULL)
- {
- /*sliceW_->scalarNameVec.clear();
- sliceW_->zoneIdVec.clear();
- sliceW_->index = 0;
- sliceW_->oldIndex = -1;*/
- // sliceW_->RestoreWidget();
- }
- if (streamW_ != NULL)
- {
- //streamW_->RestoreWidget();
- /*streamW_->dataU.clear();
- streamW_->dataV.clear();
- streamW_->dataW.clear();
- streamW_->current_direction = "both";
- streamW_->showstate = true;
- streamW_->toolstate = true;*/
- }
- // 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;
- if(source!=NULL){
- source->Delete();
- source = NULL;
- }
- if(unmesh != NULL){
- unmesh->Delete();
- unmesh = NULL;
- }
- if(uncontour != NULL){
- uncontour->Delete();
- uncontour = NULL;
- }
- if(!uncontourVec_.empty()){
- qDeleteAll(uncontourVec_);
- }
- }
- /**
- * @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 if(extType == "dat"){
- meshObj_ = new Mesh_Tecplot;
- loadstate = meshObj_->Load_Ascii(name.toStdString());//0614append
- }
- 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)//frd
- {
- 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());//key sovletime
- 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();
- }
- }
- /*for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
- it2 != unMehsIt->second.end(); it2 ++)
- {
- it2->second->SetOpacity(0);
- it2->second->ShowOn();
- }*/
- }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());
- }
- }
- void ResultMeshManager::SetXyplotWidget(XYPlot_2D *w)
- {
- }
- /**
- * @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());
- }
- }
- //create_streamTrace(x,y,z);
- }
- /**
- * @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();
- }
- }
- void ResultMeshManager::GetExportPictures(QString file)
- {
- }
- /**
- * @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_;
- }
- void ResultMeshManager::create_streamTrace(double x, double y, double z)
- {
- if(streamLine_!=NULL){
- streamLine_->SetStreamLineStartPosition(x,y,z);
- streamLine_->CreateOneStreamLine();
- }
- }
- /**
- * @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();
- }
|