ResultMeshManager.cpp 69 KB

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