Mon, 03/15/2021 - 10:13
Hello,
I am using OpenCascade V7.4.0 on 32bit windows.
I created a wire consisting of a straight line and an ellipse, converted the wire to a face, and used it in my application.
I calculated the center coordinates of the face from the converted face, but it didn't work.
When I calculated the value from the wire before conversion, I found that the value that can be obtained changes before and after conversion.
Why does changing wire to face change the value that can be obtained when surrounded by a boundy box?
Also, how can I find the correct center point coordinate value from face?
Please use the attached Brep file to reproduce the phenomenon.
Below is a sample code that causes the symptom in my environment.
TopoDS_Wire wire;
BRep_Builder builder;
BRepTools::Read( wire, "BREP_FILE_PATH", builder );
Bnd_Box bb_wire;
BRepBndLib::Add( wire, bb_wire );
bb_wire.SetGap( 0.0 );
gp_Pnt wirePntCenter( ( bb_wire.CornerMax().X() + bb_wire.CornerMin().X() ) / 2.0,
( bb_wire.CornerMax().Y() + bb_wire.CornerMin().Y() ) / 2.0,
( bb_wire.CornerMax().Z() + bb_wire.CornerMin().Z() ) / 2.0 );
// face
BRepBuilderAPI_MakeFace makerFace( wire );
TopoDS_Face face = makerFace.Face();
Bnd_Box bb_face;
BRepBndLib::Add( face, bb_face );
bb_face.SetGap( 0.0 );
gp_Pnt facePntCenter( ( bb_face.CornerMax().X() + bb_face.CornerMin().X() ) / 2.0,
( bb_face.CornerMax().Y() + bb_face.CornerMin().Y() ) / 2.0,
( bb_face.CornerMax().Z() + bb_face.CornerMin().Z() ) / 2.0 );
Best regards.
Keito
PS:Old Forum
https://old.opencascade.com/content/position-center-coordinates-can-be-o...
Mon, 03/15/2021 - 13:55
Thank you for answering in the old forum.
I tried the methods that you answered, but unfortunately neither method gave the expected results.
Also, the information I posted was lacking and misleading me. I'm sorry.
The figure I want to analyze this time is not a solid, but a plane figure that exists on one of the two-dimensional planes.
We need to capture the data of a shape drawn on a plane and need the exact coordinates of the center point, not the center of gravity of the shape.
The attachment is an image of what I want to do.
Apart from the boundy box, I tried to get the coordinate values from Face using UV vector and adapter Face.D1.
However, even with this method, the exact center coordinates could not be obtained.
Below is a sample source used in the calculation.
How can I find the exact center point of a face on a two-dimensional plane?
Best regards.
Keito
Mon, 03/15/2021 - 16:52
> Why does changing wire to face change the value that can be obtained when surrounded by a boundy box?
The reason for the difference is a triangulation data used for Bounding Box calculations:
BRepBndLib::Add() has an argument useTriangulation enabled by default:
It may look confusing in your case, but attached TopoDS_Wire indeed contains triangulation data (probably from original TopoDS_Face), but when creating a new Face from Wire, the Bounding Box calculations seem to be reject this triangulation data as new Face wasn't triangulated yet (BRepMesh wasn't called).
Wed, 03/17/2021 - 10:20
Thank you for your answer.
As a result of measuring the center point after performing BRepMesh_IncrementalMesh () on the face, improvement was seen in the values that can be obtained.
I looked at the Open Cascade documentation and found only Incremental Mesh as the mesh method.
Are there other types of meshes?
https://dev.opencascade.org/doc/occt-7.4.0/overview/html/occt_user_guide...
Also, if possible, I would like to reflect the triangle division data that wire originally has on the face.
I wondered if I could try BRepTool :: Triangulation (), but I couldn't extract the information from the wire because the argument is TopoDS_Face.
Is there a way to extract the triangle division data from the wire and reflect it on the face?
Also, is there a good way to reflect the wire triangle division data when creating a face?
Best regards.
Keito
Wed, 03/17/2021 - 16:31
Indeed, OCCT provides only one meshing algorithm. But there is also an Express Mesh component and external meshing algorithms.
TopoDS_Edge may have Poly_Polygon3D and Poly_PolygonOnTriangulation representations created by Incremental Mesh algorithm.
Take a look onto BRep_Tool::Polygon3D() and BRep_Tool::PolygonOnTriangulation() methods.
Thu, 03/18/2021 - 08:36
Thank you for your answer.
As a result of investigating based on the function you taught me, it was confirmed that the edge of the wire contains triangulation information.
Also, as a result of performing BRep_Tool :: Triangulation () on the face created from wire using BRepBuilderAPI_MakeFace,
It turns out that the Triangulation information seems to be gone.
Is there anything you can tell from the above information?
Best regards.
Keito