Author Topic: console mesages  (Read 242 times)

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
console mesages
« on: 2020-09-08, 15:59:24 »
Hi,
Trying to tune up some code, making it more succint, to put in my library, and I find that it often does not complete execution. It seems often to struggle with tori. Below is the typical console message I get.
Code: [Select]
1796 > "C:\Program Files\AngelCAD\xcsg.exe" --csg --dxf --stl --svg --fullpath "C:\Users\Ray\Desktop\AngelCad\xcsg\handwheel2.xcsg"
xcsg processing: C:/Users/Ray/Desktop/AngelCad/xcsg/handwheel2.xcsg
processing solid: difference3d
...completed CSG tree: 21 boolean operations to process.
...starting boolean operations
...boolean progress: 9.5%
...boolean progress: 19%
...Info: rotate_extrude angle>=2*PI implies a torus
...boolean progress: 28.5%
...boolean progress: 38%
...boolean progress: 47.6%
...Info: rotate_extrude angle>=2*PI implies a torus
...boolean progress: 57.1%
...boolean progress: 66.6%
...Info: rotate_extrude angle>=2*PI implies a torus


playing with some values, or adjusting secant_tolerance may allow it to complete, but more often it stalls somewhere else. Is it possible to give more detail in the console messages, as to where in the script it may be failing? I comment out sections, etc., to try and find the error, but when perhaps I have a function that works most of the time, but sometimes when it is called, it stops, is it the function in error, or the calling that is the cause of failure? Alter the function, chances are it will not work where once it worked before.

edit, adjusted secant tolerance, and got this, as last two lines.
Code: [Select]
...Info: rotate_extrude angle>=2*PI implies a torus
xcsg finished with exception: (carve error): D:\cpde_dep\3rdparty\carve\lib\intersect_face_division.cpp:587  "implement me"

which most likely is a clue.
« Last Edit: 2020-09-08, 16:05:21 by raymw »

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: console mesages
« Reply #1 on: 2020-09-08, 20:55:18 »
I scrapped what i was doing, or at least the way i was trying to do it, and came up with this (part of a generic wheel creator I am thinking about). It produces rounded ends on tubes, and can be extended for straight slabs, too. The secret is in the polygon shape. The one shape allows inside and outside ends of a tube to be rounded. It seems quite robust, for once, for me. Instead of the polygon, then a square at 45deg, would chamfer the ends. Obvious limits in the relationship between the fillet diameter and inside diameter of the tube using this
Code: [Select]
/ AngelCAD code.

//
// rounds tube ends


double rimod=50;// rim od
double rimid=8;//rim id
double rimthick=48;// rim thickness
double round =10;// diameter of fillet

solid@ rim( double h, double od,double id)
 {
    return cylinder (h,od/2)-cylinder(h,id/2);
   
  }

 shape2d@ corner_poly(double filletdiam,double bigdiameter)
 {  // generates polygon for rounding corners
     double  r= filletdiam/2;
     double br= bigdiameter/2;
     shape2d@  block = square(2*r);
     @block = block - translate(0,2*r)*circle(r);
     @block = block - translate(0,0)*circle(r);
     @block = block - translate(2*r,0)*circle(r);
     @block = block - translate(2*r,2*r)*circle(r);
     return translate(br,0)*translate(-r,-r)*block;
     return block;
 }
 
 
 solid@ round_over(double filletdiam, double circlediam)
 {
    shape2d@ poly = corner_poly(filletdiam,circlediam);
    solid@ curv = rotate_extrude(poly,360,0);
    @curv = rotate_x(90)*translate(0,filletdiam,0)*curv ;
    return translate(0,0,-filletdiam)*curv;
 }
 
 
shape@ main_shape()
{
  solid@ os = rim(rimthick,rimod,rimid);
 @os = os - round_over(round,rimod); //bottom outside
 @os = os - translate(0,0,rimthick)*round_over(round,rimod); //top outside
 @os = os - round_over(round,rimid); //bottom inside
 @os = os - translate(0,0,rimthick)*round_over(round,rimid); //top inside
 return os;

}

void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:.001);
}

Carsten Arnholm

  • Administrator
  • Newbie
  • *****
  • Posts: 45
    • View Profile
Re: console mesages
« Reply #2 on: 2020-09-08, 22:38:02 »

edit, adjusted secant tolerance, and got this, as last two lines.
Code: [Select]
...Info: rotate_extrude angle>=2*PI implies a torus
xcsg finished with exception: (carve error): D:\cpde_dep\3rdparty\carve\lib\intersect_face_division.cpp:587  "implement me"

which most likely is a clue.

Yes, things like this happen from time to time, although I have not seen that one before. AngelCAD uses the Carve library internally, and sometimes that fails. Apparently you found something that isn't fully implemented. Carve is great and much faster than CGAL, but it does act up sometimes. Usually a failure like this can be tweaked by slight redesign, or taking a different approach as you did.  I may have a look at that piece of code and see if there is anything I can do.

Whan Carve fails it either throws an exception, then you get a proper message. But it happens that it fails withouth an error message and that can leave you wondering, I agree.
« Last Edit: 2020-09-08, 22:39:53 by Carsten Arnholm »

Carsten Arnholm

  • Administrator
  • Newbie
  • *****
  • Posts: 45
    • View Profile
Re: console mesages
« Reply #3 on: 2020-09-08, 22:44:19 »
I scrapped what i was doing, or at least the way i was trying to do it, and came up with this (part of a generic wheel creator I am thinking about). It produces rounded ends on tubes, and can be extended for straight slabs, too. The secret is in the polygon shape. The one shape allows inside and outside ends of a tube to be rounded. It seems quite robust, for once, for me. Instead of the polygon, then a square at 45deg, would chamfer the ends. Obvious limits in the relationship between the fillet diameter and inside diameter of the tube using this


This is a great example, well done! It is a clever way of making rounded ends! I attached an image of your result. If you use a less aggressive secant_tolerance it runs much faster without compromising the result very much.

Code: [Select]
void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:.01);
}
« Last Edit: 2020-09-08, 22:45:56 by Carsten Arnholm »

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: console mesages
« Reply #4 on: 2020-09-09, 00:34:16 »
I thought i had completed the handwheel project of mine. It produces an stl file that renders well in meshlab, but Cura, Slic3er and IceSlicer can not slice it properly- they each give different but wrong results. The saga continues..

Carsten Arnholm

  • Administrator
  • Newbie
  • *****
  • Posts: 45
    • View Profile
Re: console mesages
« Reply #5 on: 2020-09-09, 07:07:02 »
run it through polyfix and see if it says anything useful,

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: console mesages
« Reply #6 on: 2020-09-09, 16:08:14 »
I've not heard of polyfix, but will try it. Anyway, I found the problem area, and resolved it, but not before I'd produced a print that fell apart when I lifted it from the print bed. (It looked OK in the slicer.)
Code: [Select]
// AngelCAD code.

// makes a spoked handwheel

double bore =8.2;// bore
double shaft=20;//shaft od
double shaftlen=40;//shaft length
double borelen=25;//bore length
double rimod=50;// rim od
double rimid=38;//rim id
double rimthick=8;// rim thickness
double spokes=5;//no of spokes
double fixloc=8;//fix location from boss end
double fixdiam=2;//fix diam
double grips=12;//number of grips
double round =3.5;// diameter of fillet


solid@ rim(double h,double d2,double d1, double rc)
{
// get tube
  solid@ arim= cylinder (h,d2/2) - cylinder(h,d1/2);
//fillet inside
 return arim;
}


solid@ aspoke(double t,double d, double n, double ch)
// get spoke
{
   double thick = (t-ch)*0.5; //spoke width
// make quarter spoke with rounded edge
// use offset, radius ch/2 of square for profile, then extrude
    solid@ spr= linear_extrude(offset2d(square(thick),r:ch/2),(d+(t))/2);
    solid@ spk = translate(0,-(thick/2),thick+ch/2)*rotate_y(90)*spr;
// rotate and add spokes
     array <solid@> total;
     for (int j=1;j<n+1;j++)
     {
        solid@ rotsp = rotate_z(j*360/n)* spk;
        total.push_back(rotsp);
     }
     return union3d(total);
}
 
 solid@ grip(double t,double d, double n)
// puts n balls on circle of diameter d. ball diameter is t
{
  array <solid@> balls;
 
 for (int j=1;j<=n;j++)
   {
    solid@ rotb = rotate_z(j*360/n)*translate(d/2,0,t/2)*sphere((t)*0.8/2);
    balls.push_back(rotb);
   }
   return union3d(balls);
}
 
  shape2d@ corner_poly(double filletdiam,double bigdiameter)
 {
 // generates polygon for rounding corners of tubes
     double  r= filletdiam/2;
     double br= bigdiameter/2;
     shape2d@  block = square(2*r);
     @block = block - translate(0,2*r)*circle(r);
     @block = block - translate(0,0)*circle(r);
     @block = block - translate(2*r,0)*circle(r);
     @block = block - translate(2*r,2*r)*circle(r);
     return translate(br,0)*translate(-r,-r)*block;
     return block;
 }
 
 
 solid@ round_over(double filletdiam, double circlediam)
 {// makes the profile to be subtracted from square ends
    shape2d@ poly = corner_poly(filletdiam,circlediam);
    solid@ curv = rotate_extrude(poly,360,0);
    @curv = rotate_x(90)*translate(0,filletdiam,0)*curv ;
    return translate(0,0,-filletdiam)*curv;
 }
 

 
 solid@ rwboss(double sl,double sd,double bl, double bo,double fixl, double fixd, double ch)
 // calc centre boss with fix hole
{
   solid@ shf=cylinder(sl,sd/2)-translate(0,0, sl-bl)*cylinder( bl, bo/2);
 //fixing  hole
    solid@ fix = rotate_y(90)*cylinder(sd*8,fixd/2);
    return shf  - translate(-sd*3,0,sl-fixl)*fix ;
 

   
shape@ main_shape()
{
  solid@ os=rim(rimthick,rimod,rimid, round);
  solid@ gripper =translate(0,0,0)*grip(rimthick,rimod,grips); 
  // fillet bottom of rim
  @os=os + gripper;
  @os = os - round_over(round,rimod);
  @os = os - round_over(round,rimid);
 
  //fillet top of rim
  @os = os - translate(0,0,rimthick)*round_over(round,rimod);;
  @os = os - translate(0,0,rimthick)*round_over(round,rimid);;
  @os=os + gripper;
// get shaft
   solid@ shft = rwboss(shaftlen,shaft, borelen,bore,fixloc,fixdiam,round);
   @shft= shft -round_over(round,shaft);
// bigger radius at shaft end   
   @shft = shft - translate(0,0,shaftlen)* round_over(round*2,shaft);
// get spokes
  solid@ spk = aspoke(rimthick,rimid,spokes,round);
 
 return os + spk + shft ;
 
}

void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:.01);
}

The above code works. Previous version  problem was caused by the gripper balls diameter, and the order the handwheel was assembled. If the spheres were big, they did not merge properly with the rounded edge of the rim, and although everything looked fine in meshlab, and on the slicer, it looked good enough to print, but the object was not watertight. The spheres need to be less than the flat area of the rim to be certain it builds correctly, but in some situations they can be a bit larger. I'm pretty sure there are other combinations that fail, too.

Carsten Arnholm

  • Administrator
  • Newbie
  • *****
  • Posts: 45
    • View Profile
Re: console mesages
« Reply #7 on: 2020-09-09, 16:54:16 »
I've not heard of polyfix, but will try it.

Polyfix is part of your angelcad installation, it is a console program. You find it in the same folder as AngelCAD is installed (you also find dxfread there). I recommend you set up the system PATH to include the AngelCAD installation folder.

usage: polyfix [-verbose] [-maxiter <str>] [-dtol <str>] [-atol <str>] [-lumps] [-nflip] [-remesh <str>] [-overwrite]
[-out <str>] [-zip] <input_filename>
 -verbose              Verbose messages
 -maxiter=<str>        [heal]          Max iterations (def=10)
 -dtol=<str>           [heal]          Distance tolerance (def=1.0E-2)
 -atol=<str>           [heal]          Area tolerance (def=1.0E-6)
 -lumps                [heal]          Split into lumps (not supported for stl output)
 -nflip                [heal]          Flip faces with inward normals (experimental)
 -remesh=<str>         [remesh]        Heal & remesh surfaces to given edge length (set dtol to small value ~1.E-6)
 -overwrite            [output]        allow file overwrite, including input file.
 -out=<str>            [output]        output filename/format (.obj, .off, .amf, .stl, .astl)
 -zip                  [output]        save output also to compressed zip file