Thu, 05/16/2024 - 12:21
Example of camera parameters obtained from the OCC GUI:
-----------------------------------------------
Eye: 113.976, -113.976, 48.7797
Direction: -0.57735, 0.57735, -0.57735
Up: -0.408248, 0.408248, 0.816497
Scale: 182.058
AxialScale: 1,1,1
Aspect: 1.60714
-----------------------------------------------
How can we make the viewpoint used by the HLRAlgo_Projector remains consistent with the GUI camera viewpoint?
As shown below, how can we implement the code marked with "TODO" in the comments?
-----------------------------------------------
from OCC.Display.SimpleGui import init_display
from OCC.Core.gp import gp_Pnt
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
def main():
# Initialize the display interface
display, start_display, add_menu, add_function_to_menu = init_display()
# Create a simple cube as a sample model
box_shape = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 10, 10, 10).Shape()
# Add the model to the display
display.DisplayShape(box_shape, update=True)
# This opens the GUI window and allows user interaction
start_display()
# Retrieve the current camera view parameters
view = display.View
camera = view.Camera()
eye = camera.Eye() # Camera position
at = camera.Center() # View center
up = camera.Up() # Up direction
# Print camera parameters
print("Camera Eye:", eye.Coord())
print("Camera Center:", at.Coord())
print("Camera Up:", up.Coord())
# TODO: Initialize HLRAlgo_Projector with these parameters
# TODO: Proper conversion and use of these parameters is required, depending on your specific needs and the HLRAlgo_Projector interface
if __name__ == "__main__":
main()
-----------------------------------------------
Thu, 05/16/2024 - 12:43
Hello, your question is not clear for me. You need to re-calculate HLR with new gp_Trsf based on your parameters.
Best regards, Dmitrii.
Thu, 05/16/2024 - 14:14
Thank you for your reply. Please allow me to clarify the question. Suppose that we use a GUI to view a 3D model, cache the camera parameters of the current view of the model, then provide these parameters to HLRAlgo_Projector. HLRAlgo_Projector must restore the viewing status from when the 3D model was originally viewed by GUI. I just uploaded a code example.