I have a circular face, which I want to convert to hemisphere. I have the radius of the circular face but not its center point. How do I get the center and how do I change the surface?
Thank you.
Circular face to hemisphere
-
- Posts: 1
- Joined: Thu Oct 31, 2024 3:26 am
Re: Circular face to hemisphere
Getting the center should be easy:
Try querying ICircle_DG out of the face's edge. If this does not work, get the curve of the edge and any three points on it. Create a new ICircle_DG and call ICircle_DG.Init2(point0, point1, point2).
ICircle_DG.Center will be the answer.
The easiest way of building the hemisphere I think is to build it in standard location and then move it to the correct place. This way you would ensure locations and internal structure are in sync.
Create a new sphere ISphere_DG of the specific radius. It will be located at the global origin. Try IBRepBuilder_DG.CreateFace8(ISphere_DG sphere, IBRepWire_DG wire, bool inside).
The wire can be created as:
Create a circle with the specified radius. By default, it will be a 3D circle in the x and y plane.
Create and edge out of it: IBRepBuilder_DG.CreateEdge3(ICircle_DG circle).
Create IBRepWire_DG, call IBRepWire_DG.AddEdge(edge).
Moving the sphere to the original location:
First create the target location as IFrame_DG. Set its origin to the center.
To set the orientation use IFrame_DG.SetAxes() with the first vector in direction from the center to point0, and second vector in direction from center to point1.
Option 1: Add the face to an entity and copy the location from the above: IEntity_DG.GetLocation() > IFrame_DG > IFrame_DG.Copy(theTargetLocation). Or even better, do: IEntity_DG.GetLocation() and then set the origin and call IFrame_DG.SetAxes() like above.
Option 2: Query IGeometricObject_DG from the face and use IGeometricObject_DG.Transform(theTargetLocation)
Try querying ICircle_DG out of the face's edge. If this does not work, get the curve of the edge and any three points on it. Create a new ICircle_DG and call ICircle_DG.Init2(point0, point1, point2).
ICircle_DG.Center will be the answer.
The easiest way of building the hemisphere I think is to build it in standard location and then move it to the correct place. This way you would ensure locations and internal structure are in sync.
Create a new sphere ISphere_DG of the specific radius. It will be located at the global origin. Try IBRepBuilder_DG.CreateFace8(ISphere_DG sphere, IBRepWire_DG wire, bool inside).
The wire can be created as:
Create a circle with the specified radius. By default, it will be a 3D circle in the x and y plane.
Create and edge out of it: IBRepBuilder_DG.CreateEdge3(ICircle_DG circle).
Create IBRepWire_DG, call IBRepWire_DG.AddEdge(edge).
Moving the sphere to the original location:
First create the target location as IFrame_DG. Set its origin to the center.
To set the orientation use IFrame_DG.SetAxes() with the first vector in direction from the center to point0, and second vector in direction from center to point1.
Option 1: Add the face to an entity and copy the location from the above: IEntity_DG.GetLocation() > IFrame_DG > IFrame_DG.Copy(theTargetLocation). Or even better, do: IEntity_DG.GetLocation() and then set the origin and call IFrame_DG.SetAxes() like above.
Option 2: Query IGeometricObject_DG from the face and use IGeometricObject_DG.Transform(theTargetLocation)