[OpenSCAD] unit testing based on # of volumes

Hans L thehans at gmail.com
Thu May 9 18:42:19 EDT 2019


Yep.  The inside of your geometries define one volume each, and infinite
void outside the geometry is the other volume.  That's just how CGAL
represents volumes.  In other words, "It's not a bug, its a feature" ;)

Hans

On Wed, May 8, 2019 at 6:07 PM Revar Desmera <revarbat at gmail.com> wrote:

> I believe the extra volume is that which is NOT bound by the part.  The
> perimeter of the part divides all space into 2 separate volumes.
>
> - Revar
>
>
> > On May 8, 2019, at 12:51 PM, Carsten Arnholm <arnholm at arnholm.org>
> wrote:
> >
> > On 08.05.2019 19:01, AdrianSchlatter wrote:
> >> My problem: OpenSCAD prints the number of volumes when run in GUI. I
> have
> >> not found a way to make it print that info on cmd line. Any ideas?
> >
> > The first problem seems to be that the number of volumes OpenSCAD prints
> is incorrect. For example
> >
> > cubes.scad
> > ---
> > n=5;
> > for(i=[1:n]) {
> >  echo(i);
> >  translate([i*20,0,0])cube(10);
> > }
> > ---
> >
> > You get 5 echoes, but in the GUI console it says
> >
> > Simple: yes
> > Vertices: 40
> > Halfedges: 120
> > Edges: 60
> > Halffacets: 60
> > Facets: 30
> > Volumes: 6
> > Rendering finished.
> >
> > So the number of volumes reported by OpenSCAD is off by one. Aside from
> that minor issue, you can use an external program to count the volumes in a
> machine-readable way if OpenSCAD can not do it.
> >
> > Here is one way to do it:
> >
> > Assuming the OS is Linux (similar for Windows), prepare 2 files in the
> same folder, a bash script and a minimal .as file.
> >
> > Note that the term 'lump' below is equivalent to OpenSCAD 'volume'.
> >
> > count_lumps.sh
> > ---
> > #!/bin/bash
> > openscad -o temp_file.off $1
> > as_csg ./count_lumps.as  > /dev/null
> > xcsg --stl temp_file.xcsg | grep lump
> > rm temp_file.*
> > ---
> >
> > count_lumps.as
> > ---
> > void main() {
> >   polyhedron("temp_file.off").write_xcsg("temp_file");
> > }
> > ---
> >
> > Run count_lumps.sh with OpenSCAD input
> >
> > $ ./count_lumps.sh cubes.scad
> > ECHO: 1
> > ECHO: 2
> > ECHO: 3
> > ECHO: 4
> > ECHO: 5
> > ...result model contains 5 lumps.
> > ...lump 1: 8 vertices, 12 polygon faces.
> > ...lump 2: 8 vertices, 12 polygon faces.
> > ...lump 3: 8 vertices, 12 polygon faces.
> > ...lump 4: 8 vertices, 12 polygon faces.
> > ...lump 5: 8 vertices, 12 polygon faces.
> >
> > What happens in the script is
> > 1. openscad generates .off file from .scad
> > 2. as_csg converts .off to .xcsg (silently)
> > 3. xcsg reads .xcsg and prints (filtered with grep here)
> > 4. Temporary files are removed (silently)
> >
> > If you skip piping to grep you get more detailed information. If you
> instead replace 'grep lump' with 'grep lumps' you get only the information
> you asked for:
> >
> > ...result model contains 5 lumps.
> >
> > as_csg and xcsg are installed with AngelCAD
> > https://github.com/arnholm/angelcad/releases
> >
> > Kind Regards
> > Carsten Arnholm
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > Discuss at lists.openscad.org
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190509/4e132a53/attachment.html>


More information about the Discuss mailing list