Wed, 06/05/2019 - 20:36
Forums:
Hi,
I'm completely new to Open Cascade. I would like to know if the SDK allows to write a code that automatically recognizes if some volume body has an extrudable shape.
If it recognizes a volume with extrudable shape, it should return the IDs of the source and targe surface that would represent the extrudable volume.
Mainly I only want to know if this is technically possible. If yes, I would start studying the SDK to see how it can be done.
Reason for this question is that this way we could automatically generate hexahedral meshing with GMSH, which uses Open Cascade.
Many thanks.
Alex
Wed, 06/05/2019 - 21:45
Hello,
This sort of problems is quite approachable with OpenCascade in principle. Can you provide an illustrative example of a shape (STEP or BREP format) which you want to decompose to volumes?
Sergey.
Wed, 06/05/2019 - 22:13
Thanks for replying. I want to make sure we are speaking of same thing. The question is not about "decompose volumes".
Take a simple cylinder, than you have your example. The algorithm should identify the first round surface as the source and the second round surface as the target.
Another example: A cube. Source is any of the six surfaces. Target is the opposite surface to the source.
All these examples have on thing in common. One can map all edges of source surface to all edges of target surface. The surfaces that connect the source and target surface contain at most four edges.
Wed, 06/05/2019 - 23:01
Here is what comes from the top of my head. You select (somehow) a source face which either a circle or a rectangle in your simple example. Then you take a normal vector pointing outwards the material (as you have a solid body), you reverse it, and find an intersection point which is assumed to be a point on the target face. Now you have a base face and a height in the normal direction so that you can sweep a prism. After that, in the simple case, you may subtract your original shape from the constructed prism. If the result is empty, you're probably done. This simple scenario may not work for more complex configurations when your extruded shape happens to be enclosed entirely within the analyzed body. Then you can go with a more tricky heuristic. E.g., you take a midpoint on every edge of the base face and shoot the same kind of ray inwards the material. After that, you classify whether all points of the ray lie ON (not IN, not OUT) the surface of the body in question. If yes, you are likely done. For the typical MCAD models, this approach looks quite enough, though it may not work for more sculptured parts. Alternatively, you may split your original body with the host surface of the found target face and subtract the extruded feature from the body (i.e., make a second cut using the candidate prism as a tool this time), then check if the result is empty again.
Whether this approach is sufficient or not, OpenCascade gives you plenty of shape interrogation methods which you can adopt for implementation of different geometric and topological heuristics.
Wed, 06/05/2019 - 23:44
Thank you. I think this is too much heuristic. I started writing down how the algorithm could look like and this is what came out:
I have no idea what OCC can do this:
Given a volume body with surfaces with IDs from 1 to N
First step is to find surface pairs that match by the number of edges and their topology:
Loop over all surfaces with ID1 from 1 to N-1
Loop over all surfaces with ID2 from ID1+1 to N
MatchSourceTarget(ID1,ID2)
If surfaces match, then remember surface pair P(i)=ID1-ID2
The function MatchSourceTarget (ID1,ID2) checks if all edges of ID1 can be mapped to all edges of ID2.
If number of edges of ID1 is not equal to number of edges of ID2 then ignore pair
If surfaces share common edges or vertices (touch), then ignore pair
If above conditions are not met, then surface pair is a candidate for match
Further checking is too complicated to describe here.
Last step is to filter out surface pairs that match, but their edge pairs belong to other surfaces, which have more than four edges in total.
Loop through all remembered surface pairs with ID P(i)
Loop through all edge pairs of this surface pair (number of edges is equal and source edges map 1-to-1 to target edges)
Find out which third surface contains this edge pair (cannot be except source or target surface)
If this third surface contains more than four edges in total, than ignore surface pair
Any remaining surface pairs is a valid candidate for source and target.
Thu, 06/06/2019 - 00:34
That looks like a pure topological approach, though, as practice shows, you can rarely end up with a working solution without geometric heuristics. At least, to check parallelism, surface types and dihedral angles can be a minimal gentleman's set to approach a feature recognition problem which is pretty much the field where you want to play.
Thu, 06/06/2019 - 00:39
Since I'm not a specialist in the field, how should I interpret your message? Can it be done with Open Cascade? Must I fear slow performance?
Thu, 06/06/2019 - 09:12
This is for sure possible. For the performance, it really depends more on the way how you write the code. Generally speaking, the topological approaches are much more efficient compared to geometry-only processing. But they are often not enough as I mentioned above because the topology is only a connectivity graph, without shape.
Since, as you say, you're not a specialist, you may want to go for the official support of OCC (there are plenty of options, like training, Q&A, customization of our tools, including feature recognition etc.). As practice shows, this support pays for itself.