ResultMeshManager.cpp 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761
  1. #include <algorithm>
  2. #include <set>
  3. #include <QString>
  4. #include <QFileInfo>
  5. #include "../QVTKRenderer/qvtkrenderer.h"
  6. #include "../mesh/mesh.h"
  7. #include "../MeshDS/MeshBase.h"
  8. #include "../mesh/mesh_ugrid.h"
  9. #include "../display/contourdisplay.h"
  10. #include "../display/linedisplay.h"
  11. #include "../display/slicewidget.h"
  12. #include "../display/solidsurfacewidget.h"
  13. #include "../display/streamwidget.h"
  14. #include "../display/vectordisplay.h"
  15. #include "../display/contourinimationdisplay.h"
  16. #include "../visualization_VTK/vtkVISUnContour.h"
  17. #include "../visualization_VTK/vtkvisunstructuredgridsource.h"
  18. #include "ResultMeshManager.h"
  19. #include "../visualization_VTK/vtkVISMeshToVTKSource.h"
  20. #include "../mesh/mesh_tecplot.h"
  21. #include "../mesh/Mesh_Frd.h"
  22. #include "../visualization_VTK/vtkvisunshademesh.h"
  23. #include "../visualization_VTK/vtkVISUnGlyph.h"
  24. //#include "contourinimation.h"
  25. #include "../display/slicewidget.h"
  26. //#include "streamwidget.h"
  27. //#include "xyplot_2d.h"
  28. #include <vtkAppendFilter.h>
  29. #include <QDebug>
  30. #include <QMessageBox>
  31. #include <vtkTextActor.h>
  32. #include "../visualization_VTK/vtkvismeshbasetovtksource.h"
  33. #include "vtkPoints.h"
  34. #include "../widget/linedisplayWidget.h"
  35. #include "../widget/contourdispalyWidget.h"
  36. #include "../widget/slicedisplaywidget.h"
  37. #include "../widget/solidsurfaceDisplaywidget.h"
  38. #include "../widget/Sslicewidget.h"
  39. #include "../widget/streamDisplaywidget.h"
  40. #include "../widget/vectorDisplaywidget.h"
  41. #include "../widget/contourinimationw.h"
  42. //ResultMeshManager* ResultMeshManager::m_pInstance = 0;
  43. /**
  44. * @brief singleton methed, get class instance.
  45. *
  46. * @param[in]
  47. * @return the class instance.
  48. * @author zhaoyu
  49. * @date 20221202
  50. */
  51. //ResultMeshManager* ResultMeshManager::getInstance()
  52. //{
  53. // if (m_pInstance == 0)
  54. // {
  55. // m_pInstance = new ResultMeshManager;
  56. // }
  57. // return m_pInstance;
  58. //}
  59. /**
  60. * @brief the constructor.
  61. *
  62. * @param[in]
  63. * @return
  64. * @author zhaoyu
  65. * @date 20221202
  66. */
  67. ResultMeshManager::ResultMeshManager()
  68. {
  69. meshObj_ = 0;
  70. m_currId = -1;
  71. scalarIndex = -1;
  72. range_[0] = 0;
  73. range_[1] = 0;
  74. scalarLeave = 10;
  75. titleSize_ = 6;
  76. labelSize_ = 5;
  77. animationWidget_ = NULL;
  78. contourWidget_ = NULL;
  79. lineWidget_ = NULL;
  80. vectorWidget_ = NULL;
  81. solidSurfaceW_ = NULL;
  82. sliceW_ = NULL;
  83. streamW_ = NULL;
  84. // xyplot2dW_ = NULL;
  85. changeRangeFlag = false;
  86. surfaceHideFlag = true;
  87. displayType = -1;
  88. scaleFactor_ = 0.02;
  89. solveTimes_.clear();
  90. zoneNameVec_.clear();
  91. currShowZoneNameSet_.clear();
  92. surfaceActorColor_.clear();
  93. scalarName_.clear();
  94. allZoneScalarName_.clear();
  95. surfaceActorColor_.push_back(0);
  96. surfaceActorColor_.push_back(0);
  97. surfaceActorColor_.push_back(1);
  98. surfaceActorTransparency_ = 1;
  99. addDataSource_ = NULL;
  100. currAddDataSource_ = NULL;
  101. unSliceVec_.clear();
  102. streamLine_ = NULL;
  103. render_ = NULL;
  104. titleText_ = NULL;
  105. MeshVec_.clear();
  106. ModalMeshVec_.clear();
  107. initPointsData = NULL;
  108. dispNameVec.clear();
  109. HaveModalMeshFlag = false;
  110. meshType = 0;
  111. xyplot2dSlice_ = NULL;
  112. currentVISGridVec_.clear();
  113. showHideVec_.clear();
  114. vectorScalarIndexVec.clear();
  115. TimeMeshVec_.clear();
  116. source = NULL;
  117. unmesh = NULL;
  118. uncontour = NULL;
  119. uncontourVec_.clear();
  120. }
  121. /**
  122. * @brief the destructor.
  123. *
  124. * @param[in]
  125. * @return
  126. * @author zhaoyu
  127. * @date 20221202
  128. */
  129. ResultMeshManager::~ResultMeshManager()
  130. {
  131. this->Clear();
  132. }
  133. /**
  134. * @brief clear the mesh information.
  135. *
  136. * @param[in]
  137. * @return
  138. * @author zhaoyu
  139. * @date 20221202
  140. */
  141. void ResultMeshManager::Clear()
  142. {
  143. if (meshObj_)
  144. {
  145. //delete meshObj_;
  146. meshObj_ = NULL;
  147. }
  148. m_currId = -1;
  149. scalarIndex = -1;
  150. range_[0] = 0;
  151. range_[1] = 0;
  152. scalarLeave = 10;
  153. titleSize_ = 6;
  154. labelSize_ = 5;
  155. changeRangeFlag = false;
  156. surfaceHideFlag = true;
  157. displayType = -1;
  158. scaleFactor_ = 0.02;
  159. solveTimes_.clear();
  160. zoneNameVec_.clear();
  161. currShowZoneNameSet_.clear();
  162. nameTypeMap_.clear();
  163. showHideVec_.clear();
  164. surfaceActorColor_.clear();
  165. scalarName_.clear();
  166. allZoneScalarName_.clear();
  167. //vtk vis procs.
  168. for(map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.begin(); it != vtkVisZoneMeshMap_.end(); ++it)
  169. {
  170. for(map<string, vtkVISUnContour*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  171. {
  172. itin->second->Delete();
  173. }
  174. it->second.clear();
  175. }
  176. vtkVisZoneMeshMap_.clear();
  177. for(map<double, map<string, vtkVISUnShadeMesh*>>::iterator it = vtkVisZoneUnShadeMeshMap_.begin(); it != vtkVisZoneUnShadeMeshMap_.end(); ++it)
  178. {
  179. for(map<string, vtkVISUnShadeMesh*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  180. {
  181. itin->second->Delete();
  182. }
  183. it->second.clear();
  184. }
  185. vtkVisZoneUnShadeMeshMap_.clear();
  186. for(map<double, map<string, vtkVISUnGlyph*>>::iterator it = vtkVisZoneGlyphMap_.begin(); it != vtkVisZoneGlyphMap_.end(); ++it)
  187. {
  188. for(map<string, vtkVISUnGlyph*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  189. {
  190. itin->second->Delete();
  191. }
  192. it->second.clear();
  193. }
  194. vtkVisZoneGlyphMap_.clear();
  195. if (!unSliceVec_.empty())
  196. {
  197. for (int i = 0; i < unSliceVec_.size(); i ++)
  198. {
  199. if(unSliceVec_.at(i) != NULL)
  200. {
  201. unSliceVec_.at(i)->Delete();
  202. unSliceVec_.at(i) = NULL;
  203. }
  204. }
  205. unSliceVec_.clear();
  206. }
  207. if (currentVISGridVec_.size() != 0)
  208. {
  209. /*for (int i = 0; i < currentVISGridVec_.size(); i ++)
  210. {
  211. delete currentVISGridVec_.at(i);
  212. }*/
  213. currentVISGridVec_.clear();
  214. }
  215. if (addDataSource_ != NULL)
  216. {
  217. delete addDataSource_;
  218. addDataSource_ = NULL;
  219. }
  220. if (currAddDataSource_ != NULL)
  221. {
  222. delete currAddDataSource_;
  223. currAddDataSource_ = NULL;
  224. }
  225. DeleteAllStream();
  226. if (streamLine_ != NULL)
  227. {
  228. streamLine_->Delete();
  229. streamLine_ = NULL;
  230. }
  231. if (xyplot2dSlice_ != NULL)
  232. {
  233. xyplot2dSlice_->Delete();
  234. xyplot2dSlice_ = NULL;
  235. }
  236. surfaceActorColor_.push_back(0);
  237. surfaceActorColor_.push_back(0);
  238. surfaceActorColor_.push_back(1);
  239. surfaceActorTransparency_ = 1;
  240. // if (animationWidget_ != NULL)
  241. // {
  242. // animationWidget_->RestoreWidget();
  243. // }
  244. if (contourWidget_ != NULL)
  245. {
  246. contourWidget_->RestoreWidget();
  247. }
  248. if (lineWidget_ != NULL)
  249. {
  250. lineWidget_->RestoreWidget();
  251. }
  252. if (vectorWidget_ != NULL)
  253. {
  254. //vectorWidget_->RestoreWidget();
  255. /*vectorWidget_->dataU.clear();
  256. vectorWidget_->dataV.clear();
  257. vectorWidget_->dataW.clear();
  258. vectorWidget_->SetScaleFactor(0.02);*/
  259. }
  260. if (solidSurfaceW_ != NULL)
  261. {
  262. //solidSurfaceW_->RestoreWidget();
  263. //solidSurfaceW_->SetShowHideState(true);
  264. //solidSurfaceW_->SetTransparency(1);
  265. }
  266. if (sliceW_ != NULL)
  267. {
  268. /*sliceW_->scalarNameVec.clear();
  269. sliceW_->zoneIdVec.clear();
  270. sliceW_->index = 0;
  271. sliceW_->oldIndex = -1;*/
  272. // sliceW_->RestoreWidget();
  273. }
  274. if (streamW_ != NULL)
  275. {
  276. //streamW_->RestoreWidget();
  277. /*streamW_->dataU.clear();
  278. streamW_->dataV.clear();
  279. streamW_->dataW.clear();
  280. streamW_->current_direction = "both";
  281. streamW_->showstate = true;
  282. streamW_->toolstate = true;*/
  283. }
  284. // if (xyplot2dW_ != NULL)
  285. // {
  286. // xyplot2dW_->RestoreWidget();
  287. // }
  288. if (render_ != NULL)
  289. {
  290. render_->HideAllActors();
  291. render_ = NULL;
  292. }
  293. MeshVec_.clear();
  294. TimeMeshVec_.clear();
  295. ModalMeshVec_.clear();
  296. if (initPointsData != NULL)
  297. {
  298. delete initPointsData;
  299. }
  300. initPointsData = NULL;
  301. dispNameVec.clear();
  302. HaveModalMeshFlag = false;
  303. meshType = 0;
  304. if(source!=NULL){
  305. source->Delete();
  306. source = NULL;
  307. }
  308. if(unmesh != NULL){
  309. unmesh->Delete();
  310. unmesh = NULL;
  311. }
  312. if(uncontour != NULL){
  313. uncontour->Delete();
  314. uncontour = NULL;
  315. }
  316. if(!uncontourVec_.empty()){
  317. qDeleteAll(uncontourVec_);
  318. }
  319. }
  320. /**
  321. * @brief load result mesh from file.
  322. *
  323. * @param[in] the mesh file path.
  324. * @return loading mesh is sucessful or not.
  325. * @author zhaoyu
  326. * @date 20221202
  327. */
  328. bool ResultMeshManager::LoadData(QString name)
  329. {
  330. bool loadstate = false;
  331. QFileInfo meshinfo(name);
  332. QString extType(meshinfo.completeSuffix().toLower());
  333. if (extType == "tec" || extType == "plt" )
  334. {
  335. meshObj_ = new Mesh_Tecplot;
  336. if (extType == "tec")
  337. ;
  338. else if (extType == "plt" )
  339. loadstate = meshObj_->Load_Binary(name.toStdString());
  340. }else if (extType.contains("frd"))
  341. {
  342. Mesh_Frd* mfrd = new Mesh_Frd;
  343. loadstate = mfrd->Load_Ascii(name.toStdString());
  344. if (loadstate)
  345. {
  346. dispNameVec = mfrd->GetDispVec();
  347. initPointsData = mfrd->GetBase()->GetPoints();
  348. TimeMeshVec_ = mfrd->GetMeshVec();
  349. ModalMeshVec_ = mfrd->GetModalMeshVec();
  350. if (ModalMeshVec_.size() != 0)
  351. HaveModalMeshFlag = true;
  352. MeshVec_ = TimeMeshVec_;
  353. }
  354. }else if(extType == "dat"){
  355. meshObj_ = new Mesh_Tecplot;
  356. loadstate = meshObj_->Load_Ascii(name.toStdString());//0614append
  357. }
  358. else
  359. {
  360. QMessageBox::information(NULL,"Error","The import of this file format is temporarily not supported.",QMessageBox::Ok);
  361. }
  362. return loadstate;
  363. }
  364. /**
  365. * @brief display mesh in renderer. vtk vis mode.
  366. *
  367. * @param[in] the renderer to draw mesh.
  368. * @return
  369. * @author shiting
  370. * @date 20220729
  371. */
  372. void ResultMeshManager::DisplayMesh(QVTKRenderer *qvtkRenderer)
  373. {
  374. if (MeshVec_.size() == 0)//frd
  375. {
  376. render_ = qvtkRenderer;
  377. if (meshObj_ == 0) return;
  378. if (qvtkRenderer == 0) return;
  379. solveTimes_.insert(meshObj_->GetSovleTime());
  380. size_t nzone = meshObj_->GetZoneNumber();
  381. vtkVISMeshToVTKSource* source = new vtkVISMeshToVTKSource;
  382. map<string, vtkVISUnContour*> contourMap;
  383. map<string, vtkVISUnGlyph*> glyphMap;
  384. map<string, vtkVISUnShadeMesh*> unMeshMap;
  385. source->MeshToVTK(meshObj_);
  386. int type = source->GetType();
  387. if (type == -1)//unKnow
  388. {
  389. }else if (type == 0)//structured
  390. {
  391. }else if (type == 1)//unstructured
  392. {
  393. for (int i = 0; i < nzone; i ++)
  394. {
  395. if (source->GetVtkUnMesh(i) != NULL)
  396. {
  397. map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(meshObj_->GetSovleTime());//key sovletime
  398. if (contourIt != vtkVisZoneMeshMap_.end())
  399. {
  400. contourMap = contourIt->second;
  401. }
  402. map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMeshIt = vtkVisZoneUnShadeMeshMap_.find(meshObj_->GetSovleTime());
  403. if (unMeshIt != vtkVisZoneUnShadeMeshMap_.end())
  404. {
  405. unMeshMap = unMeshIt->second;
  406. }
  407. map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(meshObj_->GetSovleTime());
  408. if (glyphIt != vtkVisZoneGlyphMap_.end())
  409. {
  410. glyphMap = glyphIt->second;
  411. }
  412. vtkVISUnstructuredGridSource* unGrid = source->GetVtkUnMesh(i);
  413. vtkVISUnContour* visobj = vtkVISUnContour::New();//contour
  414. visobj->SetRenderTo(qvtkRenderer->GetRenderer());
  415. vtkVISUnGlyph* unGlyph = vtkVISUnGlyph::New();//glyph3d
  416. unGlyph->SetRenderTo(qvtkRenderer->GetRenderer());
  417. vtkVISUnShadeMesh* unMesh = vtkVISUnShadeMesh::New();//unShadeMesh
  418. unMesh->SetRenderTo(qvtkRenderer->GetRenderer());
  419. visobj->SetDataSource(unGrid);
  420. unGlyph->SetDataSource(unGrid);
  421. unMesh->SetDataSource(unGrid);
  422. unMesh->CreateShadeMeshSurfaceDisplay(true);
  423. string zoneName = meshObj_->GetZoneName().at(i);
  424. if (!count(zoneNameVec_.begin(), zoneNameVec_.end(), zoneName))
  425. {
  426. zoneNameVec_.push_back(zoneName);
  427. }
  428. contourMap[zoneName] = visobj;
  429. glyphMap[zoneName] = unGlyph;
  430. unMeshMap[zoneName] = unMesh;
  431. }
  432. }
  433. }
  434. vtkVisZoneMeshMap_[meshObj_->GetSovleTime()] = contourMap;
  435. vtkVisZoneGlyphMap_[meshObj_->GetSovleTime()] = glyphMap;
  436. vtkVisZoneUnShadeMeshMap_[meshObj_->GetSovleTime()] = unMeshMap;
  437. }
  438. else
  439. {
  440. /*meshObj_ = MeshVec_.at(0);
  441. vtkVISMeshToVTKSource* source = new vtkVISMeshToVTKSource;
  442. source->MeshToVTK(meshObj_);
  443. vtkVISUnShadeMesh* unMesh = vtkVISUnShadeMesh::New();
  444. unMesh->SetRenderTo(qvtkRenderer->GetRenderer());
  445. unMesh->SetDataSource(source->GetVtkUnMesh(0));
  446. unMesh->CreateShadeMeshSurfaceDisplay(true);
  447. qvtkRenderer->ZoomToExtents();*/
  448. for (int i = 0; i < MeshVec_.size(); i ++)
  449. {
  450. meshObj_ = MeshVec_.at(i);
  451. render_ = qvtkRenderer;
  452. if (meshObj_ == 0) return;
  453. if (qvtkRenderer == 0) return;
  454. solveTimes_.insert(meshObj_->GetSovleTime());
  455. size_t nzone = meshObj_->GetZoneNumber();
  456. vtkVISMeshToVTKSource* source = new vtkVISMeshToVTKSource;
  457. map<string, vtkVISUnContour*> contourMap;
  458. map<string, vtkVISUnGlyph*> glyphMap;
  459. map<string, vtkVISUnShadeMesh*> unMeshMap;
  460. source->MeshToVTK(meshObj_);
  461. int type = source->GetType();
  462. if (type == -1)//unKnow
  463. {
  464. }else if (type == 0)//structured
  465. {
  466. }else if (type == 1)//unstructured
  467. {
  468. for (int i = 0; i < nzone; i ++)
  469. {
  470. if (source->GetVtkUnMesh(i) != NULL)
  471. {
  472. map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(meshObj_->GetSovleTime());
  473. if (contourIt != vtkVisZoneMeshMap_.end())
  474. {
  475. contourMap = contourIt->second;
  476. }
  477. map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMeshIt = vtkVisZoneUnShadeMeshMap_.find(meshObj_->GetSovleTime());
  478. if (unMeshIt != vtkVisZoneUnShadeMeshMap_.end())
  479. {
  480. unMeshMap = unMeshIt->second;
  481. }
  482. map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(meshObj_->GetSovleTime());
  483. if (glyphIt != vtkVisZoneGlyphMap_.end())
  484. {
  485. glyphMap = glyphIt->second;
  486. }
  487. vtkVISUnstructuredGridSource* unGrid = source->GetVtkUnMesh(i);
  488. vtkVISUnContour* visobj = vtkVISUnContour::New();//contour
  489. visobj->SetRenderTo(qvtkRenderer->GetRenderer());
  490. vtkVISUnGlyph* unGlyph = vtkVISUnGlyph::New();//glyph3d
  491. unGlyph->SetRenderTo(qvtkRenderer->GetRenderer());
  492. vtkVISUnShadeMesh* unMesh = vtkVISUnShadeMesh::New();//unShadeMesh
  493. unMesh->SetRenderTo(qvtkRenderer->GetRenderer());
  494. visobj->SetDataSource(unGrid);
  495. unGlyph->SetDataSource(unGrid);
  496. unMesh->SetDataSource(unGrid);
  497. unMesh->CreateShadeMeshSurfaceDisplay(true);
  498. string zoneName = meshObj_->GetZoneName().at(i);
  499. if (!count(zoneNameVec_.begin(), zoneNameVec_.end(), zoneName))
  500. {
  501. zoneNameVec_.push_back(zoneName);
  502. }
  503. contourMap[zoneName] = visobj;
  504. glyphMap[zoneName] = unGlyph;
  505. unMeshMap[zoneName] = unMesh;
  506. }
  507. }
  508. }
  509. vtkVisZoneMeshMap_[meshObj_->GetSovleTime()] = contourMap;
  510. vtkVisZoneGlyphMap_[meshObj_->GetSovleTime()] = glyphMap;
  511. vtkVisZoneUnShadeMeshMap_[meshObj_->GetSovleTime()] = unMeshMap;
  512. }
  513. }
  514. }
  515. /**
  516. * @brief set show or hide state
  517. *
  518. * @param[in] vector<bool>
  519. * @return
  520. * @author zhaoyu
  521. * @date 20221209
  522. */
  523. void ResultMeshManager::SetShowHideState(vector<bool> vec)
  524. {
  525. currShowZoneNameSet_.clear();
  526. showHideVec_.clear();
  527. showHideVec_ = vec;
  528. int i = 0;
  529. for (vector<string>::iterator it = zoneNameVec_.begin(); it != zoneNameVec_.end(); it ++)
  530. {
  531. if (vec.at(i))
  532. {
  533. currShowZoneNameSet_.insert(*it);
  534. }
  535. i ++;
  536. }
  537. }
  538. /**
  539. * @brief show all zones
  540. *
  541. * @param[in]
  542. * @return
  543. * @author zhaoyu
  544. * @date 20221209
  545. */
  546. void ResultMeshManager::ShowAll()
  547. {
  548. if (meshObj_ == 0) return;
  549. currShowZoneNameSet_.clear();
  550. for (int i = 0; i < zoneNameVec_.size(); i ++)
  551. {
  552. currShowZoneNameSet_.insert(zoneNameVec_.at(i));
  553. }
  554. showHideVec_.clear();
  555. for (int i = 0; i < zoneNameVec_.size(); i ++)
  556. {
  557. showHideVec_.push_back(true);
  558. }
  559. }
  560. /**
  561. * @brief display the mesh by index
  562. *
  563. * @param[in] mesh index
  564. * @return
  565. * @author zhaoyu
  566. * @date 20221205
  567. */
  568. void ResultMeshManager::DisplayMeshByIndex(int index)
  569. {
  570. bool scalarBarState = true;
  571. m_currId = index;
  572. HideSliceActors();
  573. HideXyplot2dSliceActors();
  574. int num = 0;
  575. double time = 0.0;
  576. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  577. {
  578. if (num == m_currId)
  579. {
  580. time = *it;
  581. break;
  582. }
  583. num ++;
  584. }
  585. if (index >= 0 && index <= vtkVisZoneUnShadeMeshMap_.size())
  586. {
  587. map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMehsIt = vtkVisZoneUnShadeMeshMap_.find(time);
  588. //unshademesh
  589. if (surfaceHideFlag)
  590. {
  591. for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
  592. it2 != unMehsIt->second.end(); it2 ++)
  593. {
  594. if (currShowZoneNameSet_.count(it2->first))
  595. {
  596. it2->second->SetColor(surfaceActorColor_[0], surfaceActorColor_[1], surfaceActorColor_[2]);
  597. it2->second->SetOpacity(surfaceActorTransparency_);
  598. it2->second->ShowOn();
  599. }else
  600. {
  601. it2->second->ShowOff();
  602. }
  603. }
  604. }else
  605. {
  606. for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
  607. it2 != unMehsIt->second.end(); it2 ++)
  608. {
  609. it2->second->ShowOff();
  610. }
  611. }
  612. //contour or line
  613. if (displayType == 0 || displayType == 2)
  614. {
  615. HideAllGlyphActors();
  616. map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(time);
  617. InitRange(index);
  618. for (map<string, vtkVISUnContour*>::iterator it2 = contourIt->second.begin();
  619. it2 != contourIt->second.end(); it2 ++)
  620. {
  621. if (currShowZoneNameSet_.count(it2->first))
  622. {
  623. it2->second->SetContourType(displayType);
  624. it2->second->SetContourLevel(scalarLeave);
  625. /*if (scalarName_ != it2->second->GetScalarName())
  626. {
  627. char* name = (char*)scalarName_.c_str();
  628. it2->second->ModifyContourDisplay(name);
  629. it2->second->DeleteScalarBar();
  630. it2->second->CreateScalarBar();
  631. }*/
  632. char* name = (char*)scalarName_.c_str();
  633. it2->second->ModifyContourDisplay(name);
  634. it2->second->DeleteScalarBar();
  635. it2->second->CreateScalarBar();
  636. it2->second->ModifyDisplayScalarRange(range_[0], range_[1]);
  637. it2->second->ShowOffScalarBar();
  638. it2->second->ShowOn();
  639. if (scalarBarState)
  640. {
  641. scalarBarState = !(it2->second->UpdataScalarBar());
  642. if (!scalarBarState)
  643. {
  644. it2->second->ShowOnScalarBar();
  645. }
  646. }
  647. }else
  648. {
  649. it2->second->ShowOff();
  650. it2->second->ShowOffScalarBar();
  651. }
  652. }
  653. /*for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
  654. it2 != unMehsIt->second.end(); it2 ++)
  655. {
  656. it2->second->SetOpacity(0);
  657. it2->second->ShowOn();
  658. }*/
  659. }else if (displayType == 3)//unglyph
  660. {
  661. HideAllContourActors();
  662. map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(time);
  663. for (map<string, vtkVISUnGlyph*>::iterator it2= glyphIt->second.begin();
  664. it2 != glyphIt->second.end(); it2 ++)
  665. {
  666. if (currShowZoneNameSet_.count(it2->first))
  667. {
  668. it2->second->InitGlyphDisplay(vectorScalarIndexVec.at(0),
  669. vectorScalarIndexVec.at(1),
  670. vectorScalarIndexVec.at(2));//cuode
  671. it2->second->SetGlyphScaleFactor(scaleFactor_);
  672. it2->second->ShowOn();
  673. }else
  674. {
  675. it2->second->ShowOff();
  676. }
  677. }
  678. }
  679. }
  680. render_->ZoomToExtents();
  681. }
  682. /**
  683. * @brief hide all actors in the renderer
  684. *
  685. * @param[in]
  686. * @return
  687. * @author zhaoyu
  688. * @date 20230224
  689. */
  690. void ResultMeshManager::HideAllActors()
  691. {
  692. render_->HideAllActors();
  693. }
  694. /**
  695. * @brief hide all contour actors in the renderer
  696. *
  697. * @param[in]
  698. * @return
  699. * @author zhaoyu
  700. * @date 20230224
  701. */
  702. void ResultMeshManager::HideAllUnshadeMeshActors()
  703. {
  704. if (meshObj_ == 0) return;
  705. int num = 0;
  706. double time = 0.0;
  707. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  708. {
  709. if (num == m_currId)
  710. {
  711. time = *it;
  712. break;
  713. }
  714. num ++;
  715. }
  716. map<double, map<string, vtkVISUnShadeMesh*>>::iterator unMehsIt = vtkVisZoneUnShadeMeshMap_.find(time);
  717. for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
  718. it2 != unMehsIt->second.end(); it2 ++)
  719. {
  720. it2->second->ShowOff();
  721. }
  722. }
  723. /**
  724. * @brief hide all contour actors in the renderer
  725. *
  726. * @param[in]
  727. * @return
  728. * @author zhaoyu
  729. * @date 20230224
  730. */
  731. void ResultMeshManager::HideAllContourActors()
  732. {
  733. if (meshObj_ == 0) return;
  734. int num = 0;
  735. double time = 0.0;
  736. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  737. {
  738. if (num == m_currId)
  739. {
  740. time = *it;
  741. break;
  742. }
  743. num ++;
  744. }
  745. map<double, map<string, vtkVISUnContour*>>::iterator contourIt = vtkVisZoneMeshMap_.find(time);
  746. for (map<string, vtkVISUnContour*>::iterator it2 = contourIt->second.begin();
  747. it2 != contourIt->second.end(); it2 ++)
  748. {
  749. it2->second->ShowOff();
  750. it2->second->ShowOffScalarBar();
  751. }
  752. }
  753. /**
  754. * @brief hide all vector actors in the renderer
  755. *
  756. * @param[in]
  757. * @return
  758. * @author zhaoyu
  759. * @date 20230224
  760. */
  761. void ResultMeshManager::HideAllGlyphActors()
  762. {
  763. if (meshObj_ == 0) return;
  764. int num = 0;
  765. double time = 0.0;
  766. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  767. {
  768. if (num == m_currId)
  769. {
  770. time = *it;
  771. break;
  772. }
  773. num ++;
  774. }
  775. map<double, map<string, vtkVISUnGlyph*>>::iterator glyphIt = vtkVisZoneGlyphMap_.find(time);
  776. for (map<string, vtkVISUnGlyph*>::iterator it2= glyphIt->second.begin();
  777. it2 != glyphIt->second.end(); it2 ++)
  778. {
  779. it2->second->ShowOff();
  780. }
  781. }
  782. /**
  783. * @brief set index
  784. *
  785. * @param[in] index
  786. * @return
  787. * @author zhaoyu
  788. * @date 20221205
  789. */
  790. void ResultMeshManager::SetSaveIndex(int index)
  791. {
  792. m_currId = index;
  793. }
  794. int ResultMeshManager::GetCurrIndex()
  795. {
  796. return m_currId;
  797. }
  798. /**
  799. * @brief get zone name vector
  800. *
  801. * @param[in]
  802. * @return zoneNameVec_
  803. * @author zhaoyu
  804. * @date 20221206
  805. */
  806. vector<string> ResultMeshManager::GetZoneNameVec()
  807. {
  808. return zoneNameVec_;
  809. }
  810. /**
  811. * @brief get solve time vector
  812. *
  813. * @param[in]
  814. * @return solveTimes_
  815. * @author zhaoyu
  816. * @date 20221206
  817. */
  818. set<double> ResultMeshManager::GetSolveTime()
  819. {
  820. return solveTimes_;
  821. }
  822. /**
  823. * @brief add map data by mesh data
  824. *
  825. * @param[in]
  826. * @return
  827. * @author zhaoyu
  828. * @date 20221206
  829. */
  830. void ResultMeshManager::SetNameTypeMap()
  831. {
  832. if (meshObj_ == 0) return;
  833. for (int i = 0; i < meshObj_->GetScalarNumber(); i ++)
  834. {
  835. string name = meshObj_->GetScalarName().at(i);
  836. nameTypeMap_[name] = meshObj_->GetZoneScalarType().at(0).at(i + 3);
  837. //cout << name << ", " << meshObj_->GetZoneScalarType().at(0).at(i + 3) << endl;
  838. }
  839. }
  840. /**
  841. * @brief get name type map
  842. *
  843. * @param[in]
  844. * @return nameTypeMap_
  845. * @author zhaoyu
  846. * @date 20221206
  847. */
  848. map<string, int> ResultMeshManager::GetNameTypeMap()
  849. {
  850. return nameTypeMap_;
  851. }
  852. /**
  853. * @brief get scalar name vector
  854. *
  855. * @param[in]
  856. * @return vector<string> nameVec
  857. * @author zhaoyu
  858. * @date 20221208
  859. */
  860. vector<string> ResultMeshManager::GetMeshScalarNameVec()
  861. {
  862. if (meshObj_ == 0)
  863. {
  864. vector<string> nullVec;
  865. return nullVec;
  866. }
  867. return meshObj_->GetScalarName();
  868. }
  869. /**
  870. * @brief init scalar range
  871. *
  872. * @param[in] int current step
  873. * @return
  874. * @author zhaoyu
  875. * @date 20221209
  876. */
  877. void ResultMeshManager::InitRange(int index)
  878. {
  879. if(changeRangeFlag)//user set range
  880. {
  881. changeRangeFlag = false;
  882. }else// program calculated range
  883. {
  884. set<double> set_;
  885. int num = 0;
  886. double time = 0.0;
  887. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  888. {
  889. if (num == index)
  890. {
  891. time = *it;
  892. break;
  893. }
  894. num ++;
  895. }
  896. map<double, map<string, vtkVISUnContour*>>::iterator it1 = vtkVisZoneMeshMap_.find(time);
  897. set<double>::iterator it3;
  898. for (map<string, vtkVISUnContour*>::iterator unIt = it1->second.begin(); unIt != it1->second.end(); unIt ++)
  899. {
  900. if (currShowZoneNameSet_.count(unIt->first))
  901. {
  902. double range[2];
  903. //string str = meshObj_->GetScalarName().at(scalarIndex);
  904. char* scalarName = (char*)scalarName_.c_str();
  905. unIt->second->GetScalarRange(range, scalarName);
  906. set_.insert(range[0]);
  907. set_.insert(range[1]);
  908. }
  909. }
  910. if (set_.size() == 0)
  911. {
  912. range_[0] = 0;
  913. range_[1] = 0;
  914. }else
  915. {
  916. it3 = set_.begin();
  917. range_[0] = *it3;
  918. it3 = --set_.end();
  919. range_[1] = *it3;
  920. //cout << range_[0] << ", " << range_[1] << endl;
  921. }
  922. }
  923. SetWidgetRange();//init widget range parameter*/
  924. }
  925. /**
  926. * @brief Get scalar min range
  927. *
  928. * @param[in]
  929. * @return double min
  930. * @author zhaoyu
  931. * @date 20221210
  932. */
  933. double* ResultMeshManager::GetScalarRange()
  934. {
  935. return range_;
  936. }
  937. /**
  938. * @brief change scalar display
  939. *
  940. * @param[in] index
  941. * @return
  942. * @author zhaoyu
  943. * @date 20221210
  944. */
  945. void ResultMeshManager::ModifyScalarDisplay(int index)
  946. {
  947. if (scalarIndex != index)
  948. {
  949. scalarIndex = index;
  950. }
  951. }
  952. /**
  953. * @brief change scalar display
  954. *
  955. * @param[in] index
  956. * @return
  957. * @author zhaoyu
  958. * @date 20221210
  959. */
  960. void ResultMeshManager::ModifyScalarDisplay(string name)
  961. {
  962. if (scalarName_ != name && !(name.empty()))
  963. {
  964. scalarName_ = name;
  965. SetWidgetScalarName();
  966. InitRange(m_currId);
  967. }
  968. }
  969. /**
  970. * @brief get scalar display
  971. *
  972. * @param[in]
  973. * @return scalarIndex
  974. * @author zhaoyu
  975. * @date 20221210
  976. */
  977. int ResultMeshManager::GetScalarIndex()
  978. {
  979. return scalarIndex;
  980. }
  981. /**
  982. * @brief set scalar level
  983. *
  984. * @param[in] int level
  985. * @return
  986. * @author zhaoyu
  987. * @date 20221210
  988. */
  989. void ResultMeshManager::SetContourLevel(int level)
  990. {
  991. scalarLeave = level;
  992. }
  993. /**
  994. * @brief get scalar display
  995. *
  996. * @param[in]
  997. * @return scalarIndex
  998. * @author zhaoyu
  999. * @date 20221210
  1000. */
  1001. int ResultMeshManager::GetContourLevel()
  1002. {
  1003. return scalarLeave;
  1004. }
  1005. /**
  1006. * @brief init contourWidget pointer
  1007. *
  1008. * @param[in] ContourDisplayW pointer
  1009. * @return
  1010. * @author zhaoyu
  1011. * @date 20221213
  1012. */
  1013. void ResultMeshManager::SetCotourWidget(ContourDisplayW* w)
  1014. {
  1015. contourWidget_ = w;
  1016. if (meshObj_ != NULL)
  1017. {
  1018. contourWidget_->SetNameTypeMap(GetNameTypeMap());
  1019. contourWidget_->SetScalarNameVec(GetMeshScalarNameVec());
  1020. SetWidgetRange();
  1021. SetWidgetScalarName();
  1022. }
  1023. }
  1024. /**
  1025. * @brief init lineWidget pointer
  1026. *
  1027. * @param[in] LineDisplayW pointer
  1028. * @return
  1029. * @author zhaoyu
  1030. * @date 20221213
  1031. */
  1032. void ResultMeshManager::SetLineWidget(LineDisplayW* w)
  1033. {
  1034. lineWidget_ = w;
  1035. if (meshObj_ != NULL)
  1036. {
  1037. lineWidget_->SetNameTypeMap(GetNameTypeMap());
  1038. lineWidget_->SetScalarNameVec(GetMeshScalarNameVec());
  1039. SetWidgetRange();
  1040. SetWidgetScalarName();
  1041. }//
  1042. }
  1043. /**
  1044. * @brief init vector Widget pointer
  1045. *
  1046. * @param[in] VectorW pointer
  1047. * @return
  1048. * @author zhaoyu
  1049. * @date 20221226
  1050. */
  1051. void ResultMeshManager::SetVectorWidget(VectorW* w)
  1052. {
  1053. vectorWidget_ = w;
  1054. if (meshObj_ != NULL)
  1055. {
  1056. vector<string> tmp = GetMeshScalarNameVec();//0504 append去除容器里元素的"\0000"
  1057. //for(auto &p:tmp){
  1058. //p=deleteSpaces(p);
  1059. //}
  1060. vectorWidget_->GetData_u(tmp);
  1061. vectorWidget_->GetData_v(tmp);
  1062. vectorWidget_->GetData_w(tmp);
  1063. vectorWidget_->SetScaleFactor(scaleFactor_);
  1064. }
  1065. }
  1066. void ResultMeshManager::SetAnimationWidget(ContourInimationW *w)
  1067. {
  1068. animationWidget_ = w;
  1069. if (meshObj_ != NULL)
  1070. {
  1071. w->SetTypeEnable(HaveModalMeshFlag);
  1072. animationWidget_->SetSolveTime(GetSolveTime());
  1073. animationWidget_->SetZoneNameVector(zoneNameVec_);
  1074. }
  1075. }
  1076. void ResultMeshManager::SetSurfaceSolidWidget(SolidSurfaceWidget* w)
  1077. {
  1078. solidSurfaceW_ = w;
  1079. }
  1080. /**
  1081. * @brief init slice Widget pointer
  1082. *
  1083. * @param[in] SsliceWidget pointer
  1084. * @return
  1085. * @author zhaoyu
  1086. * @date 20230301
  1087. */
  1088. void ResultMeshManager::SetSliceWidget(SsliceWidget* w)
  1089. {
  1090. sliceW_ = w;
  1091. if (meshObj_ != NULL)
  1092. {
  1093. sliceW_->GetZoneId(GetShowZoneId());
  1094. sliceW_->GetScalarName(GetMeshScalarNameVec());
  1095. }
  1096. }
  1097. /**
  1098. * @brief init stream Widget pointer
  1099. *
  1100. * @param[in] stresmWidget pointer
  1101. * @return
  1102. * @author zhaoyu
  1103. * @date 20230303
  1104. */
  1105. void ResultMeshManager::SetStremWidget(StreamDisplayWidget* w)
  1106. {
  1107. streamW_ = w;
  1108. if (meshObj_ != NULL)
  1109. {
  1110. streamW_->SetData_u(GetMeshScalarNameVec());
  1111. streamW_->SetData_v(GetMeshScalarNameVec());
  1112. streamW_->SetData_w(GetMeshScalarNameVec());
  1113. }
  1114. }
  1115. void ResultMeshManager::SetXyplotWidget(XYPlot_2D *w)
  1116. {
  1117. }
  1118. /**
  1119. * @brief init xyplot2d Widget pointer
  1120. *
  1121. * @param[in] xyplot2d pointer
  1122. * @return
  1123. * @author zhaoyu
  1124. * @date 20230411
  1125. */
  1126. //void ResultMeshManager::SetXyplotWidget(XYPlot_2D* w)
  1127. //{
  1128. // xyplot2dW_ = w;
  1129. // if (meshObj_ != NULL)
  1130. // {
  1131. // xyplot2dW_->SetArea(zoneNameVec_);
  1132. // xyplot2dW_->SetYAxis(GetMeshScalarNameVec());
  1133. // }
  1134. //}
  1135. /**
  1136. * @brief init widgets range parameter
  1137. *
  1138. * @param[in]
  1139. * @return
  1140. * @author zhaoyu
  1141. * @date 20221213
  1142. */
  1143. void ResultMeshManager::SetWidgetRange()
  1144. {
  1145. if (contourWidget_ != NULL)
  1146. {
  1147. contourWidget_->SetRange(range_);
  1148. }
  1149. if (lineWidget_ != NULL)
  1150. {
  1151. lineWidget_->SetRange(range_);
  1152. }
  1153. }
  1154. /**
  1155. * @brief init widgets scalar name
  1156. *
  1157. * @param[in]
  1158. * @return
  1159. * @author zhaoyu
  1160. * @date 20221213
  1161. */
  1162. void ResultMeshManager::SetWidgetScalarName()
  1163. {
  1164. if (meshObj_ != NULL && (!scalarName_.empty()))
  1165. {
  1166. string name = scalarName_;
  1167. if (contourWidget_ != NULL)
  1168. {
  1169. contourWidget_->SetCurrScalar(name);
  1170. }
  1171. if (lineWidget_ != NULL)
  1172. {
  1173. lineWidget_->SetCurrScalar(name);
  1174. }
  1175. }
  1176. }
  1177. /**
  1178. * @brief set title size
  1179. *
  1180. * @param[in] int size
  1181. * @return
  1182. * @author zhaoyu
  1183. * @date 20221213
  1184. */
  1185. void ResultMeshManager::SetTitleSize(double size)
  1186. {
  1187. titleSize_ = size;
  1188. //SetWidgetTitleSize();
  1189. }
  1190. /**
  1191. * @brief init widget title size
  1192. *
  1193. * @param[in]
  1194. * @return
  1195. * @author zhaoyu
  1196. * @date 20221213
  1197. */
  1198. //void ResultMeshManager::SetWidgetTitleSize()
  1199. //{
  1200. // if (contourWidget_ != NULL)
  1201. // {
  1202. // contourWidget_->SetTitleFont(titleSize_);
  1203. // }
  1204. //}
  1205. /**
  1206. * @brief set label size
  1207. *
  1208. * @param[in] int label size
  1209. * @return
  1210. * @author zhaoyu
  1211. * @date 20221213
  1212. */
  1213. void ResultMeshManager::SetLabelSize(double size)
  1214. {
  1215. labelSize_ = size;
  1216. //SetWidgetLabelSize();
  1217. }
  1218. /**
  1219. * @brief set widget label size
  1220. *
  1221. * @param[in]
  1222. * @return
  1223. * @author zhaoyu
  1224. * @date 20221213
  1225. */
  1226. //void ResultMeshManager::SetWidgetLabelSize()
  1227. //{
  1228. // if (contourWidget_ != NULL)
  1229. // {
  1230. // contourWidget_->SetLabelFont(labelSize_);
  1231. // }
  1232. //}
  1233. /**
  1234. * @brief set level
  1235. *
  1236. * @param[in] int level
  1237. * @return
  1238. * @author zhaoyu
  1239. * @date 20221213
  1240. */
  1241. void ResultMeshManager::SetLevel(int level)
  1242. {
  1243. scalarLeave = level;
  1244. SetWidgetLevel();
  1245. }
  1246. /**
  1247. * @brief set widget level
  1248. *
  1249. * @param[in]
  1250. * @return
  1251. * @author zhaoyu
  1252. * @date 20221213
  1253. */
  1254. void ResultMeshManager::SetWidgetLevel()
  1255. {
  1256. if (contourWidget_ != NULL)
  1257. {
  1258. contourWidget_->SetLevel(scalarLeave);
  1259. }
  1260. if (lineWidget_ != NULL)
  1261. {
  1262. lineWidget_->SetLevel(scalarLeave);
  1263. }
  1264. }
  1265. /**
  1266. * @brief user set range
  1267. *
  1268. * @param[in]
  1269. * @return
  1270. * @author zhaoyu
  1271. * @date 20221214
  1272. */
  1273. void ResultMeshManager::SetRange(double* range)
  1274. {
  1275. range_[0] = range[0];
  1276. range_[1] = range[1];
  1277. changeRangeFlag = true;
  1278. }
  1279. /**
  1280. * @brief user set range
  1281. *
  1282. * @param[in] type 0 is contour
  1283. * type 2 is line
  1284. * @return
  1285. * @author zhaoyu
  1286. * @date 20221214
  1287. */
  1288. void ResultMeshManager::SetDisplayType(int type)
  1289. {
  1290. displayType = type;
  1291. }
  1292. /**
  1293. * @brief init contour widget and line widget parameter
  1294. *
  1295. * @param[in]
  1296. * @return
  1297. * @author zhaoyu
  1298. * @date 20230110
  1299. */
  1300. void ResultMeshManager::InitWidgetsParameter()
  1301. {
  1302. if (animationWidget_ != NULL)
  1303. {
  1304. animationWidget_->SetTypeEnable(HaveModalMeshFlag);
  1305. animationWidget_->SetSolveTime(GetSolveTime());
  1306. animationWidget_->SetZoneNameVector(zoneNameVec_);
  1307. }
  1308. if (contourWidget_ != NULL)
  1309. {
  1310. contourWidget_->SetNameTypeMap(GetNameTypeMap());
  1311. contourWidget_->SetScalarNameVec(GetMeshScalarNameVec());
  1312. SetWidgetRange();
  1313. SetWidgetScalarName();
  1314. }
  1315. if (lineWidget_ != NULL)
  1316. {
  1317. lineWidget_->SetNameTypeMap(GetNameTypeMap());
  1318. lineWidget_->SetScalarNameVec(GetMeshScalarNameVec());
  1319. SetWidgetRange();
  1320. SetWidgetScalarName();
  1321. }
  1322. if (vectorWidget_ != NULL)
  1323. {
  1324. vectorWidget_->GetData_u(GetMeshScalarNameVec());
  1325. vectorWidget_->GetData_v(GetMeshScalarNameVec());
  1326. vectorWidget_->GetData_w(GetMeshScalarNameVec());
  1327. vectorWidget_->SetScaleFactor(scaleFactor_);
  1328. }
  1329. if (sliceW_ != NULL)
  1330. {
  1331. sliceW_->GetScalarName(GetMeshScalarNameVec());
  1332. sliceW_->GetZoneId(GetShowZoneId());
  1333. }
  1334. if (streamW_ != NULL)
  1335. {
  1336. streamW_->SetData_u(GetMeshScalarNameVec());
  1337. streamW_->SetData_v(GetMeshScalarNameVec());
  1338. streamW_->SetData_w(GetMeshScalarNameVec());
  1339. }
  1340. // if (xyplot2dW_ != NULL)
  1341. // {
  1342. // xyplot2dW_->SetArea(zoneNameVec_);
  1343. // xyplot2dW_->SetYAxis(GetMeshScalarNameVec());
  1344. // }
  1345. }
  1346. /**
  1347. * @brief init contour widget and line widget parameter
  1348. *
  1349. * @param[in]
  1350. * @return
  1351. * @author zhaoyu
  1352. * @date 20221226
  1353. */
  1354. void ResultMeshManager::SetVectorScalarIndex(vector<int> indexVec)
  1355. {
  1356. vectorScalarIndexVec.clear();
  1357. if (indexVec.at(0) == -1 ||
  1358. indexVec.at(1) == -1 ||
  1359. indexVec.at(2) == -1)
  1360. {
  1361. return;
  1362. }else
  1363. {
  1364. vectorScalarIndexVec = indexVec;
  1365. DisplayMeshByIndex(m_currId);
  1366. }
  1367. }
  1368. /**
  1369. * @brief set scaleFactor
  1370. *
  1371. * @param[in]double factor
  1372. * @return
  1373. * @author zhaoyu
  1374. * @date 20230103
  1375. */
  1376. void ResultMeshManager::SetVectorScaleFactor(double factor)
  1377. {
  1378. scaleFactor_ = factor;
  1379. }
  1380. /**
  1381. * @brief set surface actor color
  1382. *
  1383. * @param[in]color
  1384. * @return
  1385. * @author zhaoyu
  1386. * @date 20230110
  1387. */
  1388. void ResultMeshManager::SetSurfaceColor(vector<double> color)
  1389. {
  1390. surfaceActorColor_ = color;
  1391. }
  1392. /**
  1393. * @brief set surface actor transparency
  1394. *
  1395. * @param[in]value
  1396. * @return
  1397. * @author zhaoyu
  1398. * @date 20230110
  1399. */
  1400. void ResultMeshManager::SetSurfaceTransparency(double value)
  1401. {
  1402. surfaceActorTransparency_ = value;
  1403. }
  1404. /**
  1405. * @brief set surface actor state
  1406. *
  1407. * @param[in]bool flag
  1408. * @return
  1409. * @author zhaoyu
  1410. * @date 20230110
  1411. */
  1412. void ResultMeshManager::SetSurfaceShowHideFlag(bool flag)
  1413. {
  1414. surfaceHideFlag = flag;
  1415. }
  1416. /**
  1417. * @brief set scalar name
  1418. *
  1419. * @param[in]char* name
  1420. * @return
  1421. * @author zhaoyu
  1422. * @date 20230111
  1423. */
  1424. void ResultMeshManager::SetScalarName(string name)
  1425. {
  1426. scalarName_ = name;
  1427. }
  1428. vector<int> ResultMeshManager::GetShowZoneId()
  1429. {
  1430. vector<int> zoneId;
  1431. zoneId.clear();
  1432. set<string>::iterator it;
  1433. for (int i = 0; i < showHideVec_.size(); i ++)
  1434. {
  1435. if (showHideVec_.at(i))
  1436. {
  1437. zoneId.push_back(i);
  1438. }
  1439. }
  1440. return zoneId;
  1441. }
  1442. void ResultMeshManager::InitSliceWidget()
  1443. {
  1444. HideAllUnshadeMeshActors();
  1445. HideAllGlyphActors();
  1446. HideAllContourActors();
  1447. HideStreamActors();
  1448. HideXyplot2dSliceActors();
  1449. if (solidSurfaceW_ != NULL)
  1450. {
  1451. solidSurfaceW_->SetShowHideState(true);
  1452. }
  1453. }
  1454. /**
  1455. * @brief creat a vtkVISunstructuredGrid source that is added by all the show zone
  1456. *
  1457. * @param[in] time step
  1458. * @return
  1459. * @author zhaoyu
  1460. * @date 20230217
  1461. */
  1462. void ResultMeshManager::MakeVISUnStructGrid()
  1463. {
  1464. if (meshObj_ == 0) return;
  1465. int num = 0;
  1466. double time = 0.0;
  1467. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  1468. {
  1469. if (num == m_currId)
  1470. {
  1471. time = *it;
  1472. break;
  1473. }
  1474. num ++;
  1475. }
  1476. vector<vtkVISUnstructuredGridSource*> vec;
  1477. map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
  1478. if (it != vtkVisZoneMeshMap_.end())
  1479. {
  1480. for (map<string, vtkVISUnContour*>::iterator it2= it->second.begin();
  1481. it2 != it->second.end(); it2 ++)
  1482. {
  1483. if (currShowZoneNameSet_.count(it2->first))
  1484. {
  1485. vtkVISUnstructuredGridSource* unGrid = vtkVISUnstructuredGridSource::New();
  1486. unGrid = it2->second->GetDatSource();
  1487. vec.push_back(unGrid);
  1488. }
  1489. }
  1490. /*if (addDataSource_ != NULL)
  1491. {
  1492. //delete addDataSource_;
  1493. addDataSource_ = NULL;
  1494. }*/
  1495. addDataSource_ = new vtkVISAddUnGridDataSource();
  1496. addDataSource_->SetVISUnGridDataSource(vec);
  1497. currentVISGridVec_.push_back(addDataSource_);
  1498. }
  1499. }
  1500. /**
  1501. * @brief get unslice position
  1502. *
  1503. * @param[in] unslice id
  1504. * @return
  1505. * @author zhaoyu
  1506. * @date 20230221
  1507. */
  1508. vector<double> ResultMeshManager::GetUnslicePosition(int index)
  1509. {
  1510. double* data2;
  1511. data2 = unSliceVec_.at(index)->GetSlicePlaneOrigin();
  1512. vector<double> origin;
  1513. origin.push_back(data2[0]);
  1514. origin.push_back(data2[1]);
  1515. origin.push_back(data2[2]);
  1516. return origin;
  1517. }
  1518. /**
  1519. * @brief get unslice source bounds
  1520. *
  1521. * @param[in] unslice id
  1522. * @return
  1523. * @author zhaoyu
  1524. * @date 20230221
  1525. */
  1526. vector<double> ResultMeshManager::GetUnsliceSourceBounds(int index)
  1527. {
  1528. vector<double> bounds;
  1529. if (unSliceVec_.at(index) != NULL)
  1530. {
  1531. double b[6];
  1532. unSliceVec_.at(index)->GetSourceBounds_FD(b);
  1533. for (int i = 0; i < 6; i ++)
  1534. {
  1535. bounds.push_back(b[i]);
  1536. }
  1537. }
  1538. return bounds;
  1539. }
  1540. /**
  1541. * @brief display a vtkVISUnstructGrid
  1542. *
  1543. * @param[in]
  1544. * @return
  1545. * @author zhaoyu
  1546. * @date 20230221
  1547. */
  1548. void ResultMeshManager::DisplayUnstructGrid()
  1549. {
  1550. if (render_ == NULL)
  1551. {
  1552. return;
  1553. }
  1554. vtkVISUnSlice* unSlice_ = vtkVISUnSlice::New();
  1555. unSlice_->SetRenderTo(render_->GetRenderer());
  1556. string name = GetMeshScalarNameVec().at(0);
  1557. unSlice_->SetDataSource(addDataSource_->GetSource());
  1558. char* s = (char*)(name.c_str());
  1559. char* v = NULL;
  1560. unSlice_->SetSliceSource_FD(s, v);
  1561. unSlice_->CreatUnShadeMeshDisplay();
  1562. unSlice_->CreateSliceWidget_FD();
  1563. unSlice_->CreateUnSliceContourDisplay_FD();
  1564. unSlice_->CreateUnSliceContourLinesDisplay_FD();
  1565. unSlice_->ShowOffUnSliceContourLinesDisplay();
  1566. unSlice_->CreateUnSliceContourLinesLabelDisplay_FD();
  1567. unSlice_->ShowOffUnSliceContourLinesLabelDisplay();
  1568. unSliceVec_.push_back(unSlice_);
  1569. render_->Update();
  1570. }
  1571. /**
  1572. * @brief hide all slice actors in the renderer
  1573. *
  1574. * @param[in]
  1575. * @return
  1576. * @author zhaoyu
  1577. * @date 20230225
  1578. */
  1579. void ResultMeshManager::HideSliceActors()
  1580. {
  1581. if (!unSliceVec_.empty())
  1582. {
  1583. for (int i = 0; i < unSliceVec_.size(); i ++)
  1584. {
  1585. if (unSliceVec_.at(i) != NULL)
  1586. {
  1587. unSliceVec_.at(i)->ShowOffSlicePlane();
  1588. unSliceVec_.at(i)->ShowOffSlicePlaneWidget();
  1589. unSliceVec_.at(i)->ShowOffUnShadeMesh();
  1590. unSliceVec_.at(i)->ShowOffUnSliceMesh();
  1591. unSliceVec_.at(i)->ShowOffUnSliceShade();
  1592. unSliceVec_.at(i)->ShowOffCutActor();
  1593. }
  1594. }
  1595. }
  1596. }
  1597. /**
  1598. * @brief set slice state
  1599. *
  1600. * @param[in] all sliceWidget parameter
  1601. * @return
  1602. * @author zhaoyu
  1603. * @date 20230225
  1604. */
  1605. void ResultMeshManager::SetAllSliceState(vector<int> sliceId, vector<bool> solidState, vector<bool> planeWidgetState, vector<vector<double>> nomal,
  1606. vector<vector<double>> posision, vector<string> type, vector<string> contourName, vector<int> level,
  1607. vector<bool> planeState, vector<bool>labelState)
  1608. {
  1609. for (int i = 0; i < sliceId.size(); i ++)
  1610. {
  1611. if (solidState.at(i))
  1612. {
  1613. unSliceVec_.at(sliceId.at(i))->ShowOnUnshadeMesh();
  1614. }else
  1615. {
  1616. unSliceVec_.at(sliceId.at(i))->ShowOffUnShadeMesh();
  1617. }
  1618. if (planeWidgetState.at(i))
  1619. {
  1620. unSliceVec_.at(sliceId.at(i))->ShowOnSlicePlane();
  1621. unSliceVec_.at(sliceId.at(i))->ShowOnSlicePlaneWidget();
  1622. }else
  1623. {
  1624. unSliceVec_.at(sliceId.at(i))->ShowOffSlicePlane();
  1625. unSliceVec_.at(sliceId.at(i))->ShowOffSlicePlaneWidget();
  1626. }
  1627. unSliceVec_.at(sliceId.at(i))->SetSlicePlaneNormal(nomal.at(i).at(0), nomal.at(i).at(1),nomal.at(i).at(2));
  1628. unSliceVec_.at(sliceId.at(i))->SetSlicePlaneOrigin(posision.at(i).at(0), posision.at(i).at(1),posision.at(i).at(2));
  1629. if (type.at(i) == "contour")
  1630. {
  1631. unSliceVec_.at(sliceId.at(i))->ShowOnUnSliceContourDisplay();
  1632. unSliceVec_.at(sliceId.at(i))->ShowOffUnSliceContourLinesDisplay();
  1633. }else if(type.at(i) == "line")
  1634. {
  1635. unSliceVec_.at(sliceId.at(i))->ShowOnUnSliceContourLinesDisplay();
  1636. unSliceVec_.at(sliceId.at(i))->ShowOffUnSliceContourDisplay();
  1637. }
  1638. char* name = (char*)(contourName.at(i).c_str());
  1639. unSliceVec_.at(sliceId.at(i))->ModifySliceSourceScalar_FD(name);
  1640. unSliceVec_.at(sliceId.at(i))->ModifyUnSliceContourLevel(level.at(i));
  1641. if (planeState.at(i))
  1642. {
  1643. //unSliceVec_.at(sliceId.at(i))->ShowOnSlicePlane();
  1644. }else
  1645. {
  1646. unSliceVec_.at(sliceId.at(i))->ShowOffCutActor();
  1647. }
  1648. if (labelState.at(i))
  1649. {
  1650. unSliceVec_.at(sliceId.at(i))->ShowOnUnSliceContourLinesLabelDisplay();
  1651. }else
  1652. {
  1653. unSliceVec_.at(sliceId.at(i))->ShowOffUnSliceContourLinesLabelDisplay();
  1654. }
  1655. }
  1656. for (int i = 0; i < unSliceVec_.size(); i ++)
  1657. {
  1658. if (find(sliceId.begin(), sliceId.end(), i) == sliceId.end())
  1659. {
  1660. if (unSliceVec_.at(i) != NULL)
  1661. {
  1662. unSliceVec_.at(i)->ShowOffSlicePlane();
  1663. unSliceVec_.at(i)->ShowOffSlicePlaneWidget();
  1664. unSliceVec_.at(i)->ShowOffUnShadeMesh();
  1665. unSliceVec_.at(i)->ShowOffUnSliceMesh();
  1666. unSliceVec_.at(i)->ShowOffUnSliceShade();
  1667. unSliceVec_.at(i)->ShowOffCutActor();
  1668. unSliceVec_.at(i)->Delete();
  1669. unSliceVec_.at(i) = NULL;
  1670. }
  1671. }
  1672. }
  1673. render_->Update();
  1674. }
  1675. /**
  1676. * @brief updata slice widget parameter
  1677. *
  1678. * @param[in]
  1679. * @return
  1680. * @author zhaoyu
  1681. * @date 20230301
  1682. */
  1683. void ResultMeshManager::UpdataSliceWidgetParameter()
  1684. {
  1685. if (sliceW_ == NULL)
  1686. {
  1687. return;
  1688. }
  1689. vector<int> sliceWId = sliceW_->GetSliceId();
  1690. vector<vector<double>> normalVec;
  1691. vector<vector<double>> originVec;
  1692. for (int i = 0; i < sliceWId.size(); i ++)
  1693. {
  1694. double *data;
  1695. data = unSliceVec_.at(sliceWId.at(i))->GetSlicePlaneNormal();
  1696. vector<double> normal;
  1697. normal.push_back(data[0]);
  1698. normal.push_back(data[1]);
  1699. normal.push_back(data[2]);
  1700. normalVec.push_back(normal);
  1701. double *data2;
  1702. data2 = unSliceVec_.at(sliceWId.at(i))->GetSlicePlaneOrigin();
  1703. vector<double> origin;
  1704. origin.push_back(data2[0]);
  1705. origin.push_back(data2[1]);
  1706. origin.push_back(data2[2]);
  1707. originVec.push_back(origin);
  1708. }
  1709. sliceW_->normal.clear();
  1710. sliceW_->position.clear();
  1711. sliceW_->normal = normalVec;
  1712. sliceW_->position = originVec;
  1713. }
  1714. /**
  1715. * @brief updata the source consisting of all current grids
  1716. *
  1717. * @param[in]
  1718. * @return
  1719. * @author zhaoyu
  1720. * @date 20230306
  1721. */
  1722. void ResultMeshManager::UpdataCurrUnstructSource()
  1723. {
  1724. double time = 0.0;
  1725. int num = 0;
  1726. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  1727. {
  1728. if (num == m_currId)
  1729. {
  1730. time = *it;
  1731. break;
  1732. }
  1733. num ++;
  1734. }
  1735. vector<vtkVISUnstructuredGridSource*> vec;
  1736. map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
  1737. if (it != vtkVisZoneMeshMap_.end())
  1738. {
  1739. for (map<string, vtkVISUnContour*>::iterator it2= it->second.begin();
  1740. it2 != it->second.end(); it2 ++)
  1741. {
  1742. if (currShowZoneNameSet_.count(it2->first))
  1743. {
  1744. vtkVISUnstructuredGridSource* unGrid = vtkVISUnstructuredGridSource::New();
  1745. unGrid = it2->second->GetDatSource();
  1746. vec.push_back(unGrid);
  1747. }
  1748. }
  1749. if (currAddDataSource_ != NULL)
  1750. {
  1751. delete currAddDataSource_;
  1752. currAddDataSource_ = NULL;
  1753. }
  1754. currAddDataSource_ = new vtkVISAddUnGridDataSource();
  1755. currAddDataSource_->SetVISUnGridDataSource(vec);
  1756. }
  1757. }
  1758. /**
  1759. * @brief creat a vector from the scalar name passed in
  1760. *
  1761. * @param[in] three scalar names
  1762. * @return
  1763. * @author zhaoyu
  1764. * @date 20230302
  1765. */
  1766. void ResultMeshManager::CreatVectorSource(string u, string v, string w)
  1767. {
  1768. UpdataCurrUnstructSource();
  1769. char* v1 = (char*)(u.c_str());
  1770. char* v2 = (char*)(v.c_str());
  1771. char* v3 = (char*)(w.c_str());
  1772. if (streamLine_ != NULL)
  1773. {
  1774. streamLine_->ShowOffStreamWidget();
  1775. streamLine_->ShowOffStreamTraceLines();
  1776. streamLine_->Delete();
  1777. streamLine_ = NULL;
  1778. }
  1779. if (currAddDataSource_ != NULL)
  1780. {
  1781. streamLine_ = vtkVISUnStreamTrace::New();
  1782. streamLine_->SetRenderTo(render_->GetRenderer());
  1783. streamLine_->SetDataSource(currAddDataSource_->GetSource());
  1784. streamLine_->SetStreamTraceSource(v1,v2,v3);
  1785. string type = "line";
  1786. streamLine_->SetSeedsType(type);
  1787. streamLine_->CreateStreamTraceDisplayByVector();
  1788. if (streamW_ != NULL)
  1789. {
  1790. streamW_->SetInitStepData(streamLine_->GetInitialStep());
  1791. streamW_->SetMaxPropgationData(streamLine_->GetMaxPropagation());
  1792. streamW_->SetMinStepData(streamLine_->GetMinimumStep());
  1793. }
  1794. }
  1795. //create_streamTrace(x,y,z);
  1796. }
  1797. /**
  1798. * @brief display stream line
  1799. *
  1800. * @param[in]
  1801. * @return
  1802. * @author zhaoyu
  1803. * @date 20230302
  1804. */
  1805. void ResultMeshManager::DisplayStreamLine(string direction, string type,
  1806. double initStrp, double maxPropgation, double minStep, bool showState, bool ToolState)
  1807. {
  1808. if (streamLine_ != NULL)
  1809. {
  1810. char* direc = (char*)(direction.c_str());
  1811. streamLine_->ModifyIntegraDirection(direc);
  1812. //type
  1813. streamLine_->ShowOffStreamTraceLines();
  1814. char* streamType = (char*)type.c_str();
  1815. streamLine_->ModifyStreamStyle(streamType);
  1816. streamLine_->ModifyInitialStep(initStrp);
  1817. streamLine_->ModifyMaxPropagation(maxPropgation);
  1818. streamLine_->ModifyMinimumStep(minStep);
  1819. if (showState)
  1820. {
  1821. streamLine_->ShowOnStreamTraceLines();
  1822. }else
  1823. {
  1824. streamLine_->ShowOffStreamTraceLines();
  1825. }
  1826. if (ToolState)
  1827. {
  1828. streamLine_->ShowOnStreamWidget();
  1829. }else
  1830. {
  1831. streamLine_->ShowOffStreamWidget();
  1832. }
  1833. }
  1834. render_->Update();
  1835. }
  1836. /**
  1837. * @brief set select state, true is On, false is OFF
  1838. *
  1839. * @param[in]
  1840. * @return
  1841. * @author zhaoyu
  1842. * @date 20230310
  1843. */
  1844. void ResultMeshManager::SetStreamSelectState(bool flag)
  1845. {
  1846. if (streamLine_ == NULL)
  1847. return;
  1848. if (flag)
  1849. {
  1850. streamLine_->vtkSelectPointOn();
  1851. }else
  1852. {
  1853. streamLine_->vtkSelectPointOff();
  1854. }
  1855. }
  1856. /**
  1857. * @brief delete all Stream
  1858. *
  1859. * @param[in]
  1860. * @return
  1861. * @author zhaoyu
  1862. * @date 20230310
  1863. */
  1864. void ResultMeshManager::DeleteAllStream()
  1865. {
  1866. if (streamLine_ != NULL)
  1867. {
  1868. streamLine_->ShowOffStreamWidget();
  1869. streamLine_->ShowOffStreamTraceLines();
  1870. streamLine_->vtkSelectPointOff();
  1871. render_->Update();
  1872. streamLine_->Delete();
  1873. streamLine_ = NULL;
  1874. }
  1875. }
  1876. /**
  1877. * @brief export the current render picture
  1878. *
  1879. * @param[in]
  1880. * @return
  1881. * @author hejingjing
  1882. * @date 20230315
  1883. */
  1884. //void ResultMeshManager::GetExportPictures(QString file)
  1885. //{
  1886. // QFileInfo info(file);
  1887. // if (render_!= NULL && (render_->GetRenderer()->VisibleActorCount() > 0))
  1888. // {
  1889. // captureF = vtkVISCaptureFigure::New();
  1890. // captureF->SetCaptureFigureSource(render_->GetRenderer());
  1891. // QString extType = info.suffix();
  1892. // qDebug() << extType;
  1893. // string st = file.toStdString();
  1894. // char *str = (char*)st.c_str();//qstring转char
  1895. // if(extType.contains( "JPEG" ))
  1896. // {
  1897. // captureF->CaptureRenderFigureAsJPEG(str);
  1898. // }
  1899. // else if(extType.contains("BMP"))
  1900. // {
  1901. // captureF->CaptureRenderFigureAsBMP(str);
  1902. // }
  1903. // else if(extType.contains("PNG"))
  1904. // {
  1905. // captureF->CaptureRenderFigureAsPNG(str);
  1906. // }
  1907. // else if(extType.contains("TIFF"))
  1908. // {
  1909. // captureF->CaptureRenderFigureAsTIFF(str);
  1910. // }
  1911. // else if(extType.contains("PNM"))
  1912. // {
  1913. // captureF->CaptureRenderFigureAsPNM(str);
  1914. // }
  1915. // }
  1916. //}
  1917. /**
  1918. * @brief hide streamLine and lineWidget
  1919. *
  1920. * @param[in]
  1921. * @return
  1922. * @author zhaoyu
  1923. * @date 20230320
  1924. *
  1925. * */
  1926. void ResultMeshManager::HideStreamActors()
  1927. {
  1928. DeleteAllStream();
  1929. }
  1930. //void ResultMeshManager::SetTextWidget(TextWidget *w)
  1931. //{
  1932. // textW_ = w;
  1933. //}
  1934. /**
  1935. * @brief set textwidget state
  1936. *
  1937. * @param[in] all textwidget parameter
  1938. * @return
  1939. * @author hejingjing
  1940. * @date 20230321
  1941. */
  1942. void ResultMeshManager::GetActorText(string text_, vector<double> position_XY, double fontsize,vector<double> color)
  1943. {
  1944. if(titleText_ != NULL)
  1945. {
  1946. titleText_->SetVisibility(false);
  1947. titleText_->Delete();
  1948. }
  1949. titleText_ = vtkTextActor::New();
  1950. if(!text_.empty())
  1951. {
  1952. const char *TitleText = text_.c_str();
  1953. titleText_->SetInput(TitleText);
  1954. titleText_->SetDisplayPosition(position_XY.at(0),position_XY.at(1));
  1955. titleText_->GetTextProperty()->SetFontSize(fontsize);
  1956. titleText_->GetTextProperty()->SetColor(color.at(0),color.at(1),color.at(2));
  1957. render_->GetRenderer()->AddActor2D(titleText_);
  1958. render_->Update();
  1959. }
  1960. }
  1961. /**
  1962. * @brief update the scaled model
  1963. *
  1964. * @param[in] double scaled factor
  1965. * @return
  1966. * @author zhaoyu
  1967. * @date 20230406
  1968. */
  1969. void ResultMeshManager::UpdataZoomModel(double factor)
  1970. {
  1971. if (initPointsData == NULL)
  1972. return;
  1973. if (dispNameVec.size() == 0)
  1974. return;
  1975. if (MeshVec_.size() == 0)
  1976. return;
  1977. ///creat old data
  1978. for(map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.begin(); it != vtkVisZoneMeshMap_.end(); ++it)
  1979. {
  1980. for(map<string, vtkVISUnContour*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  1981. {
  1982. itin->second->Delete();
  1983. }
  1984. it->second.clear();
  1985. }
  1986. vtkVisZoneMeshMap_.clear();
  1987. for(map<double, map<string, vtkVISUnShadeMesh*>>::iterator it = vtkVisZoneUnShadeMeshMap_.begin(); it != vtkVisZoneUnShadeMeshMap_.end(); ++it)
  1988. {
  1989. for(map<string, vtkVISUnShadeMesh*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  1990. {
  1991. itin->second->Delete();
  1992. }
  1993. it->second.clear();
  1994. }
  1995. vtkVisZoneUnShadeMeshMap_.clear();
  1996. for(map<double, map<string, vtkVISUnGlyph*>>::iterator it = vtkVisZoneGlyphMap_.begin(); it != vtkVisZoneGlyphMap_.end(); ++it)
  1997. {
  1998. for(map<string, vtkVISUnGlyph*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  1999. {
  2000. itin->second->Delete();
  2001. }
  2002. it->second.clear();
  2003. }
  2004. vtkVisZoneGlyphMap_.clear();
  2005. for (int i = 0; i < MeshVec_.size(); i ++)
  2006. {
  2007. for (int j = 0; j < MeshVec_.at(i)->GetZoneNumber(); j ++)
  2008. {
  2009. double* X;
  2010. double* Y;
  2011. double* Z;
  2012. PointsDS* p = new PointsDS;
  2013. p->SetPointNumber(initPointsData->GetPointNumber());
  2014. for (int k = 0; k < MeshVec_.at(i)->GetScalarName().size(); k ++)
  2015. {
  2016. if (MeshVec_.at(i)->GetScalarName().at(k) == dispNameVec.at(0))
  2017. {
  2018. X = MeshVec_.at(i)->GetScalarData().at(j).at(k + 3);
  2019. }else if (MeshVec_.at(i)->GetScalarName().at(k) == dispNameVec.at(1))
  2020. {
  2021. Y = MeshVec_.at(i)->GetScalarData().at(j).at(k + 3);
  2022. }else if (MeshVec_.at(i)->GetScalarName().at(k) == dispNameVec.at(2))
  2023. {
  2024. Z = MeshVec_.at(i)->GetScalarData().at(j).at(k + 3);
  2025. }
  2026. }
  2027. for (int k = 0; k < initPointsData->GetPointNumber(); k ++)
  2028. {
  2029. double xyz[3];
  2030. initPointsData->GetPoint(k, xyz);
  2031. double x = xyz[0] + (factor*X[k]);
  2032. double y = xyz[1] + (factor*Y[k]);
  2033. double z = xyz[2] + (factor*Z[k]);
  2034. p->SetPoint(k, x, y, z);
  2035. }
  2036. MeshVec_.at(i)->GetZoneMesh(j)->SetPoints(p);
  2037. }
  2038. }
  2039. DisplayMesh(render_);
  2040. HideAllActors();
  2041. DisplayMeshByIndex(0);
  2042. animationWidget_->SlotStart();
  2043. render_->ZoomToExtents();
  2044. }
  2045. /**
  2046. * @brief refill mesh vector by type
  2047. *
  2048. * @param[in] int type, 0 is time step, 1 is modal step
  2049. * @return
  2050. * @author zhaoyu
  2051. * @date 20230410
  2052. */
  2053. void ResultMeshManager::ChangeMeshType(int type)
  2054. {
  2055. if (meshType != type)
  2056. {
  2057. meshType = type;
  2058. if (meshObj_)
  2059. {
  2060. //delete meshObj_;
  2061. meshObj_ = NULL;
  2062. }
  2063. m_currId = -1;
  2064. scalarIndex = -1;
  2065. range_[0] = 0;
  2066. range_[1] = 0;
  2067. scalarLeave = 10;
  2068. titleSize_ = 6;
  2069. labelSize_ = 5;
  2070. changeRangeFlag = false;
  2071. surfaceHideFlag = true;
  2072. displayType = -1;
  2073. scaleFactor_ = 0.02;
  2074. solveTimes_.clear();
  2075. zoneNameVec_.clear();
  2076. currShowZoneNameSet_.clear();
  2077. nameTypeMap_.clear();
  2078. showHideVec_.clear();
  2079. surfaceActorColor_.clear();
  2080. scalarName_.clear();
  2081. allZoneScalarName_.clear();
  2082. //vtk vis procs.
  2083. for(map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.begin(); it != vtkVisZoneMeshMap_.end(); ++it)
  2084. {
  2085. for(map<string, vtkVISUnContour*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  2086. {
  2087. itin->second->Delete();
  2088. }
  2089. it->second.clear();
  2090. }
  2091. vtkVisZoneMeshMap_.clear();
  2092. for(map<double, map<string, vtkVISUnShadeMesh*>>::iterator it = vtkVisZoneUnShadeMeshMap_.begin(); it != vtkVisZoneUnShadeMeshMap_.end(); ++it)
  2093. {
  2094. for(map<string, vtkVISUnShadeMesh*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  2095. {
  2096. itin->second->Delete();
  2097. }
  2098. it->second.clear();
  2099. }
  2100. vtkVisZoneUnShadeMeshMap_.clear();
  2101. for(map<double, map<string, vtkVISUnGlyph*>>::iterator it = vtkVisZoneGlyphMap_.begin(); it != vtkVisZoneGlyphMap_.end(); ++it)
  2102. {
  2103. for(map<string, vtkVISUnGlyph*>::iterator itin = it->second.begin(); itin != it->second.end(); ++itin)
  2104. {
  2105. itin->second->Delete();
  2106. }
  2107. it->second.clear();
  2108. }
  2109. vtkVisZoneGlyphMap_.clear();
  2110. if (!unSliceVec_.empty())
  2111. {
  2112. for (int i = 0; i < unSliceVec_.size(); i ++)
  2113. {
  2114. if(unSliceVec_.at(i) != NULL)
  2115. {
  2116. unSliceVec_.at(i)->Delete();
  2117. unSliceVec_.at(i) = NULL;
  2118. }
  2119. }
  2120. unSliceVec_.clear();
  2121. }
  2122. if (addDataSource_ != NULL)
  2123. {
  2124. delete addDataSource_;
  2125. addDataSource_ = NULL;
  2126. }
  2127. if (currAddDataSource_ != NULL)
  2128. {
  2129. delete currAddDataSource_;
  2130. currAddDataSource_ = NULL;
  2131. }
  2132. DeleteAllStream();
  2133. if (streamLine_ != NULL)
  2134. {
  2135. streamLine_->Delete();
  2136. streamLine_ = NULL;
  2137. }
  2138. if (xyplot2dSlice_ != NULL)
  2139. {
  2140. xyplot2dSlice_->Delete();
  2141. xyplot2dSlice_ = NULL;
  2142. }
  2143. surfaceActorColor_.push_back(0);
  2144. surfaceActorColor_.push_back(0);
  2145. surfaceActorColor_.push_back(1);
  2146. surfaceActorTransparency_ = 1;
  2147. // if (contourWidget_ != NULL)
  2148. // {
  2149. // contourWidget_->RestoreWidget();
  2150. // }
  2151. // if (lineWidget_ != NULL)
  2152. // {
  2153. // lineWidget_->RestoreWidget();
  2154. // }
  2155. // if (vectorWidget_ != NULL)
  2156. // {
  2157. // vectorWidget_->RestoreWidget();
  2158. // }
  2159. // if (solidSurfaceW_ != NULL)
  2160. // {
  2161. // solidSurfaceW_->RestoreWidget();
  2162. // }
  2163. // if (sliceW_ != NULL)
  2164. // {
  2165. // sliceW_->RestoreWidget();
  2166. // }
  2167. // if (streamW_ != NULL)
  2168. // {
  2169. // streamW_->RestoreWidget();
  2170. // }
  2171. // if (xyplot2dW_ != NULL)
  2172. // {
  2173. // xyplot2dW_->RestoreWidget();
  2174. // }
  2175. render_->HideAllActors();
  2176. if (type == 0)
  2177. {
  2178. MeshVec_ = TimeMeshVec_;
  2179. DisplayMesh(render_);
  2180. HideAllActors();
  2181. ShowAll();
  2182. DisplayMeshByIndex(0);
  2183. SetNameTypeMap();
  2184. InitWidgetsParameter();
  2185. animationWidget_->SlotStart();
  2186. animationWidget_->InitScaleFactor();
  2187. render_->ZoomToExtents();
  2188. }else if (type == 1)
  2189. {
  2190. MeshVec_ = ModalMeshVec_;
  2191. DisplayMesh(render_);
  2192. HideAllActors();
  2193. ShowAll();
  2194. DisplayMeshByIndex(0);
  2195. SetNameTypeMap();
  2196. InitWidgetsParameter();
  2197. animationWidget_->SlotStart();
  2198. animationWidget_->InitScaleFactor();
  2199. render_->ZoomToExtents();
  2200. }
  2201. }
  2202. }
  2203. /**
  2204. * @brief display select zone to slice
  2205. *
  2206. * @param[in] int meshindex, int scalarindex, int normalIndex
  2207. * @return
  2208. * @author zhaoyu
  2209. * @date 20230411
  2210. */
  2211. void ResultMeshManager::DisplayXyplot2dSlice(int meshIndex, int sIndex)
  2212. {
  2213. if (render_ == NULL)
  2214. {
  2215. return;
  2216. }
  2217. if (xyplot2dSlice_ != NULL)
  2218. {
  2219. xyplot2dSlice_->Delete();
  2220. xyplot2dSlice_ = NULL;
  2221. }
  2222. if (meshObj_ == 0) return;
  2223. int num = 0;
  2224. double time = 0.0;
  2225. for(set<double>::iterator it = solveTimes_.begin(); it != solveTimes_.end(); it ++)
  2226. {
  2227. if (num == m_currId)
  2228. {
  2229. time = *it;
  2230. break;
  2231. }
  2232. num ++;
  2233. }
  2234. vtkVISUnstructuredGridSource* source = NULL;
  2235. map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
  2236. if (it != vtkVisZoneMeshMap_.end())
  2237. {
  2238. map<string, vtkVISUnContour*>::iterator it2= it->second.find(zoneNameVec_.at(meshIndex));
  2239. if (it2 != it->second.end())
  2240. {
  2241. source = it2->second->GetDatSource();
  2242. }
  2243. }
  2244. if (source == NULL)
  2245. {
  2246. cout << "source data error" << endl;
  2247. return;
  2248. }
  2249. vtkVISUnSlice* unSlice_ = vtkVISUnSlice::New();
  2250. unSlice_->SetRenderTo(render_->GetRenderer());
  2251. string name = GetMeshScalarNameVec().at(sIndex);
  2252. unSlice_->SetDataSource(source);
  2253. char* s = (char*)(name.c_str());
  2254. char* v = NULL;
  2255. unSlice_->SetSliceSource_FD(s, v);
  2256. unSlice_->CreatUnShadeMeshDisplay();
  2257. unSlice_->CreateSliceWidget_FD();
  2258. unSlice_->CreateUnSliceContourDisplay_FD();
  2259. unSlice_->CreateUnSliceContourLinesDisplay_FD();
  2260. unSlice_->ShowOffUnSliceContourLinesDisplay();
  2261. unSlice_->CreateUnSliceContourLinesLabelDisplay_FD();
  2262. unSlice_->ShowOffUnSliceContourLinesLabelDisplay();
  2263. xyplot2dSlice_ = unSlice_;
  2264. render_->ZoomToExtents();
  2265. }
  2266. /**
  2267. * @brief get xyplot 2d unslice position
  2268. *
  2269. * @param[in]
  2270. * @return
  2271. * @author zhaoyu
  2272. * @date 20230411
  2273. */
  2274. vector<double> ResultMeshManager::GetXyplot2dUnslicePosition()
  2275. {
  2276. double* data2;
  2277. vector<double> origin;
  2278. if (xyplot2dSlice_ != NULL)
  2279. {
  2280. data2 = xyplot2dSlice_->GetSlicePlaneOrigin();
  2281. origin.push_back(data2[0]);
  2282. origin.push_back(data2[1]);
  2283. origin.push_back(data2[2]);
  2284. }else
  2285. {
  2286. origin.push_back(0);
  2287. origin.push_back(0);
  2288. origin.push_back(0);
  2289. }
  2290. return origin;
  2291. }
  2292. /**
  2293. * @brief set xyplot 2d unslice normal
  2294. *
  2295. * @param[in] int normal index
  2296. * @return
  2297. * @author zhaoyu
  2298. * @date 20230411
  2299. */
  2300. void ResultMeshManager::SetXyplot2dSliceNormal(int normalIndex)
  2301. {
  2302. if (xyplot2dSlice_ != NULL)
  2303. {
  2304. if (normalIndex == 0)
  2305. {
  2306. xyplot2dSlice_->SetSlicePlaneNormalToX();
  2307. }else if (normalIndex == 1)
  2308. {
  2309. xyplot2dSlice_->SetSlicePlaneNormalToY();
  2310. }else if (normalIndex == 2)
  2311. {
  2312. xyplot2dSlice_->SetSlicePlaneNormalToZ();
  2313. }
  2314. }
  2315. render_->Update();
  2316. }
  2317. /**
  2318. * @brief set xyplot 2d unslice scalar index
  2319. *
  2320. * @param[in] int scalar index
  2321. * @return
  2322. * @author zhaoyu
  2323. * @date 20230411
  2324. */
  2325. void ResultMeshManager::SetXyplot2dSliceScalarIndex(int index)
  2326. {
  2327. if (xyplot2dSlice_ != NULL)
  2328. {
  2329. string name = GetMeshScalarNameVec().at(index);
  2330. char* s = (char*)(name.c_str());
  2331. xyplot2dSlice_->ModifySliceSourceScalar_FD(s);
  2332. }
  2333. render_->Update();
  2334. }
  2335. /**
  2336. * @brief Hide xyplot 2d unslice
  2337. *
  2338. * @param[in]
  2339. * @return
  2340. * @author zhaoyu
  2341. * @date 20230411
  2342. */
  2343. void ResultMeshManager::HideXyplot2dSliceActors()
  2344. {
  2345. if (xyplot2dSlice_ != NULL)
  2346. {
  2347. xyplot2dSlice_->ShowOffSlicePlane();
  2348. xyplot2dSlice_->ShowOffSlicePlaneWidget();
  2349. xyplot2dSlice_->ShowOffUnShadeMesh();
  2350. xyplot2dSlice_->ShowOffUnSliceMesh();
  2351. xyplot2dSlice_->ShowOffUnSliceShade();
  2352. xyplot2dSlice_->ShowOffCutActor();
  2353. }
  2354. }
  2355. void ResultMeshManager::GetExportPictures(QString file)
  2356. {
  2357. }
  2358. /**
  2359. * @brief set xyplot2d unslice position
  2360. *
  2361. * @param[in] vector<double> p
  2362. * @return
  2363. * @author zhaoyu
  2364. * @date 20230411
  2365. */
  2366. void ResultMeshManager::SetXyplot2dSlicePosition(vector<double> p)
  2367. {
  2368. if (xyplot2dSlice_ != NULL)
  2369. {
  2370. xyplot2dSlice_->SetSlicePlaneOrigin(p[0], p[1], p[2]);
  2371. }
  2372. render_->Update();
  2373. }
  2374. /*
  2375. * @brief: get private scalar name
  2376. * @param: void
  2377. * @ret: scalarName
  2378. * @birth: created by czm in 20230421
  2379. */
  2380. string ResultMeshManager::getScalarName()
  2381. {
  2382. return this->scalarName_;
  2383. }
  2384. /*
  2385. * @brief: get private range
  2386. * @param: void
  2387. * @ret: range
  2388. * @birth: created by czm in 20230421
  2389. */
  2390. double *ResultMeshManager::getRange()
  2391. {
  2392. return this->range_;
  2393. }
  2394. /*
  2395. * @brief: get private meshobj_
  2396. * @param: void
  2397. * @ret: meshobj_
  2398. * @birth: created by czm in 20230421
  2399. */
  2400. Mesh *ResultMeshManager::getMeshObj_()
  2401. {
  2402. return this->meshObj_;
  2403. }
  2404. void ResultMeshManager::create_streamTrace(double x, double y, double z)
  2405. {
  2406. if(streamLine_!=NULL){
  2407. streamLine_->SetStreamLineStartPosition(x,y,z);
  2408. streamLine_->CreateOneStreamLine();
  2409. }
  2410. }
  2411. /**
  2412. * @brief get xyplot2d unslice data
  2413. *
  2414. * @param[in]
  2415. * @return x1 value1 x2 value2
  2416. * @author zhaoyu
  2417. * @date 20230411
  2418. */
  2419. //vector<vector<double>> ResultMeshManager::GetXyplot2dUnsliceData()
  2420. //{
  2421. // vector<vector<double>> xyplot2dVec;
  2422. // string xName;
  2423. // string yName;
  2424. // yName = GetMeshScalarNameVec().at(xyplot2dW_->GetYName());
  2425. // vector<vector<double>> totalVector;
  2426. // totalVector.clear();
  2427. // if (xyplot2dSlice_ != NULL)
  2428. // {
  2429. // vector<vtkDoubleArray*> vec;
  2430. // vec = xyplot2dSlice_->GetSliceData();
  2431. // string xAxis = xyplot2dW_->GetXAxis();
  2432. // double range[2];
  2433. // double middle = 0;
  2434. // int normalIndex = xyplot2dW_->GetNormalIndex();
  2435. // int referenceIndex;
  2436. // vector<double> x1;
  2437. // vector<double> value1;
  2438. // vector<double> x2;
  2439. // vector<double> value2;
  2440. // if (xAxis == "X")
  2441. // {
  2442. // xName = "X";
  2443. // if (xyplot2dW_->GetNormalIndex() == 1)
  2444. // {
  2445. // vec.at(0)->GetRange(range, 2);
  2446. // referenceIndex = 2;
  2447. // middle = (range[0] + range[1])/2.0;
  2448. // }else if (xyplot2dW_->GetNormalIndex() == 2)
  2449. // {
  2450. // vec.at(0)->GetRange(range, 1);
  2451. // referenceIndex = 1;
  2452. // middle = (range[0] + range[1])/2.0;
  2453. // }
  2454. // for (int i = 0; i < vec.at(0)->GetNumberOfTuples(); i ++)
  2455. // {
  2456. // double reference = vec.at(0)->GetTuple(i)[referenceIndex];
  2457. // if (reference < middle || reference == middle)
  2458. // {
  2459. // x1.push_back(vec.at(0)->GetTuple(i)[0]);
  2460. // value1.push_back(vec.at(1)->GetValue(i));
  2461. // }else
  2462. // {
  2463. // x2.push_back(vec.at(0)->GetTuple(i)[0]);
  2464. // value2.push_back(vec.at(1)->GetValue(i));
  2465. // }
  2466. // }
  2467. // }else if (xAxis == "Y")
  2468. // {
  2469. // xName = "Y";
  2470. // if (xyplot2dW_->GetNormalIndex() == 0)
  2471. // {
  2472. // vec.at(0)->GetRange(range, 2);
  2473. // referenceIndex = 2;
  2474. // middle = (range[0] + range[1])/2.0;
  2475. // }else if (xyplot2dW_->GetNormalIndex() == 2)
  2476. // {
  2477. // vec.at(0)->GetRange(range, 0);
  2478. // referenceIndex = 0;
  2479. // middle = (range[0] + range[1])/2.0;
  2480. // }
  2481. // for (int i = 0; i < vec.at(0)->GetNumberOfTuples(); i ++)
  2482. // {
  2483. // double reference = vec.at(0)->GetTuple(i)[referenceIndex];
  2484. // if (reference < middle || reference == middle)
  2485. // {
  2486. // x1.push_back(vec.at(0)->GetTuple(i)[1]);
  2487. // value1.push_back(vec.at(1)->GetValue(i));
  2488. // }else
  2489. // {
  2490. // x2.push_back(vec.at(0)->GetTuple(i)[1]);
  2491. // value2.push_back(vec.at(1)->GetValue(i));
  2492. // }
  2493. // }
  2494. // }else if (xAxis == "Z")
  2495. // {
  2496. // xName = "Z";
  2497. // if (xyplot2dW_->GetNormalIndex() == 0)
  2498. // {
  2499. // vec.at(0)->GetRange(range, 1);
  2500. // referenceIndex = 1;
  2501. // middle = (range[0] + range[1])/2.0;
  2502. // }else if (xyplot2dW_->GetNormalIndex() == 1)
  2503. // {
  2504. // vec.at(0)->GetRange(range, 0);
  2505. // referenceIndex = 0;
  2506. // middle = (range[0] + range[1])/2.0;
  2507. // }
  2508. // for (int i = 0; i < vec.at(0)->GetNumberOfTuples(); i ++)
  2509. // {
  2510. // double reference = vec.at(0)->GetTuple(i)[referenceIndex];
  2511. // if (reference < middle || reference == middle)
  2512. // {
  2513. // x1.push_back(vec.at(0)->GetTuple(i)[2]);
  2514. // value1.push_back(vec.at(1)->GetValue(i));
  2515. // }else
  2516. // {
  2517. // x2.push_back(vec.at(0)->GetTuple(i)[2]);
  2518. // value2.push_back(vec.at(1)->GetValue(i));
  2519. // }
  2520. // }
  2521. // }
  2522. // totalVector.push_back(x1);
  2523. // totalVector.push_back(value1);
  2524. // totalVector.push_back(x2);
  2525. // totalVector.push_back(value2);
  2526. // }
  2527. // return totalVector;
  2528. //}
  2529. /**
  2530. * @brief get xyplot2d axis name
  2531. *
  2532. * @param[in]
  2533. * @return xName and yName
  2534. * @author zhaoyu
  2535. * @date 20230414
  2536. */
  2537. //vector<string> ResultMeshManager::GetXyplot2dAxisName()
  2538. //{
  2539. // vector<string> xyplotwdNameVec;
  2540. // xyplotwdNameVec.clear();
  2541. // string xAxis = "X";
  2542. // string yName = "Y";
  2543. // if (xyplot2dSlice_ != NULL)
  2544. // {
  2545. // xAxis = xyplot2dW_->GetXAxis();
  2546. // yName;
  2547. // yName = GetMeshScalarNameVec().at(xyplot2dW_->GetYName());
  2548. // }
  2549. // xyplotwdNameVec.push_back(xAxis);
  2550. // xyplotwdNameVec.push_back(yName);
  2551. // return xyplotwdNameVec;
  2552. //}
  2553. /**
  2554. * @brief get qvtkrenderer
  2555. *
  2556. * @param[in]
  2557. * @return QVTKRenderer *render_
  2558. * @author zhaoyu
  2559. * @date 20230417
  2560. */
  2561. QVTKRenderer *ResultMeshManager::GetQVtkRender()
  2562. {
  2563. return render_;
  2564. }
  2565. /*
  2566. * @brief: remove string's spaces
  2567. * @param: string
  2568. * @ret: string
  2569. * @birth: created by czm in 20230504
  2570. */
  2571. string ResultMeshManager::deleteSpaces(string str)
  2572. {
  2573. QChar h0 = 0x00;
  2574. QString str_;
  2575. if(QString::fromStdString(str).contains(h0)){
  2576. str_=QString::fromStdString(str).replace(h0,"");
  2577. }
  2578. return str_.toStdString();
  2579. }