J
jpmendes
Fri, Dec 18, 2015 7:02 PM
Hi,
I was playing with the code bellow to generate some "toroidal sections".
When I was trying to figure how to open the closed surface of one of the
"toroids" in the picture, I blindly changed the signs of the operations in
the commented line marked with an arrow (<==) , first line after
"difference" in module "ToroidSections".
What happen then was chaotic. In about 30 seconds I completely loose the
control of the PC. The audio stopped, couldn't start the task manager, the
mouse was inoperative and the hard disk went crazy, using the swap area, I
suppose. For a moment I thought that someone had taken control of my
machine remotely. The only solution, was the power off button. After a new
start-up, then with the task manager opened, I made a new run to check if
it was a memory problem. What I saw was the pc memory being consumed
exponentially in a matter of seconds, fortunately I manage to kill the
openscad process in time.
Some other times , with other codes, I've seen console warnings reporting
that the cache is not enough for the rendered modules, but this time no
warning was issued.
I thing this is not good. OpenSCAD should have a way to limit the memory
usage. I have only 4GB in my machine + 4 GB swap .
My OpenSCAD ( 2015.03-2) memory settings in preferences are:
Turn off rendering at 100000 elements
CGAL cache size = 104857600 bytes
PolySet cache size=104857600 bytes
I think this is the the default, I don't remember to have it changed ever.
Dear developers please think in a way to avoid similar situations. OpenSCAD
is increasing its popularity and it is normal for a non experienced math guy
using it, to make some mistakes, due to the lack of enough knowledge or
comprehension of the principles behind the generation of a model.
Thanks.
http://forum.openscad.org/file/n15214/Capture.jpg
The code:
//
---==============================
DefaultFaces=24;
module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
if (EndAngle2-StartAngle2<360){
NSides= (Faces < 3 || Faces==undef) ? DefaultFaces : Faces;
n=floor((EndAngle2-StartAngle2)/120);
Sect1=EndAngle2-StartAngle2-n*120;
Sect2= (n>0) ? 120 : 0;
Sect3=(n>1) ? 120 : 0;
intersection(){
rotate_extrude(, $fn=floor(NSides*360/(EndAngle2-StartAngle2)))
translate([CenterShift,0,0])
children();
union(){
hull(){
translate([0,0,-2*Height]){
rotate(StartAngle2) cube([0.1, 3*Dout, 4*Height]);
rotate((StartAngle2+Sect1)) cube([0.1, 3*Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1)) cube([0.1, 3Dout, 4Height]);
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3Dout,
4Height]);
rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3Dout,
4*Height]);
}
}
}
}
} else { echo("Only rotations less than 360 degrees are supported");}
}
//Examples:
//translate([30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=3);
//translate([-30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=5);
//Left rotation
//TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
//Right rotation
//translate([0,30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
//Complementary right rotation
//translate([0,-30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
// Complementary right rotation
//translate([0,-60,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
//
---==============================
module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
CenterShift=Din/2;
Tube_Sect (Height,Dout,Din, CenterShift,StartAngle,EndAngle,Faces) {
square ([(Dout-Din)/2,Height]);
}
}
//
---==============================
module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
Height=D2;
CenterShift=D1/2+Aperture;
Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
translate([0,0,10]) scale([1, D2/D1])
circle(d=D1);
}
}
//TorusSection (D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
//
---===============================
module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
Fcs_a, Fcs_b) render() {
// or whatever it is ... I'm not a math guy.
difference() {
//TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
StartA-0.001), EndA, Fcs_a); <==
// The line above is dangerous in this context.
TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001 :
StartA+0.001), EndA, Fcs_a);
TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)? EndA+0.001 :
EndA-0.001), Fcs_b);
}
}
ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
translate([0,100.0])
ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
translate([0,-150,0])
ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
translate([-200,0,0])
ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
translate([-200,150,0])
ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
translate([-200,-150,0])
ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
//
---===============================
jpmendes
--
View this message in context: http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Hi,
I was playing with the code bellow to generate some "toroidal sections".
When I was trying to figure how to open the closed surface of one of the
"toroids" in the picture, I blindly changed the signs of the operations in
the commented line marked with an arrow (<==) , first line after
"difference" in module "ToroidSections".
What happen then was chaotic. In about 30 seconds I completely loose the
control of the PC. The audio stopped, couldn't start the task manager, the
mouse was inoperative and the hard disk went crazy, using the swap area, I
suppose. For a moment I thought that someone had taken control of my
machine remotely. The only solution, was the power off button. After a new
start-up, then with the task manager opened, I made a new run to check if
it was a memory problem. What I saw was the pc memory being consumed
exponentially in a matter of seconds, fortunately I manage to kill the
openscad process in time.
Some other times , with other codes, I've seen console warnings reporting
that the cache is not enough for the rendered modules, but this time no
warning was issued.
I thing this is not good. OpenSCAD should have a way to limit the memory
usage. I have only 4GB in my machine + 4 GB swap .
My OpenSCAD ( 2015.03-2) memory settings in preferences are:
Turn off rendering at 100000 elements
CGAL cache size = 104857600 bytes
PolySet cache size=104857600 bytes
I think this is the the default, I don't remember to have it changed ever.
Dear developers please think in a way to avoid similar situations. OpenSCAD
is increasing its popularity and it is normal for a non experienced math guy
using it, to make some mistakes, due to the lack of enough knowledge or
comprehension of the principles behind the generation of a model.
Thanks.
<http://forum.openscad.org/file/n15214/Capture.jpg>
The code:
//===============================================================
DefaultFaces=24;
module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
if (EndAngle2-StartAngle2<360){
NSides= (Faces < 3 || Faces==undef) ? DefaultFaces : Faces;
n=floor((EndAngle2-StartAngle2)/120);
Sect1=EndAngle2-StartAngle2-n*120;
Sect2= (n>0) ? 120 : 0;
Sect3=(n>1) ? 120 : 0;
intersection(){
rotate_extrude(, $fn=floor(NSides*360/(EndAngle2-StartAngle2)))
translate([CenterShift,0,0])
children();
union(){
hull(){
translate([0,0,-2*Height]){
rotate(StartAngle2) cube([0.1, 3*Dout, 4*Height]);
rotate((StartAngle2+Sect1)) cube([0.1, 3*Dout,
4*Height]);
}
}
hull(){
translate([0,0,-2*Height]){
rotate((StartAngle2+Sect1)) cube([0.1, 3*Dout, 4*Height]);
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3*Dout,
4*Height]);
}
}
hull(){
translate([0,0,-2*Height]){
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3*Dout,
4*Height]);
rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3*Dout,
4*Height]);
}
}
}
}
} else { echo("Only rotations less than 360 degrees are supported");}
}
//Examples:
//translate([30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=3);
//translate([-30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=5);
//Left rotation
//TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
//Right rotation
//translate([0,30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
//Complementary right rotation
//translate([0,-30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
// Complementary right rotation
//translate([0,-60,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
//===============================================================
module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
CenterShift=Din/2;
Tube_Sect (Height,Dout,Din, CenterShift,StartAngle,EndAngle,Faces) {
square ([(Dout-Din)/2,Height]);
}
}
//===============================================================
module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
Height=D2;
CenterShift=D1/2+Aperture;
Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
translate([0,0,10]) scale([1, D2/D1])
circle(d=D1);
}
}
//TorusSection (D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
//================================================================
module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
Fcs_a, Fcs_b) render() {
// or whatever it is ... I'm not a math guy.
difference() {
//TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
StartA-0.001), EndA, Fcs_a); <==
// The line above is dangerous in this context.
TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001 :
StartA+0.001), EndA, Fcs_a);
TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)? EndA+0.001 :
EndA-0.001), Fcs_b);
}
}
ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
translate([0,100.0])
ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
translate([0,-150,0])
ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
translate([-200,0,0])
ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
translate([-200,150,0])
ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
translate([-200,-150,0])
ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
//================================================================
jpmendes
--
View this message in context: http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
DM
doug moen
Fri, Dec 18, 2015 11:14 PM
This happened to me last week, but I didn't power off the PC. I just quit
OpenSCAD then went away for an hour and waited for the PC to settle down
and stop accessing the swap.
I don't think you need such a complex program to reproduce the problem. Too
many polygons was my problem. If you set $fn=1000 then do CSG operations on
spheres, you could probably reproduce it in a few lines of code. :-)
Okay, I just tested a solution for this. Disable your swap on Windows 7. I
wrote an OpenSCAD program to consume infinite memory, and I watched the
task manager window as OpenSCAD's memory consumption kept rising. Then
Windows popped up a dialog informing me that it was low on memory and it
was killing OpenSCAD. At no point did the mouse freeze or any of those
other bad things you reported.
On 18 December 2015 at 14:02, jpmendes jpmendes54@gmail.com wrote:
Hi,
I was playing with the code bellow to generate some "toroidal sections".
When I was trying to figure how to open the closed surface of one of the
"toroids" in the picture, I blindly changed the signs of the operations in
the commented line marked with an arrow (<==) , first line after
"difference" in module "ToroidSections".
What happen then was chaotic. In about 30 seconds I completely loose the
control of the PC. The audio stopped, couldn't start the task manager, the
mouse was inoperative and the hard disk went crazy, using the swap area, I
suppose. For a moment I thought that someone had taken control of my
machine remotely. The only solution, was the power off button. After a
new
start-up, then with the task manager opened, I made a new run to check if
it was a memory problem. What I saw was the pc memory being consumed
exponentially in a matter of seconds, fortunately I manage to kill the
openscad process in time.
Some other times , with other codes, I've seen console warnings reporting
that the cache is not enough for the rendered modules, but this time no
warning was issued.
I thing this is not good. OpenSCAD should have a way to limit the memory
usage. I have only 4GB in my machine + 4 GB swap .
My OpenSCAD ( 2015.03-2) memory settings in preferences are:
Turn off rendering at 100000 elements
CGAL cache size = 104857600 bytes
PolySet cache size=104857600 bytes
I think this is the the default, I don't remember to have it changed ever.
Dear developers please think in a way to avoid similar situations. OpenSCAD
is increasing its popularity and it is normal for a non experienced math
guy
using it, to make some mistakes, due to the lack of enough knowledge or
comprehension of the principles behind the generation of a model.
Thanks.
http://forum.openscad.org/file/n15214/Capture.jpg
The code:
//
---==============================
DefaultFaces=24;
module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
if (EndAngle2-StartAngle2<360){
NSides= (Faces < 3 || Faces==undef) ? DefaultFaces :
Faces;
n=floor((EndAngle2-StartAngle2)/120);
Sect1=EndAngle2-StartAngle2-n*120;
Sect2= (n>0) ? 120 : 0;
Sect3=(n>1) ? 120 : 0;
intersection(){
rotate_extrude(,
$fn=floor(NSides*360/(EndAngle2-StartAngle2)))
translate([CenterShift,0,0])
children();
union(){
hull(){
translate([0,0,-2*Height]){
rotate(StartAngle2) cube([0.1,
3Dout, 4Height]);
rotate((StartAngle2+Sect1))
cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1))
cube([0.1, 3Dout, 4Height]);
rotate((StartAngle2+Sect1+Sect2))
cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1+Sect2))
cube([0.1, 3Dout,
4Height]);
rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3Dout,
4Height]);
}
}
}
}
} else { echo("Only rotations less than 360 degrees are
supported");}
}
//Examples:
//translate([30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=3);
//translate([-30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=5);
//Left rotation
//TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
//Right rotation
//translate([0,30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
//Complementary right rotation
//translate([0,-30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
// Complementary right rotation
//translate([0,-60,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
//
---==============================
module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
CenterShift=Din/2;
Tube_Sect (Height,Dout,Din, CenterShift,StartAngle,EndAngle,Faces)
{
square ([(Dout-Din)/2,Height]);
}
}
//
---==============================
module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
Height=D2;
CenterShift=D1/2+Aperture;
Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
translate([0,0,10]) scale([1, D2/D1])
circle(d=D1);
}
}
//TorusSection
(D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
//
---===============================
module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
Fcs_a, Fcs_b) render() {
// or whatever it is ... I'm not a math guy.
difference() {
//TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
StartA-0.001), EndA, Fcs_a); <==
// The line above is dangerous in this context.
TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001 :
StartA+0.001), EndA, Fcs_a);
TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)?
EndA+0.001 :
EndA-0.001), Fcs_b);
}
}
ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
translate([0,100.0])
ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
translate([0,-150,0])
ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
translate([-200,0,0])
ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
translate([-200,150,0])
ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
translate([-200,-150,0])
ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
//
---===============================
jpmendes
--
View this message in context:
http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
This happened to me last week, but I didn't power off the PC. I just quit
OpenSCAD then went away for an hour and waited for the PC to settle down
and stop accessing the swap.
I don't think you need such a complex program to reproduce the problem. Too
many polygons was my problem. If you set $fn=1000 then do CSG operations on
spheres, you could probably reproduce it in a few lines of code. :-)
Okay, I just tested a solution for this. Disable your swap on Windows 7. I
wrote an OpenSCAD program to consume infinite memory, and I watched the
task manager window as OpenSCAD's memory consumption kept rising. Then
Windows popped up a dialog informing me that it was low on memory and it
was killing OpenSCAD. At no point did the mouse freeze or any of those
other bad things you reported.
On 18 December 2015 at 14:02, jpmendes <jpmendes54@gmail.com> wrote:
>
> Hi,
>
> I was playing with the code bellow to generate some "toroidal sections".
> When I was trying to figure how to open the closed surface of one of the
> "toroids" in the picture, I blindly changed the signs of the operations in
> the commented line marked with an arrow (<==) , first line after
> "difference" in module "ToroidSections".
> What happen then was chaotic. In about 30 seconds I completely loose the
> control of the PC. The audio stopped, couldn't start the task manager, the
> mouse was inoperative and the hard disk went crazy, using the swap area, I
> suppose. For a moment I thought that someone had taken control of my
> machine remotely. The only solution, was the power off button. After a
> new
> start-up, then with the task manager opened, I made a new run to check if
> it was a memory problem. What I saw was the pc memory being consumed
> exponentially in a matter of seconds, fortunately I manage to kill the
> openscad process in time.
>
> Some other times , with other codes, I've seen console warnings reporting
> that the cache is not enough for the rendered modules, but this time no
> warning was issued.
> I thing this is not good. OpenSCAD should have a way to limit the memory
> usage. I have only 4GB in my machine + 4 GB swap .
>
> My OpenSCAD ( 2015.03-2) memory settings in preferences are:
>
> Turn off rendering at 100000 elements
> CGAL cache size = 104857600 bytes
> PolySet cache size=104857600 bytes
>
> I think this is the the default, I don't remember to have it changed ever.
>
> Dear developers please think in a way to avoid similar situations. OpenSCAD
> is increasing its popularity and it is normal for a non experienced math
> guy
> using it, to make some mistakes, due to the lack of enough knowledge or
> comprehension of the principles behind the generation of a model.
>
> Thanks.
>
> <http://forum.openscad.org/file/n15214/Capture.jpg>
>
> The code:
>
>
> //===============================================================
> DefaultFaces=24;
> module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
>
> StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
> EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
> EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
> StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
>
> if (EndAngle2-StartAngle2<360){
>
> NSides= (Faces < 3 || Faces==undef) ? DefaultFaces :
> Faces;
> n=floor((EndAngle2-StartAngle2)/120);
> Sect1=EndAngle2-StartAngle2-n*120;
> Sect2= (n>0) ? 120 : 0;
> Sect3=(n>1) ? 120 : 0;
>
> intersection(){
> rotate_extrude(,
> $fn=floor(NSides*360/(EndAngle2-StartAngle2)))
> translate([CenterShift,0,0])
> children();
>
> union(){
> hull(){
> translate([0,0,-2*Height]){
> rotate(StartAngle2) cube([0.1,
> 3*Dout, 4*Height]);
> rotate((StartAngle2+Sect1))
> cube([0.1, 3*Dout,
> 4*Height]);
> }
> }
> hull(){
> translate([0,0,-2*Height]){
> rotate((StartAngle2+Sect1))
> cube([0.1, 3*Dout, 4*Height]);
> rotate((StartAngle2+Sect1+Sect2))
> cube([0.1, 3*Dout,
> 4*Height]);
> }
> }
> hull(){
> translate([0,0,-2*Height]){
> rotate((StartAngle2+Sect1+Sect2))
> cube([0.1, 3*Dout,
> 4*Height]);
>
> rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3*Dout,
> 4*Height]);
> }
> }
> }
> }
> } else { echo("Only rotations less than 360 degrees are
> supported");}
>
> }
> //Examples:
> //translate([30,0,0])
> //Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
> Faces=3);
> //translate([-30,0,0])
> //Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
> Faces=5);
>
> //Left rotation
> //TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
> //Right rotation
> //translate([0,30,0])
>
> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
> //Complementary right rotation
> //translate([0,-30,0])
>
> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
> // Complementary right rotation
> //translate([0,-60,0])
> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
>
> //===============================================================
>
> module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
>
> CenterShift=Din/2;
> Tube_Sect (Height,Dout,Din, CenterShift,StartAngle,EndAngle,Faces)
> {
> square ([(Dout-Din)/2,Height]);
> }
> }
> //===============================================================
>
> module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
> Height=D2;
> CenterShift=D1/2+Aperture;
> Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
> translate([0,0,10]) scale([1, D2/D1])
> circle(d=D1);
> }
> }
>
> //TorusSection
> (D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
>
> //================================================================
>
>
> module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
> Fcs_a, Fcs_b) render() {
> // or whatever it is ... I'm not a math guy.
>
> difference() {
> //TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
> StartA-0.001), EndA, Fcs_a); <==
> // The line above is dangerous in this context.
> TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001 :
> StartA+0.001), EndA, Fcs_a);
> TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)?
> EndA+0.001 :
> EndA-0.001), Fcs_b);
> }
> }
>
> ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
> translate([0,100.0])
> ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
> translate([0,-150,0])
> ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
> translate([-200,0,0])
> ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
> translate([-200,150,0])
> ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
> translate([-200,-150,0])
> ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
> //================================================================
>
>
> jpmendes
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
DM
doug moen
Fri, Dec 18, 2015 11:17 PM
I have two cores on my Windows machine. The CPU never went above 50%, since
OpenSCAD can't use more than one core, so the other core was available to
run explorer, task manager, etc. Maybe that's part of the reason why my
machine didn't freeze, once I had disabled swap.
On 18 December 2015 at 18:14, doug moen doug@moens.org wrote:
This happened to me last week, but I didn't power off the PC. I just quit
OpenSCAD then went away for an hour and waited for the PC to settle down
and stop accessing the swap.
I don't think you need such a complex program to reproduce the problem.
Too many polygons was my problem. If you set $fn=1000 then do CSG
operations on spheres, you could probably reproduce it in a few lines of
code. :-)
Okay, I just tested a solution for this. Disable your swap on Windows 7. I
wrote an OpenSCAD program to consume infinite memory, and I watched the
task manager window as OpenSCAD's memory consumption kept rising. Then
Windows popped up a dialog informing me that it was low on memory and it
was killing OpenSCAD. At no point did the mouse freeze or any of those
other bad things you reported.
On 18 December 2015 at 14:02, jpmendes jpmendes54@gmail.com wrote:
Hi,
I was playing with the code bellow to generate some "toroidal sections".
When I was trying to figure how to open the closed surface of one of the
"toroids" in the picture, I blindly changed the signs of the operations
in
the commented line marked with an arrow (<==) , first line after
"difference" in module "ToroidSections".
What happen then was chaotic. In about 30 seconds I completely loose the
control of the PC. The audio stopped, couldn't start the task manager, the
mouse was inoperative and the hard disk went crazy, using the swap area, I
suppose. For a moment I thought that someone had taken control of my
machine remotely. The only solution, was the power off button. After a
new
start-up, then with the task manager opened, I made a new run to check if
it was a memory problem. What I saw was the pc memory being consumed
exponentially in a matter of seconds, fortunately I manage to kill the
openscad process in time.
Some other times , with other codes, I've seen console warnings reporting
that the cache is not enough for the rendered modules, but this time no
warning was issued.
I thing this is not good. OpenSCAD should have a way to limit the memory
usage. I have only 4GB in my machine + 4 GB swap .
My OpenSCAD ( 2015.03-2) memory settings in preferences are:
Turn off rendering at 100000 elements
CGAL cache size = 104857600 bytes
PolySet cache size=104857600 bytes
I think this is the the default, I don't remember to have it changed ever.
Dear developers please think in a way to avoid similar situations.
OpenSCAD
is increasing its popularity and it is normal for a non experienced math
guy
using it, to make some mistakes, due to the lack of enough knowledge or
comprehension of the principles behind the generation of a model.
Thanks.
http://forum.openscad.org/file/n15214/Capture.jpg
The code:
//
---==============================
DefaultFaces=24;
module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
if (EndAngle2-StartAngle2<360){
NSides= (Faces < 3 || Faces==undef) ? DefaultFaces :
Faces;
n=floor((EndAngle2-StartAngle2)/120);
Sect1=EndAngle2-StartAngle2-n*120;
Sect2= (n>0) ? 120 : 0;
Sect3=(n>1) ? 120 : 0;
intersection(){
rotate_extrude(,
$fn=floor(NSides*360/(EndAngle2-StartAngle2)))
translate([CenterShift,0,0])
children();
union(){
hull(){
translate([0,0,-2*Height]){
rotate(StartAngle2) cube([0.1,
3Dout, 4Height]);
rotate((StartAngle2+Sect1))
cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1))
cube([0.1, 3Dout, 4*Height]);
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1+Sect2))
cube([0.1, 3Dout,
4*Height]);
rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3Dout,
4Height]);
}
}
}
}
} else { echo("Only rotations less than 360 degrees are
supported");}
}
//Examples:
//translate([30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=3);
//translate([-30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=5);
//Left rotation
//TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
//Right rotation
//translate([0,30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
//Complementary right rotation
//translate([0,-30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
// Complementary right rotation
//translate([0,-60,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
//
---==============================
module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
CenterShift=Din/2;
Tube_Sect (Height,Dout,Din,
CenterShift,StartAngle,EndAngle,Faces) {
square ([(Dout-Din)/2,Height]);
}
}
//
---==============================
module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
Height=D2;
CenterShift=D1/2+Aperture;
Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
translate([0,0,10]) scale([1, D2/D1])
circle(d=D1);
}
}
//TorusSection
(D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
//
---===============================
module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
Fcs_a, Fcs_b) render() {
// or whatever it is ... I'm not a math guy.
difference() {
//TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
StartA-0.001), EndA, Fcs_a); <==
// The line above is dangerous in this context.
TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001 :
StartA+0.001), EndA, Fcs_a);
TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)?
EndA+0.001 :
EndA-0.001), Fcs_b);
}
}
ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
translate([0,100.0])
ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
translate([0,-150,0])
ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
translate([-200,0,0])
ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
translate([-200,150,0])
ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
translate([-200,-150,0])
ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
//
---===============================
jpmendes
--
View this message in context:
http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
I have two cores on my Windows machine. The CPU never went above 50%, since
OpenSCAD can't use more than one core, so the other core was available to
run explorer, task manager, etc. Maybe that's part of the reason why my
machine didn't freeze, once I had disabled swap.
On 18 December 2015 at 18:14, doug moen <doug@moens.org> wrote:
> This happened to me last week, but I didn't power off the PC. I just quit
> OpenSCAD then went away for an hour and waited for the PC to settle down
> and stop accessing the swap.
>
> I don't think you need such a complex program to reproduce the problem.
> Too many polygons was my problem. If you set $fn=1000 then do CSG
> operations on spheres, you could probably reproduce it in a few lines of
> code. :-)
>
> Okay, I just tested a solution for this. Disable your swap on Windows 7. I
> wrote an OpenSCAD program to consume infinite memory, and I watched the
> task manager window as OpenSCAD's memory consumption kept rising. Then
> Windows popped up a dialog informing me that it was low on memory and it
> was killing OpenSCAD. At no point did the mouse freeze or any of those
> other bad things you reported.
>
> On 18 December 2015 at 14:02, jpmendes <jpmendes54@gmail.com> wrote:
>
>>
>> Hi,
>>
>> I was playing with the code bellow to generate some "toroidal sections".
>> When I was trying to figure how to open the closed surface of one of the
>> "toroids" in the picture, I blindly changed the signs of the operations
>> in
>> the commented line marked with an arrow (<==) , first line after
>> "difference" in module "ToroidSections".
>> What happen then was chaotic. In about 30 seconds I completely loose the
>> control of the PC. The audio stopped, couldn't start the task manager, the
>> mouse was inoperative and the hard disk went crazy, using the swap area, I
>> suppose. For a moment I thought that someone had taken control of my
>> machine remotely. The only solution, was the power off button. After a
>> new
>> start-up, then with the task manager opened, I made a new run to check if
>> it was a memory problem. What I saw was the pc memory being consumed
>> exponentially in a matter of seconds, fortunately I manage to kill the
>> openscad process in time.
>>
>> Some other times , with other codes, I've seen console warnings reporting
>> that the cache is not enough for the rendered modules, but this time no
>> warning was issued.
>> I thing this is not good. OpenSCAD should have a way to limit the memory
>> usage. I have only 4GB in my machine + 4 GB swap .
>>
>> My OpenSCAD ( 2015.03-2) memory settings in preferences are:
>>
>> Turn off rendering at 100000 elements
>> CGAL cache size = 104857600 bytes
>> PolySet cache size=104857600 bytes
>>
>> I think this is the the default, I don't remember to have it changed ever.
>>
>> Dear developers please think in a way to avoid similar situations.
>> OpenSCAD
>> is increasing its popularity and it is normal for a non experienced math
>> guy
>> using it, to make some mistakes, due to the lack of enough knowledge or
>> comprehension of the principles behind the generation of a model.
>>
>> Thanks.
>>
>> <http://forum.openscad.org/file/n15214/Capture.jpg>
>>
>> The code:
>>
>>
>> //===============================================================
>> DefaultFaces=24;
>> module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
>>
>> StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
>> EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
>> EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
>> StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
>>
>> if (EndAngle2-StartAngle2<360){
>>
>> NSides= (Faces < 3 || Faces==undef) ? DefaultFaces :
>> Faces;
>> n=floor((EndAngle2-StartAngle2)/120);
>> Sect1=EndAngle2-StartAngle2-n*120;
>> Sect2= (n>0) ? 120 : 0;
>> Sect3=(n>1) ? 120 : 0;
>>
>> intersection(){
>> rotate_extrude(,
>> $fn=floor(NSides*360/(EndAngle2-StartAngle2)))
>> translate([CenterShift,0,0])
>> children();
>>
>> union(){
>> hull(){
>> translate([0,0,-2*Height]){
>> rotate(StartAngle2) cube([0.1,
>> 3*Dout, 4*Height]);
>> rotate((StartAngle2+Sect1))
>> cube([0.1, 3*Dout,
>> 4*Height]);
>> }
>> }
>> hull(){
>> translate([0,0,-2*Height]){
>> rotate((StartAngle2+Sect1))
>> cube([0.1, 3*Dout, 4*Height]);
>>
>> rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3*Dout,
>> 4*Height]);
>> }
>> }
>> hull(){
>> translate([0,0,-2*Height]){
>> rotate((StartAngle2+Sect1+Sect2))
>> cube([0.1, 3*Dout,
>> 4*Height]);
>>
>> rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3*Dout,
>> 4*Height]);
>> }
>> }
>> }
>> }
>> } else { echo("Only rotations less than 360 degrees are
>> supported");}
>>
>> }
>> //Examples:
>> //translate([30,0,0])
>> //Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
>> Faces=3);
>> //translate([-30,0,0])
>> //Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
>> Faces=5);
>>
>> //Left rotation
>>
>> //TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
>> //Right rotation
>> //translate([0,30,0])
>>
>> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
>> //Complementary right rotation
>> //translate([0,-30,0])
>>
>> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
>> // Complementary right rotation
>> //translate([0,-60,0])
>> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
>>
>> //===============================================================
>>
>> module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
>>
>> CenterShift=Din/2;
>> Tube_Sect (Height,Dout,Din,
>> CenterShift,StartAngle,EndAngle,Faces) {
>> square ([(Dout-Din)/2,Height]);
>> }
>> }
>> //===============================================================
>>
>> module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
>> Height=D2;
>> CenterShift=D1/2+Aperture;
>> Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
>> translate([0,0,10]) scale([1, D2/D1])
>> circle(d=D1);
>> }
>> }
>>
>> //TorusSection
>> (D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
>>
>> //================================================================
>>
>>
>> module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
>> Fcs_a, Fcs_b) render() {
>> // or whatever it is ... I'm not a math guy.
>>
>> difference() {
>> //TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
>> StartA-0.001), EndA, Fcs_a); <==
>> // The line above is dangerous in this context.
>> TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001 :
>> StartA+0.001), EndA, Fcs_a);
>> TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)?
>> EndA+0.001 :
>> EndA-0.001), Fcs_b);
>> }
>> }
>>
>> ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
>> translate([0,100.0])
>> ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
>> translate([0,-150,0])
>> ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
>> translate([-200,0,0])
>> ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
>> translate([-200,150,0])
>> ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
>> translate([-200,-150,0])
>> ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
>> //================================================================
>>
>>
>> jpmendes
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>>
>
DM
doug moen
Fri, Dec 18, 2015 11:22 PM
Oh yeah, my program to kill OpenSCAD is:
$fn=1000;
difference() {
sphere(10);
cube(10);
}
On 18 December 2015 at 18:17, doug moen doug@moens.org wrote:
I have two cores on my Windows machine. The CPU never went above 50%,
since OpenSCAD can't use more than one core, so the other core was
available to run explorer, task manager, etc. Maybe that's part of the
reason why my machine didn't freeze, once I had disabled swap.
On 18 December 2015 at 18:14, doug moen doug@moens.org wrote:
This happened to me last week, but I didn't power off the PC. I just quit
OpenSCAD then went away for an hour and waited for the PC to settle down
and stop accessing the swap.
I don't think you need such a complex program to reproduce the problem.
Too many polygons was my problem. If you set $fn=1000 then do CSG
operations on spheres, you could probably reproduce it in a few lines of
code. :-)
Okay, I just tested a solution for this. Disable your swap on Windows 7.
I wrote an OpenSCAD program to consume infinite memory, and I watched the
task manager window as OpenSCAD's memory consumption kept rising. Then
Windows popped up a dialog informing me that it was low on memory and it
was killing OpenSCAD. At no point did the mouse freeze or any of those
other bad things you reported.
On 18 December 2015 at 14:02, jpmendes jpmendes54@gmail.com wrote:
Hi,
I was playing with the code bellow to generate some "toroidal sections".
When I was trying to figure how to open the closed surface of one of the
"toroids" in the picture, I blindly changed the signs of the operations
in
the commented line marked with an arrow (<==) , first line after
"difference" in module "ToroidSections".
What happen then was chaotic. In about 30 seconds I completely loose the
control of the PC. The audio stopped, couldn't start the task manager,
the
mouse was inoperative and the hard disk went crazy, using the swap area,
I
suppose. For a moment I thought that someone had taken control of my
machine remotely. The only solution, was the power off button. After a
new
start-up, then with the task manager opened, I made a new run to check
if
it was a memory problem. What I saw was the pc memory being consumed
exponentially in a matter of seconds, fortunately I manage to kill the
openscad process in time.
Some other times , with other codes, I've seen console warnings reporting
that the cache is not enough for the rendered modules, but this time no
warning was issued.
I thing this is not good. OpenSCAD should have a way to limit the
memory
usage. I have only 4GB in my machine + 4 GB swap .
My OpenSCAD ( 2015.03-2) memory settings in preferences are:
Turn off rendering at 100000 elements
CGAL cache size = 104857600 bytes
PolySet cache size=104857600 bytes
I think this is the the default, I don't remember to have it changed
ever.
Dear developers please think in a way to avoid similar situations.
OpenSCAD
is increasing its popularity and it is normal for a non experienced math
guy
using it, to make some mistakes, due to the lack of enough knowledge or
comprehension of the principles behind the generation of a model.
Thanks.
http://forum.openscad.org/file/n15214/Capture.jpg
The code:
//
---==============================
DefaultFaces=24;
module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
if (EndAngle2-StartAngle2<360){
NSides= (Faces < 3 || Faces==undef) ? DefaultFaces :
Faces;
n=floor((EndAngle2-StartAngle2)/120);
Sect1=EndAngle2-StartAngle2-n*120;
Sect2= (n>0) ? 120 : 0;
Sect3=(n>1) ? 120 : 0;
intersection(){
rotate_extrude(,
$fn=floor(NSides*360/(EndAngle2-StartAngle2)))
translate([CenterShift,0,0])
children();
union(){
hull(){
translate([0,0,-2*Height]){
rotate(StartAngle2) cube([0.1,
3Dout, 4Height]);
rotate((StartAngle2+Sect1))
cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2Height]){
rotate((StartAngle2+Sect1))
cube([0.1, 3Dout, 4*Height]);
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3Dout,
4Height]);
}
}
hull(){
translate([0,0,-2*Height]){
rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3Dout,
4Height]);
rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3Dout,
4Height]);
}
}
}
}
} else { echo("Only rotations less than 360 degrees are
supported");}
}
//Examples:
//translate([30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=3);
//translate([-30,0,0])
//Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
Faces=5);
//Left rotation
//TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
//Right rotation
//translate([0,30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
//Complementary right rotation
//translate([0,-30,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
// Complementary right rotation
//translate([0,-60,0])
//Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
//
---==============================
module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
CenterShift=Din/2;
Tube_Sect (Height,Dout,Din,
CenterShift,StartAngle,EndAngle,Faces) {
square ([(Dout-Din)/2,Height]);
}
}
//
---==============================
module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
Height=D2;
CenterShift=D1/2+Aperture;
Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
translate([0,0,10]) scale([1, D2/D1])
circle(d=D1);
}
}
//TorusSection
(D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
//
---===============================
module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
Fcs_a, Fcs_b) render() {
// or whatever it is ... I'm not a math guy.
difference() {
//TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
StartA-0.001), EndA, Fcs_a); <==
// The line above is dangerous in this context.
TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001
:
StartA+0.001), EndA, Fcs_a);
TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)?
EndA+0.001 :
EndA-0.001), Fcs_b);
}
}
ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
translate([0,100.0])
ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
translate([0,-150,0])
ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
translate([-200,0,0])
ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
translate([-200,150,0])
ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
translate([-200,-150,0])
ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
//
---===============================
jpmendes
--
View this message in context:
http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Oh yeah, my program to kill OpenSCAD is:
$fn=1000;
difference() {
sphere(10);
cube(10);
}
On 18 December 2015 at 18:17, doug moen <doug@moens.org> wrote:
> I have two cores on my Windows machine. The CPU never went above 50%,
> since OpenSCAD can't use more than one core, so the other core was
> available to run explorer, task manager, etc. Maybe that's part of the
> reason why my machine didn't freeze, once I had disabled swap.
>
> On 18 December 2015 at 18:14, doug moen <doug@moens.org> wrote:
>
>> This happened to me last week, but I didn't power off the PC. I just quit
>> OpenSCAD then went away for an hour and waited for the PC to settle down
>> and stop accessing the swap.
>>
>> I don't think you need such a complex program to reproduce the problem.
>> Too many polygons was my problem. If you set $fn=1000 then do CSG
>> operations on spheres, you could probably reproduce it in a few lines of
>> code. :-)
>>
>> Okay, I just tested a solution for this. Disable your swap on Windows 7.
>> I wrote an OpenSCAD program to consume infinite memory, and I watched the
>> task manager window as OpenSCAD's memory consumption kept rising. Then
>> Windows popped up a dialog informing me that it was low on memory and it
>> was killing OpenSCAD. At no point did the mouse freeze or any of those
>> other bad things you reported.
>>
>> On 18 December 2015 at 14:02, jpmendes <jpmendes54@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I was playing with the code bellow to generate some "toroidal sections".
>>> When I was trying to figure how to open the closed surface of one of the
>>> "toroids" in the picture, I blindly changed the signs of the operations
>>> in
>>> the commented line marked with an arrow (<==) , first line after
>>> "difference" in module "ToroidSections".
>>> What happen then was chaotic. In about 30 seconds I completely loose the
>>> control of the PC. The audio stopped, couldn't start the task manager,
>>> the
>>> mouse was inoperative and the hard disk went crazy, using the swap area,
>>> I
>>> suppose. For a moment I thought that someone had taken control of my
>>> machine remotely. The only solution, was the power off button. After a
>>> new
>>> start-up, then with the task manager opened, I made a new run to check
>>> if
>>> it was a memory problem. What I saw was the pc memory being consumed
>>> exponentially in a matter of seconds, fortunately I manage to kill the
>>> openscad process in time.
>>>
>>> Some other times , with other codes, I've seen console warnings reporting
>>> that the cache is not enough for the rendered modules, but this time no
>>> warning was issued.
>>> I thing this is not good. OpenSCAD should have a way to limit the
>>> memory
>>> usage. I have only 4GB in my machine + 4 GB swap .
>>>
>>> My OpenSCAD ( 2015.03-2) memory settings in preferences are:
>>>
>>> Turn off rendering at 100000 elements
>>> CGAL cache size = 104857600 bytes
>>> PolySet cache size=104857600 bytes
>>>
>>> I think this is the the default, I don't remember to have it changed
>>> ever.
>>>
>>> Dear developers please think in a way to avoid similar situations.
>>> OpenSCAD
>>> is increasing its popularity and it is normal for a non experienced math
>>> guy
>>> using it, to make some mistakes, due to the lack of enough knowledge or
>>> comprehension of the principles behind the generation of a model.
>>>
>>> Thanks.
>>>
>>> <http://forum.openscad.org/file/n15214/Capture.jpg>
>>>
>>> The code:
>>>
>>>
>>> //===============================================================
>>> DefaultFaces=24;
>>> module Tube_Sect(Height,Dout,Din,CenterShift,StartAngle,EndAngle,Faces) {
>>>
>>> StartAngle= (StartAngle < 0) ? 360+StartAngle : StartAngle;
>>> EndAngle= (EndAngle < 0) ? 360+EndAngle : EndAngle;
>>> EndAngle2 = (EndAngle < StartAngle) ? StartAngle : EndAngle;
>>> StartAngle2 = (EndAngle < StartAngle) ? EndAngle : StartAngle;
>>>
>>> if (EndAngle2-StartAngle2<360){
>>>
>>> NSides= (Faces < 3 || Faces==undef) ? DefaultFaces :
>>> Faces;
>>> n=floor((EndAngle2-StartAngle2)/120);
>>> Sect1=EndAngle2-StartAngle2-n*120;
>>> Sect2= (n>0) ? 120 : 0;
>>> Sect3=(n>1) ? 120 : 0;
>>>
>>> intersection(){
>>> rotate_extrude(,
>>> $fn=floor(NSides*360/(EndAngle2-StartAngle2)))
>>> translate([CenterShift,0,0])
>>> children();
>>>
>>> union(){
>>> hull(){
>>> translate([0,0,-2*Height]){
>>> rotate(StartAngle2) cube([0.1,
>>> 3*Dout, 4*Height]);
>>> rotate((StartAngle2+Sect1))
>>> cube([0.1, 3*Dout,
>>> 4*Height]);
>>> }
>>> }
>>> hull(){
>>> translate([0,0,-2*Height]){
>>> rotate((StartAngle2+Sect1))
>>> cube([0.1, 3*Dout, 4*Height]);
>>>
>>> rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3*Dout,
>>> 4*Height]);
>>> }
>>> }
>>> hull(){
>>> translate([0,0,-2*Height]){
>>>
>>> rotate((StartAngle2+Sect1+Sect2)) cube([0.1, 3*Dout,
>>> 4*Height]);
>>>
>>> rotate((StartAngle2+Sect1+Sect2+Sect3)) cube([0.1, 3*Dout,
>>> 4*Height]);
>>> }
>>> }
>>> }
>>> }
>>> } else { echo("Only rotations less than 360 degrees are
>>> supported");}
>>>
>>> }
>>> //Examples:
>>> //translate([30,0,0])
>>> //Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
>>> Faces=3);
>>> //translate([-30,0,0])
>>> //Tube_Sect(Height=20, Dout=30, Din=20, StartAngle=0, EndAngle=359.9999,
>>> Faces=5);
>>>
>>> //Left rotation
>>>
>>> //TubeSection(Height=40,Dout=20,Din=18,StartAngle=0,EndAngle=259,Faces=60);
>>> //Right rotation
>>> //translate([0,30,0])
>>>
>>> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=-259,Faces=20);
>>> //Complementary right rotation
>>> //translate([0,-30,0])
>>>
>>> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=-0.0001,EndAngle=259,Faces=20);
>>> // Complementary right rotation
>>> //translate([0,-60,0])
>>>
>>> //Tube_Sect(Height=40,Dout=20,Din=12,StartAngle=0,EndAngle=-259,Faces=20);
>>>
>>> //===============================================================
>>>
>>> module TubeSection(Height, Dout, Din, StartAngle, EndAngle, Faces) {
>>>
>>> CenterShift=Din/2;
>>> Tube_Sect (Height,Dout,Din,
>>> CenterShift,StartAngle,EndAngle,Faces) {
>>> square ([(Dout-Din)/2,Height]);
>>> }
>>> }
>>> //===============================================================
>>>
>>> module TorusSection( D1, D2, Aperture , StartAngle, EndAngle, Faces) {
>>> Height=D2;
>>> CenterShift=D1/2+Aperture;
>>> Tube_Sect (Height,D2,D1, CenterShift, StartAngle,EndAngle,Faces){
>>> translate([0,0,10]) scale([1, D2/D1])
>>> circle(d=D1);
>>> }
>>> }
>>>
>>> //TorusSection
>>> (D2=150,D1=60,Aperture=4,StartAngle=0,EndAngle=259,Faces=30);
>>>
>>> //================================================================
>>>
>>>
>>> module ToroidSections(D1_a,D1_b,D2_a, D2_b, Ap_a, Ap_b, StartA, EndA,
>>> Fcs_a, Fcs_b) render() {
>>> // or whatever it is ... I'm not a math guy.
>>>
>>> difference() {
>>> //TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA+0.001 :
>>> StartA-0.001), EndA, Fcs_a); <==
>>> // The line above is dangerous in this context.
>>> TorusSection (D2_a, D1_a, Ap_a, ((StartA<0)? StartA-0.001
>>> :
>>> StartA+0.001), EndA, Fcs_a);
>>> TorusSection (D2_b, D1_b, Ap_b, StartA, ((EndA>=0)?
>>> EndA+0.001 :
>>> EndA-0.001), Fcs_b);
>>> }
>>> }
>>>
>>> ToroidSections(160,150, 60,60, 4,5.2, 0,359.99, 60, 20);
>>> translate([0,100.0])
>>> ToroidSections(160,160, 60,60, 4,6, 0,359.99, 30,30);
>>> translate([0,-150,0])
>>> ToroidSections(158,160, 60,58, 4,3.9, 0,359.99, 30,30);
>>> translate([-200,0,0])
>>> ToroidSections(190,160, 60,40, 7,9, 0,180, 30,30);
>>> translate([-200,150,0])
>>> ToroidSections(190,160, 60,40, 7,9, -0.01,-180.01, 30,30);
>>> translate([-200,-150,0])
>>> ToroidSections(190,160, 60,40, 7,9, 30,-150, 30,30);
>>> //================================================================
>>>
>>>
>>> jpmendes
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214.html
>>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss@lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>>>
>>>
>>
>
J
jpmendes
Sat, Dec 19, 2015 12:15 AM
Thanks Doug,
I didn't know that OpenSCAD uses only one core. My machine have a CPU with
2 cores also. Now I have a way to keep my pc under control. There is in the
Net an useful little utility named prio.exe, when installed we can assign an
application to a core permanently.
My goal with the code I posted was not to test OpenSCAD. The situation
described happened by hazard.
Cheers,
jpmendes
--
View this message in context: http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214p15222.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Thanks Doug,
I didn't know that OpenSCAD uses only one core. My machine have a CPU with
2 cores also. Now I have a way to keep my pc under control. There is in the
Net an useful little utility named prio.exe, when installed we can assign an
application to a core permanently.
My goal with the code I posted was not to test OpenSCAD. The situation
described happened by hazard.
Cheers,
jpmendes
--
View this message in context: http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214p15222.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
J
jpmendes
Sat, Dec 19, 2015 1:18 AM
Hi Doug,
Setting the affinity of OpenSCAD to one processor didn't work, not even
lowering the process priority worked. The problem really is the memory swap.
If I wait enough time a window pop-pup appears requesting termination of the
application. For sure is the disk controller interrupting continuously the
CPU that causes the odd behavior. I have so little memory in my 10 year old
machine that I'm not thinking to disable the swap feature.
Thanks anyway.
jpmendes
--
View this message in context: http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214p15224.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Hi Doug,
Setting the affinity of OpenSCAD to one processor didn't work, not even
lowering the process priority worked. The problem really is the memory swap.
If I wait enough time a window pop-pup appears requesting termination of the
application. For sure is the disk controller interrupting continuously the
CPU that causes the odd behavior. I have so little memory in my 10 year old
machine that I'm not thinking to disable the swap feature.
Thanks anyway.
jpmendes
--
View this message in context: http://forum.openscad.org/Playing-with-code-and-loosing-the-control-of-the-PC-tp15214p15224.html
Sent from the OpenSCAD mailing list archive at Nabble.com.