1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219 |
- #include "stdafx.h"
- #include <QFile>
- #include <QTextStream>
- #include <QDateTime>
- #include <QProcess>
- #include <QDir>
- #include <qdebug.h>
- #include "cmdmainprocess.h"
- #include "dpmvolclass.h"
- #include "ga_api.hxx"
- #include "at_str.hxx"
- #include "at_int.hxx"
- // Global variables to control the demonstration of advanced meshing functionalities
- // 0 - skip; 1 - apply
- //int USE_LOCAL_PHYSICAL_SIZE = 0; // 3DPM-CadSurf
- //int APPLY_PERIODICITY = 0; // 3DPM-CadSurf
- //int USE_TETRA = 1; // 3DPM-Tetra
- //int USE_HEXA = 0; // 3DPM-Hexa
- int USE_LOCAL_PHYSICAL_SIZE = 0; // 3DPM-CadSurf,1:physical_size_mode,2:geometry_size_mode
- int APPLY_PERIODICITY = 0; // 3DPM-CadSurf
- int USE_TETRA = 0; // 3DPM-Tetra
- int USE_HEXA = 0; // 3DPM-Hexa
- int USE_HYBIRD = 0;//3DPM-Hybird
- extern void unlock_license();
- class DPMvolClass;
- cmdMainProcess::cmdMainProcess()
- {
- //init some parameter
- szmp_iso_face_t_ = nullptr;
- szmp_iso_edge_t_ = nullptr;
- szmp_iso_point_t_ = nullptr;
- SampleUtils_ = NULL;//new DPMvolClass();
- object = NULL;
- }
- cmdMainProcess::~cmdMainProcess()
- {
- if(object)
- object = NULL;
- }
- /**
- * @brief iniACIS
- * Start ACIS to generate data
- * @param[in]
- * @return
- * @author
- * @date
- * @reviser
- * @date
- */
- void cmdMainProcess::iniACIS()
- {
- unlock_license();
- exit_on_bad_outcome(api_start_modeller(0));//启动ACIS,生成内部数据结构
- exit_on_bad_outcome(api_initialize_3dpm_bridge());
- printf("Successful initialization\n");
- }
- /**
- * @brief closeACIS
- * Delete ACIS
- * @param[in]
- * @return
- * @author qiyan
- * @date 2022-11-16
- * @reviser
- * @date
- */
- void cmdMainProcess::closeACIS()
- {
- exit_on_bad_outcome(api_terminate_3dpm_bridge());
- exit_on_bad_outcome(api_stop_modeller());//删除内部数据结构
- }
- /*
- * @brief:set boostjsonobject into cmdmainprocess
- * @param:[in]object
- * @ret:void
- * @birth:created by czm in 20230831
- */
- void cmdMainProcess::setJsonObject(boostJsonObject *object)
- {
- this->object = object;
- }
- /**
- * @brief CreateProcess Geometry
- *
- * @param[in] geometry
- * @return
- * @author qiyan
- * @date 2023-04-24
- * @reviser
- * @date
- */
- bool cmdMainProcess::CreateProcess_(string pathGeo)
- {
- iniACIS();
- //1.--read cad surf parameter
- //Get ENTITY_LIST;
- ENTITY_LIST Whole_ents;
- ENTITY_LIST cells;
- ENTITY_LIST ent;
- int externGeo = 0;
- if (externGeo == 0) {
- GeometryImExporter* geo = new GeometryImExporter();
- geo->LoadGeometryFile(pathGeo);
- ENTITY_LIST readRowEnt = geo->GetEntities();
- printf("Read all entity body count is %d;\n", readRowEnt.count());
- for (ENTITY *entC = readRowEnt.first(); entC != 0; entC = readRowEnt.next())
- {
- if (is_BODY(entC)) ent.add(entC);
- printf("current body is %s;\n", (is_closed_solid_body(entC) ? "closed" : "not closed"));//判断是否闭合?
- }
- printf("\n Body's count is %d;", ent.count());
- //--获取边的信息
- ENTITY_LIST EdgeEnt = geo->GetEdges();
- const char *name = "entity_index";
- for (int kk = 0; kk<EdgeEnt.count(); kk++)
- {
- if (find_named_attrib(EdgeEnt[kk], name) == 0) {
- //printf("not find EdgeEnt name : %s\n", name);
- }
- else {
- //ATTRIB_GEN_STRING* pId = NULL;
- ATTRIB_GEN_INTEGER* pId = NULL;
- outcome result = api_find_named_attribute(EdgeEnt[kk], name, reinterpret_cast<ATTRIB_GEN_NAME*&>(pId));
- printf("find result : %d\n", result.ok());
- if (pId && (result.ok() == TRUE))
- {
- /* const char*name = pId->value();
- printf("find pId name : %s\n", name);*/
- int names = pId->value();
- printf("find EdgeEnt pId name : %d\n", names);
- }
- }
- }
- //--获取面信息
- ENTITY_LIST FaceEnt = geo->GetFaces();
- for (int kk = 0; kk < FaceEnt.count(); kk++)
- {
- if (find_named_attrib(FaceEnt[kk], name) == 0) {
- //printf("not find FaceEnt name : %s\n", name);
- }
- else {
- //ATTRIB_GEN_STRING* pId = NULL;
- ATTRIB_GEN_INTEGER* pId = NULL;
- outcome result = api_find_named_attribute(FaceEnt[kk], name, reinterpret_cast<ATTRIB_GEN_NAME*&>(pId));
- printf("find result : %d\n", result.ok());
- if (pId && (result.ok() == TRUE))
- {
- /* const char*name = pId->value();
- printf("find pId name : %s\n", name);*/
- int names = pId->value();
- printf("find FaceEnt pId name : %d\n", names);
- }
- }
- }
- exit_on_bad_outcome(api_n_body_unite(ent, false));
- printf("Whole_ents after unite is : %d\n", ent.count());
- for (int kk = 0; kk < ent.count(); kk++)
- {
- printf("kk%d is %d; ", kk, is_BODY(ent[kk]));
- }
- // Attach cellular topology to non-regular union (necessary for the Spa3dpm::Cell_VolumeElem_Assoc class below to function correctly).
- exit_on_bad_outcome(api_ct_attach(ent));
- printf("Whole_ents after attach is : %d\n", ent.count());
- for (int kk = 0; kk < ent.count(); kk++)
- {
- printf("kk%d is %d; ", kk, is_BODY(ent[kk]));
- }
- //start stitch---
- GeometryStitch *geomStitch = new GeometryStitch;
- geomStitch->aei_STITCH_FULL(ent, Whole_ents);
- printf("geomStitch count is %d;\n ", Whole_ents.count());
- if(geo!=NULL){//0804append
- delete geo;
- geo = NULL;
- }
- }
- else {//self create
- Whole_ents = CreateSelfGeo();
- }
- printf("Load Geometry OK!"); //
- printf("Whole_ents is : %d\n", Whole_ents.count());
- //--test begin--
- api_ct_get_all_cells(Whole_ents, cells);
- printf("Cells Count: %d\n", cells.count());
- ENTITY_LIST lumps_list;
- api_get_lumps(Whole_ents[0], lumps_list);
- printf("Lumps Count: %d\n", lumps_list.count());
- ENTITY_LIST shell_list;
- api_get_shells(Whole_ents[0], shell_list);
- printf("Shells Count: %d\n", shell_list.count());
- ENTITY_LIST face_list;
- api_get_faces(Whole_ents[0], face_list);
- printf("Face count : %d\n", face_list.count());
- ENTITY_LIST loops_list;
- api_get_loops(Whole_ents[0], loops_list);
- printf("Loops count : %d\n", loops_list.count());
- ENTITY_LIST wires_list;
- api_get_wires(Whole_ents[0], wires_list);
- printf("Wires count : %d\n", wires_list.count());
- ENTITY_LIST edge_list;
- api_get_edges(Whole_ents[0], edge_list);
- printf("Edge count is : %d\n", edge_list.count());
- ENTITY_LIST coedges_list;
- api_get_coedges(Whole_ents[0], coedges_list);
- printf("Coedges count is : %d\n", coedges_list.count());
- ENTITY_LIST vertices_list;
- api_get_vertices(Whole_ents[0], vertices_list);
- printf("Vertices count is : %d\n", vertices_list.count());
- ENTITY_LIST tedges_list;
- api_get_tedges(Whole_ents[0], tedges_list);
- printf("tedges count is : %d\n", tedges_list.count());
- ENTITY_LIST tcoedges_list;
- api_get_tcoedges(Whole_ents[0], tcoedges_list);
- printf("tcoedges count is : %d\n", tcoedges_list.count());
- closeACIS();
- return true;
- }
- /**
- * @brief CreateProcess
- * Create the whole Process
- * @param[in]pathGeo ,pathParam
- pathGeo : geo file path(eq: "E:/xx.igs")
- pathParam: xml file path(eq: "E:/xx.xml")
- * @param[out]
- * @return bool
- * @author QiYan
- * @date 20221202
- */
- bool cmdMainProcess::CreateProcess_(string pathGeo, string pathParam)
- {
- Q_UNUSED(pathParam);
- // Note that 3DPM-Hexa does not respect the input surface mesh //3dpm-hexa不遵循曲面网格
- // If USE_HEXA is set to 1,
- // then both APPLY_PERIODICITY and USE_LOCAL_PHYSICAL_SIZE are set to 0
- iniACIS();
- //1.--read cad surf parameter
- //Get ENTITY_LIST;
- ENTITY_LIST Whole_ents;
- ENTITY_LIST cells;
- ENTITY_LIST ent;
- int externGeo = 0;
- if (externGeo == 0) {
- GeometryImExporter* geo = new GeometryImExporter();
- geo->LoadGeometryFile(pathGeo);
- ENTITY_LIST readRowEnt = geo->GetEntities();
- printf("Read all entity body count is %d;\n", readRowEnt.count());
- for (ENTITY *entC = readRowEnt.first(); entC != 0; entC = readRowEnt.next())
- {
- if (is_BODY(entC)) ent.add(entC);
- printf("current body is %s;", (is_closed_solid_body(entC)?"true":"face"));//判断是否闭合?
- }
- printf("\n Body's count is %d;", ent.count());
- //--获取边的信息
- ENTITY_LIST EdgeEnt = geo->GetEdges();
- const char *name = "entity_index";
- for (int kk=0;kk<EdgeEnt.count();kk++)
- {
- if (find_named_attrib(EdgeEnt[kk], name) == 0) {
- //printf("not find EdgeEnt name : %s\n", name);
- }else {
- //ATTRIB_GEN_STRING* pId = NULL;
- ATTRIB_GEN_INTEGER* pId = NULL;
- outcome result = api_find_named_attribute(EdgeEnt[kk], name, reinterpret_cast<ATTRIB_GEN_NAME*&>(pId));
- printf("find result : %d\n", result.ok());
- if (pId && (result.ok() == TRUE))
- {
- /* const char*name = pId->value();
- printf("find pId name : %s\n", name);*/
- int names = pId->value();
- printf("find EdgeEnt pId name : %d\n", names);
- }
- }
- }
- //--获取面信息
- ENTITY_LIST FaceEnt = geo->GetFaces();
- for (int kk=0; kk < FaceEnt.count(); kk++)
- {
- if (find_named_attrib(FaceEnt[kk], name) == 0) {
- //printf("not find FaceEnt name : %s\n", name);
- }else {
- //ATTRIB_GEN_STRING* pId = NULL;
- ATTRIB_GEN_INTEGER* pId = NULL;
- outcome result = api_find_named_attribute(FaceEnt[kk] , name, reinterpret_cast<ATTRIB_GEN_NAME*&>(pId));
- printf("find result : %d\n", result.ok());
- if (pId && (result.ok() == TRUE))
- {
- /* const char*name = pId->value();
- printf("find pId name : %s\n", name);*/
- int names = pId->value();
- printf("find FaceEnt pId name : %d\n", names);
- }
- }
- }
- ENTITY_LIST testEnt=ent;
- exit_on_bad_outcome(api_n_body_unite(testEnt, false));
- printf("Whole_ents after unite is : %d,then use stitch function\n", testEnt.count());
- if (testEnt.count()==1)
- {
- //exit_on_bad_outcome(api_n_body_unite(ent, false));
- //printf("Whole_ents after unite is : %d\n", ent.count());
- //for (int kk = 0; kk < ent.count(); kk++)
- //{
- // printf("kk%d is %d; ", kk, is_BODY(ent[kk]));
- //}
- //// Attach cellular topology to non-regular union (necessary for the Spa3dpm::Cell_VolumeElem_Assoc class below to function correctly).
- exit_on_bad_outcome(api_ct_attach(testEnt));
- printf("Whole_ents after attach is : %d\n", testEnt.count());
- /*for (int kk = 0; kk < ent.count(); kk++)
- {
- printf("kk%d is %d; ", kk, is_BODY(ent[kk]));
- }
- int tt = is_closed_solid_body(ent[0]);
- printf("closed solid body is : %d\n", tt);*/
- Whole_ents = testEnt;
- }else {
- //start stitch---
- GeometryStitch *geomStitch = new GeometryStitch;
- geomStitch->aei_STITCH_FULL(ent, Whole_ents);
- printf("geomStitch count is %d;\n ", Whole_ents.count());
- }
- //--
- //api_copy_entity(ent[0], &Whole_ents);
- if(geo!=NULL){//0804 append
- delete geo;
- geo = NULL;
- }
- }else {//self create
- Whole_ents = CreateSelfGeo();
- }
- printf("Load Geometry OK!"); //
- printf("Whole_ents is : %d\n", Whole_ents.count());
- ENTITY_LIST ents;
- ents = Whole_ents;
- //--test begin
- ENTITY_LIST face_list;
- api_get_faces(Whole_ents[0], face_list);
- printf("face count : %d\n", face_list.count());
- ENTITY_LIST edge_list;
- api_get_edges(Whole_ents[0], edge_list);
- printf("edge count is : %d\n", edge_list.count());
- //api_ct_get_all_cells(face_list[0], cells);
- api_ct_get_all_cells(ents, cells);
- printf("Cells Count: %d\n", cells.count());
- //const char*cpName = ((ATTRIB_GEN_STRING *)tNAME)->value();
- //--test end
- //2.--read cad surf parameter
- QString dDir=QDir::currentPath();
- printf("path:%s\n",dDir.toLatin1().data());
- ADIParam_.useDefaultParam();
- CRWriteFile* crw = new CRWriteFile();
- //if (!crw->ReadXmlParamFile(ADIParam_, pathParam.c_str()))
- //return false;
- if (!crw->ReadXmlParam(ADIParam_,object))//0831append
- return false;
- //3.--create surf.0
- Createcadsurf(ents, cadsurf_);
- //4.--Set parameters and create mesh
- cadsurfParams_ = setADIParamTo3dpm(ADIParam_);
- //-4.1-size map for vol
- CreateLocalSizeMap();
- //5.--output surfmesh with cleaner or not
- if(!OutPutSurfMesh(cadsurf_, surfMesh_, &cadsurfParams_))return 1;
- //-5.1-for vol
- printf("style=%d\n", ADIParam_.style);
- if(ADIParam_.style)
- {
- createVol(ADIParam_.style, cells);
- }
- //6. Save the surface mesh to .mesh (optional)
- QString appPath = dDir+"\\Data\\";//qy 2023-03-24修改路径
- QDateTime data = QDateTime::currentDateTime();
- QString strName;
- if (ADIParam_.strResultFormat == ".ugrid")
- {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "Result.ugrid";
- crw->WirteUgridFoamFile(surfMesh_, QString(appPath + strName).toLatin1());
- }
- else if (ADIParam_.strResultFormat == ".vtk") {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "Result.vtk";
- crw->WirteVtkFoamFile(surfMesh_, QString(appPath + strName).toLatin1());
- }
- else if (ADIParam_.strResultFormat == ".bdf") {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "Result.bdf";
- crw->WirteBDFFoamFile(surfMesh_, QString(appPath + strName).toLatin1());
- }
- else if (ADIParam_.strResultFormat == ".neu") {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "Result.neu";
- crw->WriteNeuFoamFile(surfMesh_, QString(appPath + strName).toLatin1());
- }
- exit_on_bad_outcome(api_3dpm_save_mesh(surfMesh_, "3dpmSample_surfMesh.mesh"));
- printf("Successfully wrote SurfMesh to .mesh format\n");
- //-6.1Deletesome Clean up MeshGems Sizemaps
- if (szmp_iso_face_t_)
- meshgems_sizemap_delete(szmp_iso_face_t_);
- if (szmp_iso_edge_t_)
- meshgems_sizemap_delete(szmp_iso_edge_t_);
- if (szmp_iso_point_t_)
- meshgems_sizemap_delete(szmp_iso_point_t_);
- //7. Termination
- closeACIS();
- if(crw!=NULL)
- {
- delete crw;
- crw = NULL;
- }
- //8.start show
- //QProcess *process = new QProcess;
- //process->setWorkingDirectory("..\\");
- //process->setWorkingDirectory("E:\\QY_Case\\MainWndTest\\case01\\trunk\\x64\\Release202010\\Release\\gmsh-4.3.0-Windows64");
- //QStringList strLName;
- //strLName << QString(appPath+strName);
- #ifdef _WIN32
- //process->start("E:\\QY_Case\\MainWndTest\\case01\\trunk\\x64\\Release202010\\Release\\gmsh-4.3.0-Windows64\\gmsh.exe", strLName);
- //process->start("..\\..\\Libs\\gmsh\\win\\gmsh-git-Windows64-sdk\\bin\\gmsh.exe",strLName);
- #else
- #endif
- return 1;
- }
- /**
- * @brief set ADIParam To Spa3dpm::Parameters
- For this sample we look at each API outcome and exit when something fails.
- In general your application may want to rethrow its own type of exception,
- or do something else.
- Be careful if you nest API blocks to make sure to rethrow acis_exceptions
- from the inner API block using check_outcome. Otherwise transactional behavior for
- APIs will not work.
- * @param[in] o
- * @return
- * @author qiyan
- * @date 2022-11-16
- * @reviser
- * @date
- */
- void cmdMainProcess::exit_on_bad_outcome(const outcome &o)
- {
- if (!o.ok())
- if (const message_list *ml = get_message(o.error_number()))
- {
- printf("*** ERROR: %s: %s\n", ml->ident, ml->message);
- exit(1);
- }
- }
- /**
- * @brief set ADIParam To Spa3dpm::Parameters
- *
- * @param[in] p
- * @return cadsurfParams
- * @author qiyan
- * @date 2022-11-16
- * @reviser
- * @date
- */
- Spa3dpm::Parameters cmdMainProcess::setADIParamTo3dpm(const DPM_ADIParam &p)
- {
- Spa3dpm::Parameters cadsurfParams;
- //cadsurfParams.SetParam("global_physical_size", "0.01"); // default: ModelDiagonal/100
- //cadsurfParams.SetParam("element_order", "quadratic");
- if (!p.surfParam_.SurfStyle.isEmpty())
- {
- cadsurfParams.SetParam("element_generation", p.surfParam_.SurfStyle.toLatin1().data());//"full_quad");//"quad_dominant");
- }
- if (!p.surfParam_.max_size.isEmpty())
- {
- cadsurfParams.SetParam("max_size", p.surfParam_.max_size.toLatin1().data());//"full_quad");//"quad_dominant");
- }
- if (!p.surfParam_.min_size.isEmpty())
- {
- cadsurfParams.SetParam("min_size", p.surfParam_.min_size.toLatin1().data());//"full_quad");//"quad_dominant");
- }
- if (!p.surfParam_.Global_physical_size.isEmpty())
- {
- cadsurfParams.SetParam("global_physical_size", p.surfParam_.Global_physical_size.toLatin1().data());//"full_quad");//"quad_dominant");
- }
- if (!p.surfParam_.gradation.isEmpty())
- {
- cadsurfParams.SetParam("gradation", p.surfParam_.gradation.toLatin1().data());//"full_quad");//"quad_dominant");
- }
- //optim
- if (!p.surfParam_.element_order.isEmpty())
- {
- //"full_quad");//"quad_dominant");
- if (p.surfParam_.element_order=="quadratic" )
- {
- cadsurfParams.SetParam("element_order", p.surfParam_.element_order.toLatin1().data());
- if (!p.surfParam_.scaled_jacobian_threshold_value.isEmpty())
- {
- cadsurfParams.SetParam("scaled_jacobian_threshold_value", p.surfParam_.scaled_jacobian_threshold_value.toLatin1().data());
- }
- }
- }
- if (!p.surfParam_.remove_duplicate_cad_faces.isEmpty()&& p.surfParam_.remove_duplicate_cad_faces=="no")
- {
- cadsurfParams.SetParam("remove_duplicate_cad_faces", p.surfParam_.remove_duplicate_cad_faces.toLatin1().data());
- }
- if (!p.surfParam_.correct_surface_intersections.isEmpty())
- {
- if (p.surfParam_.correct_surface_intersections=="no"&& p.surfParam_.optimisation=="yes")
- {
- cadsurfParams.SetParam("correct_surface_intersections", p.surfParam_.correct_surface_intersections.toLatin1().data());
- cadsurfParams.SetParam("optimisation", p.surfParam_.optimisation.toLatin1().data());
- }
- }
- //more setting
- if (!p.surfParam_.debug.isEmpty())
- {
- cadsurfParams.SetParam("debug", p.surfParam_.debug.toLatin1().data());
- }
- if (!p.surfParam_.closed_geometry.isEmpty())
- {
- cadsurfParams.SetParam("closed_geometry", p.surfParam_.closed_geometry.toLatin1().data());
- }
- if (!p.surfParam_.anisotropic_ratio.isEmpty())
- {
- cadsurfParams.SetParam("anisotropic_ratio", p.surfParam_.anisotropic_ratio.toLatin1().data());
- }
- if (!p.surfParam_.bad_surface_element_aspect_ratio.isEmpty())
- {
- cadsurfParams.SetParam("bad_surface_element_aspect_ratio", p.surfParam_.bad_surface_element_aspect_ratio.toLatin1().data());
- }
- if (!p.surfParam_.chordal_error.isEmpty())
- {
- cadsurfParams.SetParam("chordal_error", p.surfParam_.chordal_error.toLatin1().data());
- }
- if (!p.surfParam_.closed_geometry.isEmpty())
- {
- cadsurfParams.SetParam("closed_geometry", p.surfParam_.closed_geometry.toLatin1().data());
- }
- if (!p.surfParam_.discard_input_topology.isEmpty())
- {
- cadsurfParams.SetParam("discard_input_topology", p.surfParam_.discard_input_topology.toLatin1().data());
- }
- if (!p.surfParam_.create_tag_on_collision.isEmpty())
- {
- cadsurfParams.SetParam("create_tag_on_collision", p.surfParam_.create_tag_on_collision.toLatin1().data());
- }
- if (!p.surfParam_.chordal_error.isEmpty())
- {
- cadsurfParams.SetParam("chordal_error", ADIParam_.surfParam_.chordal_error.toLatin1().data());
- printf("chordal_error set\n");
- }
- if (!p.surfParam_.geometric_approximation_angle.isEmpty())
- {
- cadsurfParams.SetParam("geometric_approximation_angle", ADIParam_.surfParam_.geometric_approximation_angle.toLatin1().data());
- printf("geometric_approximation_angle set\n");
- }
- //--mg
- if (!p.surfParam_.physical_size_mode.isEmpty()&& p.surfParam_.physical_size_mode=="local"){
- USE_LOCAL_PHYSICAL_SIZE = 1;
- printf("print the physical_size_mode");
- //}else{ //if (p.surfParam_.physical_size_mode=="global"){
- }else if (!p.surfParam_.physical_size_mode.isEmpty()){
- cadsurfParams.SetParam("physical_size_mode", p.surfParam_.physical_size_mode.toLatin1().data());
- }
- if (!p.surfParam_.geometric_size_mode.isEmpty() && p.surfParam_.geometric_size_mode == "local") {
- USE_LOCAL_PHYSICAL_SIZE = 2;
- printf("print the geometric_size_mode");
- //}else {//if (p.surfParam_.geometric_size_mode == "global") {
- }else if (!p.surfParam_.geometric_size_mode.isEmpty()) {
- cadsurfParams.SetParam("geometric_size_mode", p.surfParam_.geometric_size_mode.toLatin1().data());
- printf("*** geometric_size_mode: %s\n", p.surfParam_.geometric_size_mode.toLatin1().data());
- }
- return cadsurfParams;
- }
- /**
- * @brief get Spa3dpm::Parameters
- Create a cadsurf session that will convert the
- Acis model(the non - regular union of two blocks and the sphere)
- into a surface mesh.
- * @param[in] ents、 cadsurf
- * @return bool
- * @author qiyan
- * @date 2022-11-16
- * @reviser
- * @date
- */
- bool cmdMainProcess::Createcadsurf(const ENTITY_LIST &ents, Spa3dpm::CadSurfSession &cadsurf)
- {
- exit_on_bad_outcome(api_3dpm_create_cadsurf_session(ents, cadsurf));
- printf("Successfully created cadsurf session\n");
- return true;
- }
- /**
- * @brief get output mesh
- Create a cadsurf session that will convert the
- Acis model(the non - regular union of two blocks and the sphere)
- into a surface mesh.
- * @param[in] ents、 cadsurf
- * @return bool
- * @author qiyan
- * @date 2022-11-16
- * @reviser
- * @date
- */
- bool cmdMainProcess::OutPutSurfMesh(Spa3dpm::MgSession &inSession, Spa3dpm::Mesh &outMesh, const Spa3dpm::Parameters *inParams)
- {
- printf("start created 3dpm_compute_mesh\n");
- exit_on_bad_outcome(api_3dpm_compute_mesh(inSession, outMesh, inParams));
- printf("Successfully created surface mesh\n");
- if (ADIParam_.bCleanerSection)//open cleaner or not
- {
- printf("start created create_cleaner_session\n");
- Spa3dpm::CleanerSession cleantetra;
- exit_on_bad_outcome(api_3dpm_create_cleaner_session(outMesh, cleantetra));
- Spa3dpm::Parameters cleanerParams;
- //--set cleaner parameter
- if (!ADIParam_.clrParam.folding_angle.isEmpty())
- {
- cleanerParams.SetParam("folding_angle", ADIParam_.clrParam.folding_angle.toLatin1().data());
- printf("cleanerParams folding_angle:\n");
- }
- if (!ADIParam_.clrParam.use_default_settings_for.isEmpty())//默认设置
- {
- cleanerParams.SetParam("use_default_settings_for", ADIParam_.clrParam.use_default_settings_for.toLatin1().data());
- printf("start cleaner session use_default_settings_for...\n");
- }else {//可编辑
- if (!ADIParam_.clrParam.resolution_length.isEmpty())
- {
- cleanerParams.SetParam("resolution_length", ADIParam_.clrParam.resolution_length.toLatin1().data());
- printf("start cleaner session resolution_length...\n");
- }
- if (!ADIParam_.clrParam.overlap_angle.isEmpty())
- {
- cleanerParams.SetParam("overlap_angle", ADIParam_.clrParam.overlap_angle.toLatin1().data());
- printf("start cleaner session overlap_angle...\n");
- }
- }
- printf("Successfully set cleaner session\n");
- exit_on_bad_outcome(api_3dpm_compute_mesh(cleantetra, outMesh, &cleanerParams));
- printf("Successfully created cleaner surface mesh\n");
- }
- return true;
- }
- /**
- * @brief CreateSelfGeo
- * --create geo for test
- * @param[in]
- * @param[out]
- * @return ENTITY_LIST
- * @author QiYan
- * @date 20221202
- */
- ENTITY_LIST cmdMainProcess::CreateSelfGeo()
- {
- ENTITY_LIST ents;
- // Create the first solid block
- BODY *block = nullptr;
- exit_on_bad_outcome(api_solid_block(SPAposition(0, 0, 0), SPAposition(10, 5, 10), block));
- ents.add(block);
- // Create a hanging face inside the first block
- FACE *face = nullptr;
- exit_on_bad_outcome(api_face_plane(SPAposition(1, 1, 5), 8, 3, &SPAvector(0.0, 0.0, 1.0), face));
- //exit_on_bad_outcome(api_face_plane(SPAposition(1, 1, 1), 4, 1, &SPAvector(0.0, 0.0, 1.0), face));
- BODY * sheet = nullptr;
- api_sheet_from_ff(1, &face, sheet);
- ents.add(sheet);
- //FACE *face2 = nullptr;
- ////exit_on_bad_outcome(api_face_plane(SPAposition(1, 1, 5), 8, 3, &SPAvector(0.0, 0.0, 1.0), face));
- //exit_on_bad_outcome(api_face_plane(SPAposition(2, 2, 2), 4, 1, &SPAvector(0.0, 0.0, 1.0), face2));
- //BODY * sheet2 = nullptr;
- //api_sheet_from_ff(1, &face2, sheet2);
- //ents.add(sheet2);
- // Create the second solid cube with edge length 10, adjacent to the first block
- BODY *cube = nullptr;
- exit_on_bad_outcome(api_solid_block(SPAposition(0, 5, 0), SPAposition(10, 15, 10), cube));
- ents.add(cube);
- // Create a sphere of radius 4 that lies insides the second block
- BODY *sphere = nullptr;
- exit_on_bad_outcome(api_solid_sphere(SPAposition(5, 10, 5), 4, sphere));
- ents.add(sphere);
- printf("Entity Count not unite: %d\n", ents.count());
- // Non-regularized unite of the blocks and the sphere. All faces are kept and used to divide the output body into cells (in Acis) and subdomains (in 3DPM).
- exit_on_bad_outcome(api_n_body_unite(ents, false));
- // Attach cellular topology to non-regular union (necessary for the Spa3dpm::Cell_VolumeElem_Assoc class below to function correctly).
- exit_on_bad_outcome(api_ct_attach(ents));
- //printf("Successfully attached cellular topology to body\n");
- //ENTITY_LIST cells;
- //api_ct_get_all_cells(ents, cells);
- //printf("Cells Count: %d\n", cells.count());
- printf("Entity Count after unite: %d\n", ents.count());
- return ents;
- }
- /**
- * @brief CreateLocalSizeMap
- * --use local size
- * @param[in]
- * @param[out]
- * @return ENTITY_LIST
- * @author QiYan
- * @date 20221202
- */
- void cmdMainProcess::CreateLocalSizeMap()
- {
- // Sizemaps to be set
- //USE_LOCAL_PHYSICAL_SIZE = 1;
- if (USE_LOCAL_PHYSICAL_SIZE==1)//physical_size_mode must be "local"
- {
- // Apply physical size functions, sizemaps应用物理尺寸函数、尺寸映射
- //if (!ADIParam_.surfParam_.physical_size_mode.isEmpty())
- //{
- cadsurfParams_.SetParam("physical_size_mode", ADIParam_.surfParam_.physical_size_mode.toLatin1().data());
- //}
- // default: "none"; when use_local_physical_size需要設置為 "local"
- // Create a sizemap associated with faces创建与面关联的尺寸映射
- SampleUtils_ = new DPMvolClass();
- if (ADIParam_.surfParam_.Global_physical_size.isEmpty())
- {
- printf("error : global_physical_size is empty!\n");
- return;
- }
- SampleUtils_->setGlobelSize(ADIParam_.surfParam_.Global_physical_size.toDouble());
- // Get pointer to native MeshGems cad_t object
- meshgems_cad_t *mg_cad = cadsurf_.GetMeshgemsCadPtr();
- if (!ADIParam_.surfParam_.physicalSizeFaceId.isEmpty())
- {
- SampleUtils_->SetLocalSizeData(2, ADIParam_.surfParam_.physicalSizeFaceId);//"1,10;2,4;");
- szmp_iso_face_t_ = meshgems_sizemap_new(mg_cad, meshgems_sizemap_type_iso_cad_face, SampleUtils_->size_iso_face, SampleUtils_);
- if (!szmp_iso_face_t_) sys_error(MESHGEMS_STATUS_NOMEM);
- #ifdef ADI_DEBUG_PRINT
- printf("Sizemap face ok \n");
- #endif
- }
- // Create a sizemap associated with edges
- if (!ADIParam_.surfParam_.physicalSizeEdgeId.isEmpty())
- {
- SampleUtils_->SetLocalSizeData(1, ADIParam_.surfParam_.physicalSizeEdgeId);
- szmp_iso_edge_t_ = meshgems_sizemap_new(mg_cad, meshgems_sizemap_type_iso_cad_edge, SampleUtils_->size_iso_edge, SampleUtils_); //SampleUtils_.size_iso_edge, 0);
- if (!szmp_iso_edge_t_) sys_error(MESHGEMS_STATUS_NOMEM);
- #ifdef ADI_DEBUG_PRINT
- printf("Sizemap edge ok \n");
- #endif
- }
- // Create a sizemap associated with point
- if (!ADIParam_.surfParam_.physicalSizePointId.isEmpty())
- {
- SampleUtils_->SetLocalSizeData(0, ADIParam_.surfParam_.physicalSizePointId);
- szmp_iso_point_t_ = meshgems_sizemap_new(mg_cad, meshgems_sizemap_type_iso_cad_point, SampleUtils_->size_iso_point, SampleUtils_);
- if (!szmp_iso_point_t_) sys_error(MESHGEMS_STATUS_NOMEM);
- printf("Sizemap point ok \n");
- }
- // Get MeshGems native cadsurf sessions
- meshgems_cadsurf_session_t *mg_cadsurf[2];
- cadsurf_.GetMeshgemsSessionPtr(mg_cadsurf);
- // Set the sizemaps to the session
- if (szmp_iso_face_t_) {
- meshgems_cadsurf_set_sizemap(mg_cadsurf[0], szmp_iso_face_t_); // index 0 is for analytical CAD
- }
- if(szmp_iso_edge_t_){
- meshgems_cadsurf_set_sizemap(mg_cadsurf[0], szmp_iso_edge_t_);
- }
- if (szmp_iso_point_t_){
- meshgems_cadsurf_set_sizemap(mg_cadsurf[0], szmp_iso_point_t_);
- }
- }else if (USE_LOCAL_PHYSICAL_SIZE==2){//geometry size mode
- // Apply physical size functions, sizemaps
- //if (!ADIParam_.surfParam_.physical_size_mode.isEmpty())
- //{
- cadsurfParams_.SetParam("geometric_size_mode", ADIParam_.surfParam_.geometric_size_mode.toLatin1().data());
- //}
- // default: "none"; when use_local_physical_size需要設置為 "local"
- // Create a sizemap associated with faces
- SampleUtils_ = new DPMvolClass();
- if (ADIParam_.surfParam_.Global_physical_size.isEmpty())
- {
- printf("error : global_physical_size is empty!");
- return;
- }
- SampleUtils_->setGlobelSize(ADIParam_.surfParam_.Global_physical_size.toDouble());
- // Get pointer to native MeshGems cad_t object
- meshgems_cad_t *mg_cad = cadsurf_.GetMeshgemsCadPtr();
- if (!ADIParam_.surfParam_.geometricSizeFaceId.isEmpty())
- {
- SampleUtils_->SetLocalSizeData(2, ADIParam_.surfParam_.geometricSizeFaceId);//"1,10;2,4;");
- szmp_iso_face_t_ = meshgems_sizemap_new(mg_cad, meshgems_sizemap_type_iso_cad_face, SampleUtils_->size_iso_face, SampleUtils_);
- if (!szmp_iso_face_t_) sys_error(MESHGEMS_STATUS_NOMEM);
- #ifdef ADI_DEBUG_PRINT
- printf("Sizemap face ok \n");
- #endif
- }
- // Create a sizemap associated with edges
- if (!ADIParam_.surfParam_.geometricSizeEdgeId.isEmpty())
- {
- SampleUtils_->SetLocalSizeData(1, ADIParam_.surfParam_.geometricSizeEdgeId);
- szmp_iso_edge_t_ = meshgems_sizemap_new(mg_cad, meshgems_sizemap_type_iso_cad_edge, SampleUtils_->size_iso_edge, SampleUtils_); //SampleUtils_.size_iso_edge, 0);
- if (!szmp_iso_edge_t_) sys_error(MESHGEMS_STATUS_NOMEM);
- #ifdef ADI_DEBUG_PRINT
- printf("Sizemap edge ok \n");
- #endif
- }
- // Create a sizemap associated with point创建与点关联的尺寸映射
- if (!ADIParam_.surfParam_.geometricSizePointId.isEmpty())
- {
- SampleUtils_->SetLocalSizeData(0, ADIParam_.surfParam_.geometricSizePointId);
- szmp_iso_point_t_ = meshgems_sizemap_new(mg_cad, meshgems_sizemap_type_iso_cad_point, SampleUtils_->size_iso_point, SampleUtils_);
- if (!szmp_iso_point_t_) sys_error(MESHGEMS_STATUS_NOMEM);
- printf("Sizemap point ok \n");
- }
- // Get MeshGems native cadsurf sessions
- meshgems_cadsurf_session_t *mg_cadsurf[2];
- cadsurf_.GetMeshgemsSessionPtr(mg_cadsurf);
- // Set the sizemaps to the session
- if (szmp_iso_face_t_) {
- meshgems_cadsurf_set_sizemap(mg_cadsurf[0], szmp_iso_face_t_); // index 0 is for analytical CAD
- }
- if (szmp_iso_edge_t_) {
- meshgems_cadsurf_set_sizemap(mg_cadsurf[0], szmp_iso_edge_t_);
- }
- if (szmp_iso_point_t_) {
- meshgems_cadsurf_set_sizemap(mg_cadsurf[0], szmp_iso_point_t_);
- }
- }
- // Periodic Meshing / Mesh Matching周期性网格划分/网格匹配
- // Refer to "Section 4.3.7 Setting any CAD mesh matching specifications" in mg-cadsurf_user_manual.pdf for more examples
- if (APPLY_PERIODICITY)
- {
- if (SampleUtils_->apply_reflection_periodicity(cadsurf_))
- printf("Successfully applied mesh periodicity settings\n");
- else
- printf("Failed to apply mesh periodicity settings\n");
- }
- }
- /**
- * @brief createVol
- * --choose mesh style
- * @param[in]istyle ,cells
- style :
- 1:tetra;2:hexa;3:hybird
- cell:
- * @param[out]
- * @return ENTITY_LIST
- * @author QiYan
- * @date 20221202
- */
- void cmdMainProcess::createVol(int istyle,ENTITY_LIST &cells)
- {
- if (istyle==1){//四面体网格
- USE_TETRA = 1;
- USE_HEXA = 0;
- USE_HYBIRD = 0;
- }else if (istyle == 2){//六面体网格
- USE_HEXA = 1;
- USE_TETRA = 0;
- USE_HYBIRD = 0;
- }else if(istyle==3){//混合网格划分
- USE_HYBIRD = 1;
- USE_TETRA = 0;
- USE_HEXA = 0;
- }else {
- return;
- }
- if (USE_HEXA == 1)
- {
- USE_TETRA = 0;
- APPLY_PERIODICITY = 0;
- USE_LOCAL_PHYSICAL_SIZE = 0;
- }else{
- if (USE_HYBIRD == 0)
- {
- USE_TETRA = 1; // Make sure at least one type of volume mesh is chosen
- }
- }
- printf("USE_TETRA = %d\n", USE_TETRA);
- printf("USE_HEXA = %d\n", USE_HEXA);
- printf("USE_HYBIRD = %d\n", USE_HYBIRD);
- if (APPLY_PERIODICITY)
- {
- //// Mesh Matching of two periodic faces (reflection) with IDs 1 and 5
- //if (verify_mesh_periodicity(surfMesh_.GetMeshgemsMeshPtr(), 1, 5))
- // printf("Successfully verified mesh periodicity\n");
- //else
- // printf("Failed to verify mesh periodicity\n");
- }
- // Create the volume mesh.
- Spa3dpm::Mesh volMesh;
- Spa3dpm::Cell_VolumeElem_Assoc::VolumeElemType currentVolElemType = Spa3dpm::Cell_VolumeElem_Assoc::Tetra;
- std::string strElemType;
- // Create "user_data" for set_subdomain_description callback
- // Keep it in higher scope since other MeshGems functions may use this user_data
- std::vector<int> surfMeshFaceIndices;
- if (USE_HEXA)
- {
- // Specify the mesh element type
- strElemType = "Hexahedron";
- currentVolElemType = Spa3dpm::Cell_VolumeElem_Assoc::Hexa;
- // Set 3DPM-Hexa parameters
- Spa3dpm::Parameters hexaParams;
- if (ADIParam_.hexaParam.components.isEmpty())
- {
- printf(" hexaParam.components is empty!");
- return;
- }
- hexaParams.SetParam("components", ADIParam_.hexaParam.components.toLatin1().data()); // all connected components will be meshed
- printf("tags %s\n", ADIParam_.hexaParam.components.toLatin1().data());
- //hexaParams.SetParam("tags", "respect");
- if (!ADIParam_.hexaParam.min_size.isEmpty())
- {
- hexaParams.SetParam("min_size", ADIParam_.hexaParam.min_size.toLatin1().data());
- }
- if (!ADIParam_.hexaParam.max_size.isEmpty())
- {
- hexaParams.SetParam("max_size", ADIParam_.hexaParam.max_size.toLatin1().data());
- }
- //ADIParam_.hexaParam.min_size.toLatin1().data());// hexaParams.SetParam("manifold_geometry", "no"); // critical to mesh non-manifold bodies
- //printf("min_size %s\n", ADIParam_.hexaParam.min_size.toStdString());
- hexaParams.SetParam("verbose", "3"); // allows the user to raise the amount of information sent to the callback during the mesh generation process (default 3)
- //hexaParams.SetParam("min_size", "0.0001");
- // Current 3DPM-Hexa Limitation:
- // - subdomain description needs to be manually set for non-manifold regions in 3DPM-Hexa
- // to tag the subdomains in a similar fashion to 3DPM-Tetra and 3DPM-Tetra_HPC results (with 1, 2, 3, ...)
- // Helper function to find seed surface elements and populate "surfMeshFaceIndices" for setting the subdomain description
- //if (SampleUtils_ == NULL)
- //{
- // SampleUtils_ = new ADI3DPMNameSpace::DPMvolClass();
- //}
- //if (SampleUtils_->find_subdomain_seed_from_ct(cadsurf_, surfMesh_, cells, surfMeshFaceIndices))
- // printf("Successfully found seeds to set hexahedral subdomain description\n");
- //
- //// Set subdomain description on the input surface mesh
- //// Hexa will use this information to tag generated hexa elements accordingly
- //meshgems_mesh_t *mg_surf_mesh = surfMesh_.GetMeshgemsMeshPtr();
- //// Set subdomain count
- //meshgems_mesh_set_subdomain_count(mg_surf_mesh, cells.count()); // assume CELL count is equal to mesh subdomain count
- //
- ////qy // Set subdomain description
- //
- //meshgems_status_t setRes = meshgems_mesh_set_get_subdomain_description(mg_surf_mesh, (meshgems_mesh_get_subdomain_description_t)(SampleUtils_->hexa_mesh_get_subdomain_description_impl), &surfMeshFaceIndices);
- //printf("set_get_subdoamin_description was set: %s\n", ((setRes == MESHGEMS_STATUS_OK) ? "true" : "false"));
- //
- // Create Hexa session
- Spa3dpm::HexaSession hexa;
- exit_on_bad_outcome(api_3dpm_create_hexa_session(surfMesh_, hexa));
- printf("Successfully created hexa session\n");
- exit_on_bad_outcome(api_3dpm_compute_mesh(hexa, volMesh, &hexaParams));
- printf("Successfully created volume mesh\n");
- printf("Total Hexahedron count: %d\n", volMesh.HexahedronCount());
- // Get callback messages from Hexa session (optional)
- //get_mg_messages(dynamic_cast<Spa3dpm::MgSession&>(hexa));
- }
- if (USE_TETRA)
- {
- // Create a tetrahedral mesh
- strElemType = "Tetrahedron";
- currentVolElemType = Spa3dpm::Cell_VolumeElem_Assoc::Tetra;
- // Create a tetra session that will convert the MeshGems surface mesh into a MeshGems volume mesh containing tetrahedra only.
- Spa3dpm::TetraHpcSession tetra;
- exit_on_bad_outcome(api_3dpm_create_tetra_hpc_session(surfMesh_, tetra));
- printf("Successfully created tetra session\n");
- // Set Tetra Parameters
- Spa3dpm::Parameters tetParams;
- tetParams.SetParam("components", ADIParam_.tetraParam.components.toLatin1().data());//"all"); // all connected components will be meshed
- tetParams.SetParam("gradation", ADIParam_.tetraParam.gradation.toLatin1().data()); // critical to g enerate volume elements with uniform sizes set in the input surface mesh
- tetParams.SetParam("verbose", "10");
- tetParams.SetParam("max_number_of_threads", "8");
- tetParams.SetParam("number_of_subdomains", "1");
- if (!ADIParam_.tetraParam.min_size.isEmpty())
- {
- tetParams.SetParam("min_size", ADIParam_.tetraParam.min_size.toLatin1().data());
- printf("tetParams min_size:\n");
- }
- if (!ADIParam_.tetraParam.max_size.isEmpty())
- {
- tetParams.SetParam("max_size", ADIParam_.tetraParam.max_size.toLatin1().data());
- }
- exit_on_bad_outcome(api_3dpm_compute_mesh(tetra, volMesh, &tetParams));
- printf("Successfully created volume mesh\n");
- printf("Total Tetrahedron count: %d\n", volMesh.TetrahedronCount());
- }
- if (USE_HYBIRD)
- {
- // Create a Hybird mesh
- strElemType = "Hybrid";
- currentVolElemType = Spa3dpm::Cell_VolumeElem_Assoc::Tetra;
- // Create a tetra session that will convert the MeshGems surface mesh into a MeshGems volume mesh containing tetrahedra only.
- Spa3dpm::HybridSession Hybird;
- exit_on_bad_outcome(api_3dpm_create_hybrid_session(surfMesh_, Hybird));
- printf("Successfully created Hybird session\n");
- // Set Tetra Parameters
- Spa3dpm::Parameters HybirdParams;
- if (!ADIParam_.hybridParam.HybridStyle.isEmpty())
- {
- HybirdParams.SetParam("element_generation", ADIParam_.hybridParam.HybridStyle.toLatin1().data());
- }
- if (!ADIParam_.hybridParam.number_of_boundary_layers.isEmpty())
- {
- HybirdParams.SetParam("number_of_boundary_layers", ADIParam_.hybridParam.number_of_boundary_layers.toLatin1().data());
- }
- if (!ADIParam_.hybridParam.normal_direction.isEmpty())
- {
- HybirdParams.SetParam("normal_direction", ADIParam_.hybridParam.normal_direction.toLatin1().data());
- }
- if (!ADIParam_.hybridParam.boundary_layer_global_initial_height.isEmpty())
- {
- HybirdParams.SetParam("boundary_layer_global_initial_height", ADIParam_.hybridParam.boundary_layer_global_initial_height.toLatin1().data());
- }
- if (!ADIParam_.hybridParam.boundary_layer_geometric_progression.isEmpty())
- {
- HybirdParams.SetParam("boundary_layer_geometric_progression", ADIParam_.hybridParam.boundary_layer_geometric_progression.toLatin1().data());
- }
- exit_on_bad_outcome(api_3dpm_compute_mesh(Hybird, volMesh, &HybirdParams));
- printf("Successfully created volume mesh\n");
- printf("Total Tetrahedron count: %d\n", volMesh.TetrahedronCount());
- }
- //print_mesh_info(volMesh); // optional
- //Save the volumen mesh to .mesh (optional)
- exit_on_bad_outcome(api_3dpm_save_mesh(volMesh, "3dpmSample_volMesh.mesh"));
- printf("Successfully wrote VolMesh to .mesh format\n\n");
- //// Extract CAD-Mesh associativity information
- //meshgems_mesh_t *mg_mesh = volMesh.GetMeshgemsMeshPtr();
- //meshgems_integer numSubdomain = -1;
- //if (MESHGEMS_STATUS_IS_ERROR(meshgems_mesh_get_subdomain_count(mg_mesh, &numSubdomain)))
- // sys_error(SPA3DPM_GENERIC_FAILURE);
- //printf("Number of subdomains in mesh: %d\n", numSubdomain);
- //// Create the association class between ACIS cells and MeshGems subdomains.
- //Spa3dpm::Cell_VolumeElem_Assoc volumeAssoc;
- //exit_on_bad_outcome(api_3dpm_create_volume_assoc(volMesh, volumeAssoc));
- //printf("Successfully created volume element association object\n");
- //// The following code demonstrates how to:
- //// 1. Get the ACIS cell from a volume element index (Here, we are using the first element in the mesh)
- //// 2. Get all volume elements associated with that ACIS cell and print out available information
- //Spa3dpm::Cell_VolumeElem_Assoc::VolumeElemArray volElemArray;
- //int seedElemIndex = 1;
- //CELL *cell = volumeAssoc.FindCell(Spa3dpm::Cell_VolumeElem_Assoc::VolumeElem(currentVolElemType, seedElemIndex));
- //volumeAssoc.FindVolumeElements(cell, volElemArray);
- //// Cycle through the list of volume elements in the cell that contains the volume element with index 1.
- //auto sz = volElemArray.Size();
- //printf("Number of elements in the cell containing %s with index 1: %zu\n", strElemType.c_str(), sz);
- //printf("List of elements in the cell containing %s with index 1:", strElemType.c_str());
- //for (decltype(sz) i = 0; i < sz; i++)
- //{
- // if (i % 6 == 0)
- // printf("\n\t(");
- // else
- // printf(", (");
- // switch (volElemArray[i].elemType)
- // {
- // case Spa3dpm::Cell_VolumeElem_Assoc::Tetra:
- // printf("tetra");
- // break;
- // case Spa3dpm::Cell_VolumeElem_Assoc::Hexa:
- // printf("hexa");
- // break;
- // case Spa3dpm::Cell_VolumeElem_Assoc::Pyramid:
- // printf("pyramid");
- // break;
- // case Spa3dpm::Cell_VolumeElem_Assoc::Prism:
- // printf("prism");
- // break;
- // }
- // printf(", #%d)", volElemArray[i].elemIndex);
- //}
- //printf("\n");
- QString dDir = QDir::currentPath();
- QString appPath = dDir + "\\Data\\";
- QDateTime data = QDateTime::currentDateTime();
- QString strName;
- CRWriteFile* crw = new CRWriteFile();
- if (ADIParam_.strResultFormat == ".ugrid")
- {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "VolResult.ugrid";
- crw->WirteUgridFoamFile(volMesh, QString(appPath + strName).toLatin1());
- }else if (ADIParam_.strResultFormat == ".vtk") {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "VolResult.vtk";
- crw->WirteVtkFoamFile(volMesh, QString(appPath + strName).toLatin1());
- }else if (ADIParam_.strResultFormat == ".bdf") {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "VolResult.bdf";
- crw->WirteBDFFoamFile(volMesh, QString(appPath + strName).toLatin1());
- }
- else if (ADIParam_.strResultFormat == ".neu") {
- strName = data.toString("yyyy_MM_dd_HH_mm_ss") + "VolResult.neu";
- crw->WriteNeuFoamFile(volMesh, QString(appPath + strName).toLatin1());
- }
- exit_on_bad_outcome(api_3dpm_save_mesh(surfMesh_, "3dpmSample_surfMesh.mesh"));
- printf("Successfully wrote vol to .mesh format\n");
- //-----
- //7.start show for qy --only for self show
- QProcess *process = new QProcess;
- process->setWorkingDirectory("F:\\czm\\qt_demo\\build-test_hoops-Desktop_Qt_5_12_0_MSVC2015_64bit-Debug\\debug\\gmsh");
- QStringList strLName;
- strLName << QString(appPath + strName);
- process->start("F:\\czm\\qt_demo\\build-test_hoops-Desktop_Qt_5_12_0_MSVC2015_64bit-Debug\\debug\\gmsh\\win\\gmsh-git-Windows64-sdk\\bin\\gmsh.exe", strLName);
- if(crw!=NULL){
- delete crw;
- crw = NULL;
- }
- }
- //-callbacke
- //static meshgems_status_t cmdMainProcess::size_iso_edge(meshgems_integer edge_id, meshgems_real t, meshgems_real *size, void *user_data)
- //{
- // Acis3dpmSampleUtils::size_iso_edge;
- //}
|