Commit c001de20 by Christophe Geuzaine

prettify and constify API

parent 32f0e2d4
Pipeline #753 passed with stage
in 76 minutes 49 seconds
......@@ -103,6 +103,7 @@ bool GEO_Internals::addVertex(int &tag, double x, double y, double z, double lc)
return false;
}
if(tag < 0) tag = getMaxTag(0) + 1;
if(!lc) lc = MAX_LC;
Vertex *v = CreateVertex(tag, x, y, z, lc, 1.0);
Tree_Add(Points, &v);
_changed = true;
......
......@@ -22,9 +22,9 @@ endif(GMSH_LIB MATCHES ".a")
include_directories(${GMSH_INC})
file(GLOB FILES *.cpp)
foreach(FILE ${FILES})
get_filename_component(DEMO ${FILE} NAME_WE)
add_executable(${DEMO} ${FILE})
target_link_libraries(${DEMO} ${GMSH_LIB} ${LAPACK_LIB} ${BLAS_LIB})
endforeach(FILE)
file(GLOB DEMOS *.cpp)
foreach(DEMO ${DEMOS})
get_filename_component(DEMONAME ${DEMO} NAME_WE)
add_executable(${DEMONAME} ${DEMO})
target_link_libraries(${DEMONAME} ${GMSH_LIB} ${LAPACK_LIB} ${BLAS_LIB})
endforeach(DEMO)
......@@ -17,19 +17,19 @@ int main(int argc, char **argv)
double R = 1.4, Rs = R*.7, Rt = R*1.25;
std::vector<int> t = {1,2,3,4,5,6,7,8};
gmshModelOccAddBox(t[0], -R,-R,-R, 2*R,2*R,2*R);
gmshModelOccAddSphere(t[1], 0,0,0,Rt);
int o;
gmshModelOccAddBox(1, -R,-R,-R, 2*R,2*R,2*R, o);
gmshModelOccAddSphere(2, 0,0,0,Rt, o);
std::vector<std::pair<int, int> > o;
std::vector<std::pair<int, int> > ov;
std::vector<std::vector<std::pair<int, int> > > om;
gmshModelOccBooleanIntersection(t[2], {{3, t[0]}}, {{3, t[1]}}, o, om);
gmshModelOccAddCylinder(t[3], -2*R,0,0, 4*R,0,0, Rs);
gmshModelOccAddCylinder(t[4], 0,-2*R,0, 0,4*R,0, Rs);
gmshModelOccAddCylinder(t[5], 0,0,-2*R, 0,0,4*R, Rs);
gmshModelOccBooleanUnion(t[6], {{3, t[3]}, {3, t[4]}}, {{3, t[5]}}, o, om);
gmshModelOccBooleanDifference(t[7], {{3, t[2]}}, {{3, t[6]}}, o, om);
gmshModelOccBooleanIntersection(3, {{3, 1}}, {{3, 2}}, ov, om);
gmshModelOccAddCylinder(4, -2*R,0,0, 4*R,0,0, Rs, o);
gmshModelOccAddCylinder(5, 0,-2*R,0, 0,4*R,0, Rs, o);
gmshModelOccAddCylinder(6, 0,0,-2*R, 0,0,4*R, Rs, o);
gmshModelOccBooleanUnion(7, {{3, 4}, {3, 5}}, {{3, 6}}, ov, om);
gmshModelOccBooleanDifference(8, {{3, 3}}, {{3, 7}}, ov, om);
gmshModelOccSynchronize();
......
......@@ -10,32 +10,22 @@ int main(int argc, char **argv)
gmshModelCreate("t1");
double lc = 1e-2;
std::vector<int> t = {1, 2, 3, 4};
gmshModelGeoAddVertex(t[0], 0, 0, 0, lc);
gmshModelGeoAddVertex(t[1], .1, 0, 0, lc);
gmshModelGeoAddVertex(t[2], .1, .3, 0, lc);
gmshModelGeoAddVertex(t[3], 0, .3, 0, lc);
gmshModelGeoAddLine(t[0], 1, 2);
gmshModelGeoAddLine(t[1], 3, 2);
gmshModelGeoAddLine(t[2], 3, 4);
gmshModelGeoAddLine(t[3], 4, 1);
std::vector<int> l = {4, 1, -2, 3};
gmshModelGeoAddLineLoop(t[0], l);
std::vector<int> ll = {1};
gmshModelGeoAddPlaneSurface(t[0], ll);
std::vector<int> p1 = {1, 2};
gmshModelAddPhysicalGroup(0, 1, p1);
std::vector<int> p2 = {1, 2};
gmshModelAddPhysicalGroup(1, 2, p2);
std::vector<int> p3 = {1};
gmshModelAddPhysicalGroup(2, 6, p3);
int o;
gmshModelGeoAddVertex(1, 0, 0, 0, o, lc);
gmshModelGeoAddVertex(2, .1, 0, 0, o, lc);
gmshModelGeoAddVertex(3, .1, .3, 0, o, lc);
gmshModelGeoAddVertex(4, 0, .3, 0, o, lc);
gmshModelGeoAddLine(1, 1, 2, o);
gmshModelGeoAddLine(2, 3, 2, o);
gmshModelGeoAddLine(3, 3, 4, o);
gmshModelGeoAddLine(4, 4, 1, o);
gmshModelGeoAddLineLoop(1, {4, 1, -2, 3}, o);
gmshModelGeoAddPlaneSurface(1, {1}, o);
gmshModelAddPhysicalGroup(0, 1, {1, 2});
gmshModelAddPhysicalGroup(1, 2, {1, 2});
gmshModelAddPhysicalGroup(2, 6, {1});
gmshModelSetPhysicalName(2, 6, "My surface");
gmshModelGeoSynchronize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment