split surface Geom_Surface - multiple approaches

Hi everyone!

I'm trying to split surfaces by curves and get a resulting surface. I need this surface (Geom_BsplineSurface) to extract geometric parameters like the knot vectors and control polygon. I approached this in different ways but never with a satisfying result. I present you the approaches I took and show you how I implemented them. Additionally I attached a file with examples for all my approaches.

--- What I tried:

1. Geom_RectangularTrimmedSurface only trims by U,V. I want an arbitrary cutting edge so this is not a solution for me.

2. GEOMAlgo_Splitter does not work with my compiled OCE-12 and pythonOCC master (also tried 0.6-dev, 0.6-beta, 0.6-alpha with OCE-11). I always receive a segmentation fault when executing Perform(). Maybe I'm not using the splitter correctly.
I also tried to implement the GEOMAlgo_Splitter in c++ but had the problem that the algorithm got stuck. I added a cpp file with a GEOMAlgo_Splitter example in the next post which gets stuck for me. I looked into the sources in geom-6.3.1.8.: I followed the execution trail and found, that the execution gets stuck at PaveFiller from NMTTools_PaveFiller. It seems that not all necessary methods/functions like PreparePaveBlocks are defined. In geom-6.3.1.8/src/NMTTools there are multiple NMTTools_PaveFiller_*.cpp files and some of them have the necessary methods/function. I'm by far no expert in C++ - how this makes sense is beyond my knowledge...

3. BRepAlgoAPI_Section - creates intersections between shapes. Works great but I do not want an intersecting curve but a split surface.

4. BRepAlgoAPI_Cut - also creates intersections even when set to Operation(cut)

5. BRepFeat_SplitShape works great as I can split my original shape (created from the surface) into sub shapes via a projected curve(edge). My problem here is to convert the resulting shapes to Geom_Surface. Conversion results in surfaces that are the same as the original surfaces.

My main question is:
How can I get surfaces from the resulting shapes?

Best regards
Kay

--- following short detail of example code - python
see the attached file for a working example including geometry generation pythonOCC

# ###### GEOMAlgo_Splitter

aFace_orig = makeFace(handle_sweptSurface_trimmed_bsplinesurf)
aFace_cutter = makeFace(handle_sweptSurface_cutter_trimmed_bsplinesurf)

# instantiate the Splitter
splitter_Algo = GEOMAlgo_Splitter()
# add the shape to be split
splitter_Algo.AddShape(aFace_orig)
# add the shape that works as a cutter
splitter_Algo.AddTool(aFace_cutter)
# run splitter
splitter_Algo.Perform() # segmentation fault here

# resulting shape
result_shape = splitter_Algo.Shape()

# ###### BRepAlgoAPI_Cut

aFace_orig = makeFace(handle_sweptSurface_trimmed_bsplinesurf)
aFace_cutter = makeFace(handle_sweptSurface_cutter_trimmed_bsplinesurf)

# instantiate the cutter
cutter = BRepAlgoAPI_Cut(aFace_orig,aFace_cutter)
# generate results
cutter.Build()
# get the result
ResultShape = cutter.Shape()

--> does not result in splitted shapes

# ###### BRepFeat_SplitShape

# instantiate the splitter and add the cutter
splitter = BRepFeat_SplitShape(aFace_orig)
splitter.Add(aEdge_cutter,aFace_orig)
# build result
splitter.Build()
# iterator for the result objects
iter = TopTools_ListOfShape()
iter.Set(splitter.Modified(aFace_orig))
# get the results
shape = iter.First()
shape_other_edge = iter.Last()

# convert a shape to a face
face_shape_other_edge = TopoDS.face(shape_other_edge) # # generate a surface from the shape
surf = BRep_Tool.Surface(face_shape_other_edge) #

--> does not result in a splitted surface

Attachments: 
ksommerw's picture

attached here is the c++ code file that gets stuck for me at Perform() of GEOMAlgo_Splitter.

--- following short detail of example code - c++

TopoDS_Face aFace_orig = makeFace(sweptSurface_trimmed_bsplinesurf);
TopoDS_Face aFace_cutter = makeFace(handle_sweptSurface_cutter_trimmed_bsplinesurf);

GEOMAlgo_Splitter splitter_Algo;
splitter_Algo.AddShape(aFace_orig);
splitter_Algo.AddTool(aFace_cutter);
cout << "--before Perform() <-- getting stuck here" << endl;
splitter_Algo.Perform();
cout << "--after Perform()" << endl;

Attachments: 
Mauro Mariotti's picture

If you split with a free-form edge (e.g. a circle or a NURBS curve) you cannot have Geom_Surface's as a result; TopoDS_Face's are neeed.
I use BRepFeat_SplitShape.

Only if you trim along an isoparametric curve, you can build Geom_Surface's (usually a Geom_RectangularTrimmedSurface).

Regards.
Mauro

ksommerw's picture

Hi Mauro!

thank you for your reply! So this split is only registered on the topological level with the trimming edge? Trimming with an isoparametric curve would result in a trimm along a costant U or V value, wouldn't it? Like with the standard Geom_RectangularTrimmedSurface where one inidcates the U and V limits?

Is there any other way to construct a Geom_Surface from a splitted face? Or is there an option to trim a Geom_Surface directly with an arbitrary curve?

I have seen the approach to make a face with a surface and a wire via

faceMaker = BRepBuilderAPI_MakeFace(bsplinesurf,wire)
builtFace = faceMaker.Face()

which does not show a result for me. Reconstructing the surface to a face shows the orignal geoemtry.

I also tried to reconstruct a splitted surface via the edges of the original face and the splitted edge. I convert the edges to trimmed curves and create a surface with GeomFill_BSplineCurves(). However as there is no tangency information the fill style (e.g. GeomFill_StretchStyle, GeomFill_CurvedStyle) fills the surface in a way that it is not congruent with the original surface. The sub surfaces are bulged to the inside or to the outside.
Is there a way to fit the resulting surface to the orginal surface - reducing the bulge to fit the shape of the original?

Best regards
Kay

Sayantam Datta's picture

Dear all,

I am currently using the method  Brepfeatsplitshape to split a face into multiple faces. However problem is I am getting only one face after splitting which is quite weird. For the cutting line, I am trying to take a portion of one of the border edges, while the remaining ones are inside the face. Does anyone have any idea about it?

I am also trying to use Geomalgo_splitter via OCC 0.18  but it seems some methods are not working.

Warm regards,

Sayantam