You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having difficulty creating a solid out of a shell. I wanted to use this functionality to create a socalled icosphere or geodesic dome. I used some code that I found on the internet to create these shapes. To create an icosphere with a certain subdivision level you have to start with an icosahedron. I created all faces using the standard Polygon() function of CascadeStudio. Then I sewed all faces to a shell. I confirmed that the shell is closed. Then I tried to create a solid out of the closed shell using oc.BRepBuilderAPI_MakeSolid(). After this I checked that indeed a solid was created.
The following scene shows my result. I get a shape that I can scale and translate. The scene contains three shapes, namely a box, a sphere and the icosphere. All three shapes are identified as solids (ShapeType()=2). A boolean operation between the box and the sphere works, but if you uncomment the last line in my code, containing a boolean of the icosphere with the resulting shape, the icosphere disappears.
What am I doing wrong?
// icospheresfunctionProjectSphere(radius,vertex)// function to project a vertex on to a sphere with radius "radius"{letx=vertex[0];lety=vertex[1];letz=vertex[2];letcurrentRadius=Math.sqrt(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2))letscale=radius/currentRadius;letscaledVertex=[scale*x,scale*y,scale*z]returnscaledVertex}functionIcosahedron(radius){letgolden=(1+Math.sqrt(5))/2letv=[]// vertices determined by 4 rectanglesv[0]=ProjectSphere(radius,[-1,golden,0]);v[1]=ProjectSphere(radius,[1,golden,0]);v[2]=ProjectSphere(radius,[-1,-golden,0]);v[3]=ProjectSphere(radius,[1,-golden,0]);v[4]=ProjectSphere(radius,[0,-1,golden]);v[5]=ProjectSphere(radius,[0,1,golden]);v[6]=ProjectSphere(radius,[0,-1,-golden]);v[7]=ProjectSphere(radius,[0,1,-golden]);v[8]=ProjectSphere(radius,[golden,0,-1]);v[9]=ProjectSphere(radius,[golden,0,1]);v[10]=ProjectSphere(radius,[-golden,0,-1]);v[11]=ProjectSphere(radius,[-golden,0,1]);// faces added so that they always have an edge in common// with the previous onesletf=[]f[0]=[v[0],v[11],v[5]]f[1]=[v[0],v[5],v[1]]f[2]=[v[0],v[10],v[11]]f[3]=[v[0],v[7],v[10]]f[4]=[v[5],v[11],v[4]]f[5]=[v[4],v[9],v[5]]f[6]=[v[3],v[9],v[4]]f[7]=[v[3],v[8],v[9]]f[8]=[v[3],v[6],v[8]]f[9]=[v[3],v[2],v[6]]f[10]=[v[6],v[2],v[10]]f[11]=[v[10],v[7],v[6]]f[12]=[v[8],v[6],v[7]]f[13]=[v[0],v[1],v[7]]f[14]=[v[1],v[5],v[9]]f[15]=[v[11],v[10],v[2]]f[16]=[v[7],v[1],v[8]]f[17]=[v[3],v[4],v[2]]f[18]=[v[2],v[4],v[11]]f[19]=[v[9],v[8],v[1]]// create polygons/faces out of the 20 * three vertices// and sew them together to a closed shellleticosphere=newoc.BRepBuilderAPI_Sewing()for(leti=0;i<=19;i++){face=Polygon(f[i])icosphere.Add(face)sceneShapes.pop(face)// to avoid that Polygon() puts faces in the scene}icosphere.Perform()letsewedsphere=icosphere.SewedShape()console.log(sewedsphere.ShapeType())// check type 3 (shell) of the resultconsole.log(sewedsphere.Closed())// check if the shell is closed (true)// create a solidletresult=newoc.BRepBuilderAPI_MakeSolid()result.Add(sewedsphere)letfinalresult=result.Solid()console.log(finalresult.ShapeType())returnfinalresult}// draw the isospherelettest=Icosahedron(2.0);test=Scale(50,test,false)test=Translate([20,20,220],test,false)console.log(test.ShapeType())// draw a boxletbox=Box(200,200,200)console.log(box.ShapeType())// draw a standard sphereletstudioSphere=Translate([50,30,20],Sphere(100))console.log(studioSphere.ShapeType())box=Difference(box,[studioSphere])// let experiment = Difference(box,[test])
The problem is causeb by the Scale command. If we chose a bigger radius, and do not apply the Scale command, the code works.
Why?
I reproduced the problem with a simpler example. The Scale command might have issues.
The problem has nothing to do with the icospheres (size of radius, rounding error). If the scale factor equals 1, the result might be good.
Might also be caused by the size of the radius? Something like rounding errors? So what happens if you use an even larger radius and scale the shape down? Or scale with factor 1? Then we would know for sure that the Scale function is the culprit.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am having difficulty creating a solid out of a shell. I wanted to use this functionality to create a socalled icosphere or geodesic dome. I used some code that I found on the internet to create these shapes. To create an icosphere with a certain subdivision level you have to start with an icosahedron. I created all faces using the standard Polygon() function of CascadeStudio. Then I sewed all faces to a shell. I confirmed that the shell is closed. Then I tried to create a solid out of the closed shell using oc.BRepBuilderAPI_MakeSolid(). After this I checked that indeed a solid was created.
The following scene shows my result. I get a shape that I can scale and translate. The scene contains three shapes, namely a box, a sphere and the icosphere. All three shapes are identified as solids (ShapeType()=2). A boolean operation between the box and the sphere works, but if you uncomment the last line in my code, containing a boolean of the icosphere with the resulting shape, the icosphere disappears.
What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions