For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Stitching

Jacques Coetzee's picture
Forums: 

Hello

I have imported an STL file into my program, but now I only have primitive vertices and triangles to work with.

Is it possible to stitch these primitive triangle faces together to form a higher level, more native, object within OCC?
I would like to get it as close as possible as if I have procedurally generated the object within OCC.
Ultimately when I am selecting a face on the pipe I imported, I would like to select the entire face and not a single triangle on that face.

Thanks in advance.
Jacques Coetzee

Jacques Coetzee's picture

Hello

Here is my code so far but I am not getting the desired effect:

Handle(StlMesh_Mesh) stlMesh = RWStl::ReadFile(aFile);

Standard_Integer nrDomains = stlMesh->NbDomains();

StlMesh_MeshExplorer meshExp (stlMesh);
BRepOffsetAPI_Sewing stitcher(1.0e-06, Standard_True, Standard_True, Standard_True, Standard_True);

for (int x = 1; x {
for (meshExp.InitTriangle (x); meshExp.MoreTriangle (); meshExp.NextTriangle ())
{
gp_XYZ p1, p2, p3;
Standard_Real x1, y1, z1;
Standard_Real x2, y2, z2;
Standard_Real x3, y3, z3;

meshExp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3);
p1.SetCoord(x1,y1,z1);
p2.SetCoord(x2,y2,z2);
p3.SetCoord(x3,y3,z3);

if (!p1.IsEqual(p2,0.0) && !p1.IsEqual(p3,0.0))
{
TopoDS_Vertex vertex1, vertex2, vertex3;

vertex1 = BRepBuilderAPI_MakeVertex(p1);
vertex2 = BRepBuilderAPI_MakeVertex(p2);
vertex3 = BRepBuilderAPI_MakeVertex(p3);

TopoDS_Wire wire = BRepBuilderAPI_MakePolygon(vertex1, vertex2, vertex3, Standard_True);

if(!wire.IsNull())
{
TopoDS_Face face = BRepBuilderAPI_MakeFace(wire);
stitcher.Add(face);
}
}
}
}

stitcher.Perform();
TopoDS_Shape sShape = stitcher.SewedShape();

Attached is also a picture of the result. When I select a face, only a single primitive triangle is chosen and not the entire face...

Attachments: 
Pawel's picture

Hello Jacques,

you can create a compound and add the triangles to it. This might help: http://www.opencascade.org/org/forum/thread_15132/?forum=3

Pawel

Jacques Coetzee's picture

Hello Pawel

The code that Suman posted is the code I started off with, but I didn't get the nice smooth faces like creating an object procedurally.

Thus I turned to sewing in the hope that it would fuse my little triangles together, giving me a larger smooth face.

Pawel's picture

Hello,

sewing unfortunately will not eliminate the common edges.

Mayby you can have a look here:

http://www.linkedin.com/groupItem?view=&gid=1546137&type=member&item=159537344&qid=e50db01f-493e-4656-91e2-b972e47acbd1&trk=groups_most_recent-0-b-ttl&goback=.nmp_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1.gmr_1546137

Pawel

Jacques Coetzee's picture

Hello Pawel

My membership to the OCC group is pending. I cannot view the content until I am a member of the group.

Are you aware of any other functionality within OCC which will help me?

jelle's picture

Sorry to ask the obvious - but why not create that geometry in OCC?

Jacques Coetzee's picture

I am getting the files from other people who export it as STL-file from CAD.

Game Milky's picture

Dear Jacques Coetzee,

Your attempt of using BRepOffsetAPI_Sewing might connect your gaps or overlaps between two surfaces based on the tolerance value. Therefore, 1.0e-06 could be small compared to the gaps between your surfaces. Could you please check the size of the gap between your surfaces...

So that you can guess the tolerance value. The sewing algorithm closed when the tolerance value should be equal to greater than the gap size,,
Hope helps

Jacques Coetzee's picture

Hello Game

I accidentally left in that line of code creating my "stitcher" for non manifold sewing.
The object is actually created for normal manifold sewing, so the tolerance no longer plays any part.

Unless you think that I should be using non manifold sewing?

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.