star-cad

Geometric operators for computer-aided design
git clone git://git.meso-star.fr/star-cad.git
Log | Files | Refs | README | LICENSE

commit 56b1bbb7d4d02066b6004062ac56b9eb9f90cea1
parent 6043d88d66add96e661afc757cced6d94f752d3b
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date:   Mon, 21 Mar 2022 10:33:41 +0100

Extend scad_intersect to get common face

Diffstat:
Msrc/scad.c | 89++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 70 insertions(+), 19 deletions(-)

diff --git a/src/scad.c b/src/scad.c @@ -293,6 +293,43 @@ scad_intersect if (ierr != 0 ) {FATAL("Intersection not possible !\n"); goto error;} + + tagoutn = 0; + if (tagoutn == 0) { /* try instersect boundary to extract common face */ + int* bound1; + int* bound2; + size_t n1, n2; + + gmshModelGetBoundary(geom1, sa_size(geom1), + &bound1, &n1, + 1, + 0, + 0, + &ierr); + + /*if (ierr != 0) { */ + /*if (bound1) free(bound1};*/ + /*goto error:*/ + /*}*/ + + gmshModelGetBoundary(geom2, sa_size(geom2), + &bound2, &n2, + 1, + 0, + 0, + &ierr); + + gmshModelOccIntersect(bound1, n1, + bound2, n2, + &tagout, &tagoutn, + &map, &mapn, &mapnn, + -1, + NODELETE, + NODELETE, + &ierr); + } + + for (i=0; i<(int)tagoutn; ++i){ sa_push(*out, tagout[i]); } @@ -428,30 +465,44 @@ scad_stl_export(const scad_geom_T geom, char *prefix) size_t tagoutn; int group, dimtag[2]; - for (i=0; i<(int)sa_size(geom)/2; ++i) - { - gmshModelMeshSetOutwardOrientation(geom[2*i+1], &ierr); - } - - gmshModelGetBoundary(geom, sa_size(geom), - &tagout, &tagoutn, - 1, - 0, - 0, - &ierr); + if (geom[0] == 2) { + tagoutn = sa_size(geom); + for(i=0; i<(int)tagoutn/2; ++i){ + sa_push(tags, geom[2*i + 1]); + + } + + group = gmshModelAddPhysicalGroup(2, tags, tagoutn/2, + -1, + &ierr); + if (ierr !=0) goto error; + + } else { + + for (i=0; i<(int)sa_size(geom)/2; ++i) + { + gmshModelMeshSetOutwardOrientation(geom[2*i+1], &ierr); + } + + gmshModelGetBoundary(geom, sa_size(geom), + &tagout, &tagoutn, + 1, + 0, + 0, + &ierr); - if (ierr !=0) goto error; + if (ierr !=0) goto error; + for(i=0; i<(int)tagoutn/2; ++i){ + sa_push(tags, tagout[2*i + 1]); + } - for(i=0; i<(int)tagoutn/2; ++i){ - sa_push(tags, tagout[2*i + 1]); + group = gmshModelAddPhysicalGroup(2, tags, tagoutn/2, + -1, + &ierr); + if (ierr !=0) goto error; } - group = gmshModelAddPhysicalGroup(2, tags, tagoutn/2, - -1, - &ierr); - if (ierr !=0) goto error; - gmshWrite(prefix, &ierr); if (ierr !=0) goto error;