
Tue, 05/30/2023 - 18:13
Forums:
Dear community,
I use these methods for cutting a mesh and I have a problem with non-manifold shape.
std::vector<OCCTMeshModel> OCCTShapeHealer::getSplittedMeshesAsTwoPart(OCCTMeshModel mesh_model, float height)
{
std::vector<OCCTMeshModel> splitted_mesh_models;
OCCTMeshModel top_mesh, bottom_mesh;
TopoDS_Shape being_splitted_shape = mesh_model.getMeshShape();
if(being_splitted_shape.NbChildren() > 0){
being_splitted_shape = unifyToBeCuttedShape(being_splitted_shape);
}
double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
Bnd_Box bounding_box_of_being_splitted_shape;
BRepBndLib::Add(being_splitted_shape, bounding_box_of_being_splitted_shape);
bounding_box_of_being_splitted_shape.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
//Cut the bottom part of the tool
auto box_to_cut_for_bottom_part = BRepPrimAPI_MakeBox(Xmax - Xmin, Ymax - Ymin, height);
gp_Trsf XYZTransformation_of_box_to_cut_for_bottom_part;
// 1,0,0 Corresponds to X axis; 0,1,0 Corresponds to Y axis; 0,0,1 Corresponds to Z axis.
XYZTransformation_of_box_to_cut_for_bottom_part.SetValues(1, 0, 0, Xmin, 0, 1, 0, Ymin, 0, 0, 1, Zmin);
BRepBuilderAPI_Transform transformXYZ_of_bottom_box(XYZTransformation_of_box_to_cut_for_bottom_part);
transformXYZ_of_bottom_box.Perform(box_to_cut_for_bottom_part.Shape());
auto transformed_cutter_box_bottom = transformXYZ_of_bottom_box.Shape();
auto cutter_for_bottom_shape = BRepAlgoAPI_Cut(being_splitted_shape, transformed_cutter_box_bottom);
auto bottom_shape_of_splitted_shape = cutter_for_bottom_shape.Shape();
auto cutter_for_top_shape = BRepAlgoAPI_Cut(being_splitted_shape, bottom_shape_of_splitted_shape);
auto top_shape_of_splitted_shape = cutter_for_top_shape.Shape();
// Rebuild top and bottom shape.
top_mesh.setMeshShape(top_shape_of_splitted_shape);
top_mesh.setMeshModelId(0);
top_mesh.setMeshModelName("top_shape_of_stl");
bottom_mesh.setMeshShape(bottom_shape_of_splitted_shape);
bottom_mesh.setMeshModelId(1);
bottom_mesh.setMeshModelName("bottom_shape_of_stl");
splitted_mesh_models.push_back(top_mesh);
splitted_mesh_models.push_back(bottom_mesh);
return splitted_mesh_models;
}
TopoDS_Shape OCCTShapeHealer::unifyToBeCuttedShape(TopoDS_Shape shape){
ShapeUpgrade_UnifySameDomain unifier;
unifier.Initialize(shape,true, true, true);
unifier.Build();
return unifier.Shape();
}
I am attaching current screenshots of STL files:
Before cutting:
After cutting:
I would like to fill the cutted surface areas. How can I handle this issuee?
Thank you in advance!
Best regards
Wed, 05/31/2023 - 00:13
Your shape is just a set of faces. You need to handle it as a solid object. So, you need to construct a closed shell from faces, and then create a solid shape from the shell. Such shape will be cut as a solid body.
Wed, 05/31/2023 - 14:03
Hello Mikhail,
Thank you for your support. It helped a lot. Currently, I am able to get closed shapes after cutting operations.
Best regards
Wed, 07/12/2023 - 14:14
Hello again,
Actually, I had implemented a solution for this problem and it worked. However, unfortunately, there is another problem now.
My implementation is:
The current problem is that if we cut some step files after importing them, it adds a rectangular prism. They can be shown as below images:
How can I handle this issue with some meshes?
Thank you in advance!
Wed, 07/12/2023 - 22:34
It is unclear what were arguments of the cut operation.
Fri, 07/14/2023 - 08:11
Hi again,
Is these clear now after adding some code snippets, step file and its screenshots? If not, let me know for extra information.
Best regards
Thu, 07/13/2023 - 09:07
Hello,
I am sorry for unclearness.
My full implementation is:
Test STEP File is : B292A03000YPL_GTM.stp
I've downloaded from: https://www.kennametal.com/tr/tr/products/p.b292-ypl-5-x-d-kcms15-a-saft...
And I am splitting from 10mm as a height.
Before Splitting:
After Splitting-part1:
After Splitting- Part2:
Thu, 07/27/2023 - 00:02
Sorry for long delay. Now I will answer your question and solve the problem. Definitely, your code is wrong. I will give you some recommendations to fix it.
I have performed all these steps using Draw commands, and have got good results.
Tue, 08/01/2023 - 15:57
Hello,
Thank you for getting back to me. This time, I wrote late :) I appreciate your willingness to help and provide recommendations to fix the code.
I have done some modifications with your proposal however, I fear that I am wrong it. Additionally, below implementation occurs open mesh (non-manifold problem again):
Can you share the code you wrote here? Because it works absolutely right according to your image. I'm looking forward to hearing your suggestions.
Best regards,
Nezihe
Wed, 08/02/2023 - 00:39
I did not wrote any code, I just performed some tcl commands in the Draw application. Looking at your new code, I see several mistakes, and you still do not follow my recommendations.