Extending a shell 25mm

Quaoar

Administrator
Staff member
Your original code works nicely on the part you attached:

1655313357957.png
Reversing the circle is probably not a solution to keep the pipe oriented properly. What is necessary to control is rather the normal field over a pipe:

1655313474994.png
You might wanna check how this normal field is oriented for the cases where your algorithm fails. If a pipe is oriented nicely, then the fault should be related to something else.
 

edoelas

CAD practitioner
I just checked it. Depending on how I create the pipe it works for some shapes but not for others. I will have to further investigate what is going on.
 

edoelas

CAD practitioner
I think I am going to try a new approach:
  1. Generate the extended surface
  2. Subtract the original surface to the extended surface
  3. Generate a solid pipe
  4. Generate a face by intersecting the solid pipe with the extended surface.
EDIT: Just discovered that subtracting the original surface to the extended surface is not enough to get rid of the inner offset. This happens when the width of the surface is smaller than 25mm. I will have to find a better way.
 
Last edited:

blobfish

CAD community veteran
The problem is that since the face can rotate and the square will not, the distance of the offset might not be constant. As far as I know there is no way to make the square rotate with the surface.
Maybe you already know, but sweeps can use a support face for calculating the profile binormal. Of course the binormals are calculated at the spine so the greater the offset and greater the surface curvature, the less accurate. Here is a picture and files of a line swept using a support face on the test_vase file.
 

Attachments

  • supportSweep.png
    supportSweep.png
    240.8 KB · Views: 5
  • profile.brep
    557 bytes · Views: 2
  • result.brep
    676 KB · Views: 2

blobfish

CAD community veteran
I have removed the unnecessary wires, but now I am facing a really weird problem I do not know how to solve. I am using BRepAlgoAPI_Section to check the intersection between the pipe and the face. Sometimes it works, but others it does not
If you run the test_vase through the bop algo check you get a whole bunch of invalid curve on surface errors. That might explain the wild results with the section algo.
 

Attachments

  • invalidCurveOnSurface.png
    invalidCurveOnSurface.png
    288.8 KB · Views: 6

edoelas

CAD practitioner
Maybe you already know, but sweeps can use a support face for calculating the profile binormal.
I was expecting this to be possible, but I could not find a class that allowed me to do it. Which class are you using to create the sweep? I might just sweep with a straight wire of 25mm length tangent to the surface. Of course, the resulting shape will be flat and not follow the curvature of the surface, but that's not a problem for my use case.

If you run the test_vase through the bop algo check you get a whole bunch of invalid curve on surface errors.
That file was generated using solidworks 2020. Just created the shell with loft, made some holes, and exported it to stp. I don't know what can be causing those problems. Hope shape healing can help with that.
 

blobfish

CAD community veteran
I was expecting this to be possible, but I could not find a class that allowed me to do it. Which class are you using to create the sweep?
BRepFill_PipeShell

That file was generated using solidworks 2020. Just created the shell with loft, made some holes, and exported it to stp. I don't know what can be causing those problems. Hope shape healing can help with that.
I believe all translations get run through shapefix by default, so I guess further involvement from shapefix won't help. The bopalgo check may indicate shortcomings from the algorithms themselves as apposed to actual problems with the data, so you have to keep that in mind.
 

edoelas

CAD practitioner
I am using BRepFill_PipeShell now and it works really well. It is faster, does not give as many problems as calculating the intersection and I have more control over what is going on. So far it hasn't crashed or anything like that. Also, as far as the wire and the faces are continuous, the offset is continuous. The only problem I am facing is that sometimes I get the inner offset instead of the outer offset, but probably that is because I am not handling the normals with enough care.

1655569246216.png

More testing is needed and I have seen some weird behaviour in some shapes, but this seems to be the right way to go. As soon as I have a properly working code I will uplaod it.
 

edoelas

CAD practitioner
Okay, I think I got what I need. This is the code I am using (with a few comments):

C++:
// Get edge's first vertex position
ShapeAnalysis_Edge edgeA = ShapeAnalysis_Edge();
gp_Pnt edgeVertex = BRep_Tool::Pnt(edgeA.FirstVertex(edge));

// Get edge normal on edgeVertex position
Handle(Geom_Curve) edgeCurve;
Standard_Real a, b;
edgeA.Curve3d(edge, edgeCurve, a, b);
GeomAPI_ProjectPointOnCurve pointProjection(edgeVertex, edgeCurve);
Standard_Real vertexU = pointProjection.LowerDistanceParameter();
gp_Pnt P;
gp_Vec edgeNormal;
edgeCurve->D1(vertexU, P, edgeNormal);

// Get face normal on edgeVertex position
const Handle(Geom_Surface)& surface = BRep_Tool::Surface(face);
ShapeAnalysis_Surface surfaceAnalysis(surface);
gp_Pnt2d edgeVertexUV = surfaceAnalysis.ValueOfUV(P, 0.01);
GeomLProp_SLProps props(surface, edgeVertexUV.X(), edgeVertexUV.Y(), 1, 0.01);
gp_Dir faceNormal = props.Normal();

// Reverse normals if needed
if (face.Orientation() == TopAbs_REVERSED)
    faceNormal.Reverse();

if (edge.Orientation() == TopAbs_REVERSED)
    edgeNormal.Reverse();

// Build profile
auto profileLine = gp_Lin(edgeVertex, edgeNormal.Crossed(faceNormal));
auto profileEdge = BRepBuilderAPI_MakeEdge(profileLine, 0, 25).Edge();
auto profileWire = BRepBuilderAPI_MakeWire(profileEdge).Wire();

// Build pipe
auto pipeBuilder = BRepFill_PipeShell(BRepBuilderAPI_MakeWire(edge).Wire());
pipeBuilder.Set(face);
pipeBuilder.Add(profileWire);
pipeBuilder.Build();
auto pipe = pipeBuilder.Shape();

_assembly->AddShape(pipe);

The only problem I have found with this code is that both the surface and the wire must be continuous. In the future, I will add a mechanism to connect the faces generated by non-continuous shapes.
 
Top