tag:blogger.com,1999:blog-3285677929777490656.post5149875276706432876..comments2023-10-31T13:16:01.375+03:00Comments on Open CASCADE notes: Standard allocator interface.Roman Lyginhttp://www.blogger.com/profile/18338419158437898791noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-3285677929777490656.post-51070743024795941852012-10-06T21:17:34.671+04:002012-10-06T21:17:34.671+04:00Hmm I didn't know about this.Hmm I didn't know about this.Shahana Shafiuddinhttps://www.blogger.com/profile/06801040505340305472noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-36759936223553521502012-04-04T00:46:45.845+04:002012-04-04T00:46:45.845+04:00Thanks a ton for replying.
The reply might be a b...Thanks a ton for replying.<br /><br><br />The reply might be a bit long but please bear with me.<br /><br><br />So, a bit on what I am trying to do<br />I want to create a Cylinder *face*, triangulate it, <br />cut it with other *surfaces* (planar, cylindrical, conical, ...).<br /><br><br />As a first step <br />Step 1) I create a Cylindrical face and then <br />bound it using a bounding box. <br /><br><br />Step 2) The way I do it is I create a bounding box with the given bounds and then complement the bounding box and then subtract the complemented box from the face I created in step 1. <br><br />** I notice that if I create even a simple planar face in step 1 and then perform step 2 on it - it gives me a face with an improper wire order (so wither there is something seriously wrong with the boolean cut operation or with the code that I have written) I have pasted the code at the end (snippet 1)<br /><br><br />Step 3) Triangulation<br /><br />If I use the API that you suggested I observe that<br />it fails while triangulating for the case where I create a complete cylinder (0 to 2*PI) for other value it behaves fine. No clue why that should happen<br /><br /><br />--<br />The only thing that robustly worked so far is to create the cylindrical surface using BRepPrimAPI_MakeRevol. The only issue I faced with this API is it always creates an outer cylinder ((surface geometry) and sometimes I want to reverse it - I could not figure out a way to reverse the sursurface (->VReverse) as well as modify the topology so as to make sure that the inside and outside are consistent with what they were before the surface reversal.<br /><br />I am not sure if any of that made sense to you but I have a very strong feeling that there is somewhere some bug in OpenCascade -<br /><br />As a very simple thing - I created a box and the wires on the box come out as *out of order* to start with. Why would that happen?? (Code snippet 2)<br />Is that I am doing something seriously wrong??<br /><br />And though I agree that this the way I listed above is a very round about way - but I would still want to know why is the order coming wrong. I would be more than happy if you throw some light on it.<br /><br /><br />Code snippet 1:<br />test_face_trimming_with_bounding_box(TopoDS_Face aShape)<br />{<br /> gp_Pnt min(-50, -50, -50);<br /> gp_Pnt max(50, 50, 50);<br /><br /> gp_Pnt minO(-5000, -5000, -5000);<br /> gp_Pnt maxO(5000, 5000, 5000);<br /><br /> BRepPrimAPI_MakeBox inner(min, max);<br /> inner.Build();<br /> TopoDS_Solid aInnerBox = inner.Solid();<br /><br /> BRepPrimAPI_MakeBox outer(minO, maxO);<br /> outer.Build();<br /> TopoDS_Solid aOuterBox = outer.Solid();<br /> <br /> BRepAlgoAPI_Cut aSub(aOuterBox, aInnerBox);<br /> aSub.Build();<br /> const TopoDS_Shape& aOutBoxWithHole = aSub.Shape();<br /><br /> TopoDS_Face splitFace;<br /> BRepAlgoAPI_Cut aCut(aShape, aOutBoxWithHole);<br /> aCut.Build();<br /> for (TopExp_Explorer iter(aCut.Shape(), TopAbs_FACE); iter.More(); iter.Next())<br /> {<br /> //expecting a single face<br /> splitFace = TopoDS::Face(iter.Current());<br /> }<br />}<br /><br />Code snippet 2:<br /><br />test_bounding_box()<br />{<br /> gp_Pnt min(-50, -50, -50);<br /> gp_Pnt max(50, 50, 50);<br /> <br /> BRepPrimAPI_MakeBox aBox(minPt, maxPt);<br /> aBox.Build();<br /> const TopoDS_Solid& aSolid = aBox.Solid();<br /> <br /> for (TopExp_Explorer it(aSolid, TopAbs_WIRE);<br /> it.More(); it.Next())<br /> {<br /> double precision = 1e-04;<br /> ShapeAnalysis_Wire saw(aWire, *aParentFace, precision);<br /> if (saw.CheckOrder())<br /> {<br /> throw exception("Wire not ordered");<br /> }<br /> }<br />}<br /><br />Thanks again.Kapilhttps://www.blogger.com/profile/04253329700317125170noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-9529909477819592222012-04-03T20:59:46.026+04:002012-04-03T20:59:46.026+04:00Hi Kapil,
Why wouldn't you just do this strai...Hi Kapil,<br /><br />Why wouldn't you just do this straightforward:<br /><br />TopoDS_Face aFace = BRepBuilderAPI_MakeFace (new Geom_CylindricalSurface (gp_Ax3 (P, V, Vx), radius), 0, 2 * PI, 0, height); //Vx is perpendicular to V and defines X axis<br /><br />Hope this helps !<br />RomanRoman Lyginhttps://www.blogger.com/profile/18338419158437898791noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-64253731854573679472012-04-03T20:42:09.211+04:002012-04-03T20:42:09.211+04:00Hi Roman,
I have been stuck with this problem sin...Hi Roman,<br /><br />I have been stuck with this problem since past two weeks - All I wanted to do was to create a simple cylindrical face.<br /><br />So, the way I chose to do this is create a Solid cylinder and extract the cylindrical face.<br />Then I tried some simple checks and I notice that the Wire order is not proper - how is that possible - Opencascade is creating something that is invalid to start with !!!!!<br /><br />Could you please help me out with this - I will really appreciate any time you spend on this. I need this real desparately, I tried seeking help on the forum, raised a bug with opencascade but no help yet. <br /><br />// code<br /><br /> double radius = 2;<br /> double height = 1600;<br /> gp_Pnt P(0, 0, 0);<br /> gp_Vec V(0, 0, 1);<br /> V.Normalize();<br /> TopoDS_Solid solidCylinder = kernel->CreateSolidCylinder(P, V, radius, height);<br /><br /> // explore the solid and gets its faces<br /> //kernel->AnalyzeFace(cylface, 0, true);<br /> TopoDS_Face cylindricalFace;<br /> for (TopExp_Explorer it(solidCylinder, TopAbs_FACE);<br /> it.More(); it.Next())<br /> {<br /> const TopoDS_Face &aFace = TopoDS::Face(it.Current());<br /> const Handle(Geom_Surface) &aSurface = BRep_Tool::Surface(aFace);<br /> if (aSurface->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface))<br /> {<br /> cylindricalFace = aFace;<br /> break;<br /> }<br /> }<br /><br />for (TopExp_Explorer it(cylindricalFace, TopAbs_WIRE); <br /> it.More(); it.Next())<br />{<br /> const TopoDS_Wire& aWire = TopoDS::Wire(it.Current());<br /> double precision = 1e-04;<br /> ShapeAnalysis_Wire saw(aWire,cylindricalFace, precision); <br /> if(saw.CheckOrder())<br /> throw exception("Not expecting this");<br />}<br />//code endsKapilhttps://www.blogger.com/profile/04253329700317125170noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-34891249175397511162011-11-27T23:51:28.579+04:002011-11-27T23:51:28.579+04:00Thank you and Denis Barbier for fix and integratin...Thank you and Denis Barbier for fix and integrating it!<br />Performance and memory footprint benefits heavily depend on a workload where both OCC and standard mechanisms are mixed. I have not created a synthetic case to show it but the following explanation should give an idea.<br />If the code intensively uses both, then there can be extra footprint given that standard containers allocate memory outside of OCC mechanism (when using OCC or TBB allocator), which meanwhile can hoard memory without using it. <br />Performance penalties (from standard allocation) may come from two sources: a). fragmentation, which may appear during intensive allocation/deallocation of objects via standard allocator; b). multi-threaded environment where standard allocator uses a central coarse-grain lock causing threads to wait for each other. When using TBB allocator both issues are addressed, when using OCC - #a is addressed, while #b remains.Roman Lyginhttps://www.blogger.com/profile/18338419158437898791noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-57461792819345339632011-11-27T22:39:06.907+04:002011-11-27T22:39:06.907+04:00The fix has been pushed to the OCE repositoy.
By ...The fix has been pushed to the OCE repositoy.<br /><br />By the way, you write that "Using common memory allocation mechanism allows to decrease memory footprint and/or increase performance". What should we expect from your patch in terms of performance/memory footprint? Did you measure any significant improvement?Thomas Paviothttps://www.blogger.com/profile/00126734528767422573noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-21463495733324497322011-11-27T15:52:36.180+04:002011-11-27T15:52:36.180+04:00Hi Thomas, thanks for reporting this and sorry for...Hi Thomas, thanks for reporting this and sorry for the trouble. I only verified compilation with VS2008 as was traveling with a notebook.<br />Will try to look into the issue and provide a fix.<br />RomanRoman Lyginhttps://www.blogger.com/profile/18338419158437898791noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-90167667721056437312011-11-27T15:46:48.374+04:002011-11-27T15:46:48.374+04:00Hi Roman, there is a compile error on OSX/gcc-4.2....Hi Roman, there is a compile error on OSX/gcc-4.2.1 (see https://github.com/tpaviot/oce/issues/204)Thomas Paviothttps://www.blogger.com/profile/00126734528767422573noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-38823977139560168712011-11-26T10:09:32.530+04:002011-11-26T10:09:32.530+04:00As mentioned above, click the links. Then push the...As mentioned above, click the links. Then push the download buttons.Roman Lyginhttps://www.blogger.com/profile/18338419158437898791noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-11838152042121109992011-11-25T18:11:30.833+04:002011-11-25T18:11:30.833+04:00The referred files (Standard_StdAllocator.hxx ...)...The referred files (Standard_StdAllocator.hxx ...) are broken.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-20434662358363144152011-11-25T16:12:12.735+04:002011-11-25T16:12:12.735+04:00Hi Thomas,
Please just go to the page following th...Hi Thomas,<br />Please just go to the page following the url's and click the Download buttons. That should work.<br />Otherwise - download from the OCC thread http://www.opencascade.org/org/forum/thread_22234/.Roman Lyginhttps://www.blogger.com/profile/18338419158437898791noreply@blogger.comtag:blogger.com,1999:blog-3285677929777490656.post-35997327430496251262011-11-25T12:58:36.702+04:002011-11-25T12:58:36.702+04:00Thanks Roman for this very interesting post and yo...Thanks Roman for this very interesting post and your contribution. However, it seems there is an issue with the repository you used. I'm able to download hxx/cxx files, but they appear to be some kind of html code, nothing to do with C++ code.Thomas Paviothttps://www.blogger.com/profile/00126734528767422573noreply@blogger.com