create a compsolid out of two boxes

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
bernd
Veteran
Posts: 12686
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

create a compsolid out of two boxes

Post by bernd »

jmaustpc wrote: ... OCE has an item concept of "compsolid". It is like a compound except that the solids in the compound share a single face.

How do I create a compsolid out of two boxes in FreeCAD ?

EDIT: For later reference some links in the regard of CompSolids

OCCT
http://opencascade.blogspot.ch/2009/02/ ... de_27.html
http://www.opencascade.com/content/compsolid-two-solids
https://mail.gna.org/public/pythonocc-u ... 00209.html

GMSH
http://www.geuz.org/pipermail/gmsh/2016/010267.html

FreeCAD:
viewtopic.php?t=5113&start=10#p40380 (similar too: viewtopic.php?f=8&t=13830&start=30#p111073 seams not a valid CompSolid inside FreeCAD 0.16.6214 )
viewtopic.php?f=22&t=13895
viewtopic.php?t=11899
Last edited by bernd on Wed Jan 20, 2016 1:18 pm, edited 3 times in total.
User avatar
yorik
Founder
Posts: 13074
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: create a compsolid out of two boxes

Post by yorik »

Interesting, I had never fully understood the compsolid concept :)
I think it's not implemented in FreeCAD so far..
User avatar
bernd
Veteran
Posts: 12686
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: create a compsolid out of two boxes

Post by bernd »

That would be a pity. At the moment what I need is a BREP of a compsolid which should look like the one in the screen. FreeCAD file attached. There is not much at the internet about compsolids. I found just the link in the first post.
compsolid_wanted.FCStd
(7.36 KiB) Downloaded 83 times
screen.jpg
screen.jpg (192.91 KiB) Viewed 4568 times

EDIT: for reference the brep of the compsolid_wanted exported from tandersons FreeCAD file
compsolid.brep
(31.02 KiB) Downloaded 263 times
Last edited by bernd on Wed Jan 13, 2016 7:01 am, edited 2 times in total.
User avatar
tanderson69
Veteran
Posts: 1591
Joined: Thu Feb 18, 2010 1:07 am

Re: create a compsolid out of two boxes

Post by tanderson69 »

if you can get 2 faces in a shell, you can run the shell through part extrude and make a compsolid. Leave the 'create solid' check box UNchecked. Curious to here what you are doing and how it works out. Compsolids are not supported in booleans operations, so they don't seem very useful to me.
CompSolid.png
CompSolid.png (34.74 KiB) Viewed 4550 times
Attachments
compsolid_wanted_ta2.FCStd
(10.41 KiB) Downloaded 79 times
User avatar
bernd
Veteran
Posts: 12686
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: create a compsolid out of two boxes

Post by bernd »

tanderson69 wrote:Curious to here what you are doing and how it works out. Compsolids are not supported in booleans operations, so they don't seem very useful to me.
Wow thanks very much. For FEM analysis 3D tetrahedral meshes are needed. If the part to analyse has different materials none of the tetrahedral mesh elements should cut the contact faces. Means nodes should be on the contact face. Now meshing software GMSH comes in here but this is the case for all open source mesher around. In a compound the contact faces are two faces. One from each solid. The meshing software will make one big glued mesh but the mesh will be not connected at the contact face because of the two faces. If the contact face is planar the meshing software (GMSH) can remove the duplicate faces and glue the mesh together at the contact face but not in case of curved faces. Here comes the compsolid in. If a BREP of a compsolid is passed to GMSH it works (thanks again for providing the compsolid for testing :D ) the mesh is glued and none mesh element cuts the contact face. Attached an FreeCAD FEM file with two materials and a simple tension calculation. Results are included for testing without ccx installed.
FEM_compsolid.fcstd
(63.65 KiB) Downloaded 109 times
Ahh thanks to Jim for is hint in viewtopic.php?t=10846&start=30

Mhh next step. Is it possible to create a compsolid out of two solids or out of a bound of faces like a shere in a cube. Attache another FreeCAD file and a screen.
cube_sphere.fcstd
(3.8 KiB) Downloaded 62 times
screen2.jpg
screen2.jpg (129.57 KiB) Viewed 4533 times
Last edited by bernd on Wed Jan 13, 2016 7:00 am, edited 2 times in total.
User avatar
tanderson69
Veteran
Posts: 1591
Joined: Thu Feb 18, 2010 1:07 am

Re: create a compsolid out of two boxes

Post by tanderson69 »

ah yes. I forgot. The last guy in here asking about compsolids was doing fem also.
bernd wrote:Mhh next step. Is it possible to create a compsolid out of two solids or out of a bound of faces like a shere in a cube. Attache another FreeCAD file and a screen.
I don't know a way to do it in freecad. It probably is possible in occt drawexe, but it wasn't obvious too me.
User avatar
tanderson69
Veteran
Posts: 1591
Joined: Thu Feb 18, 2010 1:07 am

Re: create a compsolid out of two boxes

Post by tanderson69 »

Give this a shot. I made it with the following code. If it works, maybe you can duplicate it with pythonOCC. Or make a feature request and link to this thread.

Code: Select all

 TopoDS_Solid box = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(10.0, 10.0, 10.0)).Solid();
	TopoDS_Solid sphere = BRepPrimAPI_MakeSphere(gp_Pnt(5.0, 5.0, 5.0), 3.0).Solid();
	BRepAlgoAPI_Cut cutter(box, sphere);
	TopoDS_Solid cut = TopoDS::Solid(Utilities::getFirstType(cutter.Shape(), TopAbs_SOLID));
	
	TopoDS_CompSolid compSolid;
	TopoDS_Builder cBuilder;
	cBuilder.MakeCompSolid(compSolid);
	cBuilder.Add(compSolid, cut);
	cBuilder.Add(compSolid, sphere);

        Utilities::dbusClient()->newDocument("Doc");
        Utilities::dbusClient()->addBrep(QString::fromStdString("Doc"), QString::fromStdString("Box"), Utilities::shapeBrep(box));
        Utilities::dbusClient()->addBrep(QString::fromStdString("Doc"), QString::fromStdString("Sphere"), Utilities::shapeBrep(sphere));
        Utilities::dbusClient()->addBrep(QString::fromStdString("Doc"), QString::fromStdString("Cut"), Utilities::shapeBrep(cut));
        Utilities::dbusClient()->addBrep(QString::fromStdString("Doc"), QString::fromStdString("CompSolid"), Utilities::shapeBrep(compSolid));
CompSolid2.png
CompSolid2.png (45.53 KiB) Viewed 4508 times
Attachments
compsolid_wanted_ta3.FCStd
(5.91 KiB) Downloaded 59 times
User avatar
DeepSOIC
Veteran
Posts: 7873
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: create a compsolid out of two boxes

Post by DeepSOIC »

I just want to tell, I'm interested in compsolids too. One particular situation, what I'd like to have compsolids, is joinfeatures. I'd love to have an operation, that fuses two solids as shells, and outputs the result as a compsolid. That can be later filtered, and joined into one solid quickly and efficiently. Now, Part JoinConnect is doing five booleans in a row, which makes it veeeeerrryyyy slow.
wmayer
Founder
Posts: 19219
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: create a compsolid out of two boxes

Post by wmayer »

In Python:

Code: Select all

box=Part.makeBox(10,10,10)
sphere=Part.makeSphere(3,App.Vector(5,5,5))
cut=box.cut(sphere)
compSolid = Part.CompSolid([cut.Solids[0],sphere])
Part.show(compSolid)
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: create a compsolid out of two boxes

Post by teobo »

Hi,
even though I see how a compsolid works, (thanks to the preposters and thanks to bernd for pursuing the question)
do not understand the great advantage of a compsolid over a compound, yet. There is a check implied that the "links" of this compound have common faces? That all?
I do not know what is more effort:
Keep it in might or remember a new word for it? (The former I guess)

Well, should not be that difficult to convert a compound to compsolid neither..
Post Reply