SV_Position的每个component都是什么

SV_Position在VS与PS中的应用解析
本文详细解析了SV_Position在顶点着色器(VS)与像素着色器(PS)中的作用与表现形式。在VS中,SV_Position用于写入裁剪空间位置;而在PS中,则读取屏幕像素位置与深度信息,揭示了其在不同阶段的数据转换与应用。
部署运行你感兴趣的模型镜像

SV_Position能在VS和PS中出现。

VS中是要写入。写入的是clip space position

PS中是读出,xy是screen pixel position,范围是[(0,0),(ScreenWidth,ScreenHeight)], z是已经经过divide w后的depth,在[0,1]区间里。w就是clipspace w,所以SV_Position.z * SV_Position.w是clip space z,如果你用SV_Position.z / SV_Position.w那就是除了2次w,那就有问题了!

 

您可能感兴趣的与本文相关的镜像

Qwen-Image

Qwen-Image

图片生成
Qwen

Qwen-Image是阿里云通义千问团队于2025年8月发布的亿参数图像生成基础模型,其最大亮点是强大的复杂文本渲染和精确图像编辑能力,能够生成包含多行、段落级中英文文本的高保真图像

根据BAPI_ALM_ORDER_MAINTAIN源代码分析原因: FUNCTION bapi_alm_order_maintain. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(IV_MMSRV_EXTERNAL_MAINTENACE) TYPE BAPI_FLAG OPTIONAL *" TABLES *" IT_METHODS STRUCTURE BAPI_ALM_ORDER_METHOD *" IT_HEADER STRUCTURE BAPI_ALM_ORDER_HEADERS_I OPTIONAL *" IT_HEADER_UP STRUCTURE BAPI_ALM_ORDER_HEADERS_UP OPTIONAL *" IT_HEADER_SRV STRUCTURE BAPI_ALM_ORDER_SRVDAT_E OPTIONAL *" IT_HEADER_SRV_UP STRUCTURE BAPI_ALM_ORDER_SRVDAT_UP OPTIONAL *" IT_USERSTATUS STRUCTURE BAPI_ALM_ORDER_USRSTAT OPTIONAL *" IT_PARTNER STRUCTURE BAPI_ALM_ORDER_PARTN_MUL OPTIONAL *" IT_PARTNER_UP STRUCTURE BAPI_ALM_ORDER_PARTN_MUL_UP OPTIONAL *" IT_OPERATION STRUCTURE BAPI_ALM_ORDER_OPERATION OPTIONAL *" IT_OPERATION_UP STRUCTURE BAPI_ALM_ORDER_OPERATION_UP OPTIONAL *" IT_RELATION STRUCTURE BAPI_ALM_ORDER_RELATION OPTIONAL *" IT_RELATION_UP STRUCTURE BAPI_ALM_ORDER_RELATION_UP OPTIONAL *" IT_COMPONENT STRUCTURE BAPI_ALM_ORDER_COMPONENT OPTIONAL *" IT_COMPONENT_UP STRUCTURE BAPI_ALM_ORDER_COMPONENT_UP OPTIONAL *" IT_OBJECTLIST STRUCTURE BAPI_ALM_ORDER_OBJECTLIST OPTIONAL *" IT_OBJECTLIST_UP STRUCTURE BAPI_ALM_ORDER_OLIST_UP OPTIONAL *" IT_OLIST_RELATION STRUCTURE BAPI_ALM_OLIST_RELATION OPTIONAL *" IT_TEXT STRUCTURE BAPI_ALM_TEXT OPTIONAL *" IT_TEXT_LINES STRUCTURE BAPI_ALM_TEXT_LINES OPTIONAL *" IT_SRULE STRUCTURE BAPI_ALM_ORDER_SRULE OPTIONAL *" IT_SRULE_UP STRUCTURE BAPI_ALM_ORDER_SRULE_UP OPTIONAL *" IT_TASKLISTS STRUCTURE BAPI_ALM_ORDER_TASKLISTS_I OPTIONAL *" EXTENSION_IN STRUCTURE BAPIPAREX OPTIONAL *" RETURN STRUCTURE BAPIRET2 OPTIONAL *" ET_NUMBERS STRUCTURE BAPI_ALM_NUMBERS OPTIONAL *" IT_REFORDER_ITEM STRUCTURE BAPI_REFORDER_ITEM_I OPTIONAL *" IT_REFORDER_ITEM_UP STRUCTURE BAPI_REFORDER_ITEM_UP OPTIONAL *" IT_REFORDER_SERNO_OLIST_INS STRUCTURE *" BAPI_REFORDER_SERNO_OLIST_I OPTIONAL *" IT_REFORDER_SERNO_OLIST_DEL STRUCTURE *" BAPI_REFORDER_SERNO_OLIST_I OPTIONAL *" IT_PRT STRUCTURE BAPI_ALM_ORDER_PRT_I OPTIONAL *" IT_PRT_UP STRUCTURE BAPI_ALM_ORDER_PRT_UP OPTIONAL *" IT_REFORDER_OPERATION STRUCTURE BAPI_REFORDER_OPERATION *" OPTIONAL *" IT_SERVICEOUTLINE STRUCTURE BAPI_ALM_SRV_OUTLINE OPTIONAL *" IT_SERVICEOUTLINE_UP STRUCTURE BAPI_ALM_SRV_OUTLINE_UP *" OPTIONAL *" IT_SERVICELINES STRUCTURE BAPI_ALM_SRV_SERVICE_LINE OPTIONAL *" IT_SERVICELINES_UP STRUCTURE BAPI_ALM_SRV_SERVICE_LINE_UP *" OPTIONAL *" IT_SERVICELIMIT STRUCTURE BAPI_ALM_SRV_LIMIT_DATA OPTIONAL *" IT_SERVICELIMIT_UP STRUCTURE BAPI_ALM_SRV_LIMIT_DATA_UP *" OPTIONAL *" IT_SERVICECONTRACTLIMITS STRUCTURE *" BAPI_ALM_SRV_CONTRACT_LIMITS OPTIONAL *" IT_SERVICECONTRACTLIMITS_UP STRUCTURE *" BAPI_ALM_SRV_CONTRACT_LIMITS_U OPTIONAL *" ET_NOTIFICATION_NUMBERS STRUCTURE BAPI_ALM_NOTIF_NUMBERS *" OPTIONAL *" IT_PERMIT STRUCTURE BAPI_ALM_ORDER_PERMIT OPTIONAL *" IT_PERMIT_UP STRUCTURE BAPI_ALM_ORDER_PERMIT_UP OPTIONAL *" IT_PERMIT_ISSUE STRUCTURE BAPI_ALM_ORDER_PERMITISSUE OPTIONAL *" IT_ESTIMATED_COSTS STRUCTURE BAPI_ALM_ORDER_COSTS_EST_I *" OPTIONAL *" IT_HEADER_JVA STRUCTURE BAPI_ALM_ORDER_JVA OPTIONAL *" IT_HEADER_JVA_UP STRUCTURE BAPI_ALM_ORDER_JVA_UP OPTIONAL *" IT_ADDITIONAL_TEXT STRUCTURE BAPI_ALM_CC4_ADDITIONAL_TEXT *" OPTIONAL *"---------------------------------------------------------------------- ENHANCEMENT-POINT bapi_alm_order_maintain_g8 SPOTS es_saplibapi_alm_order STATIC. ENHANCEMENT-POINT bapi_alm_order_maintain_g6 SPOTS es_saplibapi_alm_order. * BAPI Funktionsbaustein zum Bearbeiten von ALM Aufträgen (PM/CS) * Die gewünschten Funktionen müssen über eine Methodentabelle * übergeben werden. Darin stehen die auszuführenden Methoden. * Die dazugehörigen Daten sind in den einzelnen Datentabellen * zuzuordnen. * Weitere Informationen befinden sich im BAPI Explorer unter * Instandhaltungsabwicklung bzw. Serviceabwicklung * Datendefinitionen *************************************** DATA lt_methods TYPE bapi_alm_order_method_t. * Zu bearbeitende Aufträge, die gelesen werden müssen DATA lt_orders TYPE almb_ord_pre_tab. * Methodenreihenfolge DATA lt_method_level TYPE almb_proc_level_tab. * Interne Datentabellen *********************************** * Auftragsköpfe DATA lt_caufvd TYPE almb_caufvd_tab_int. DATA lt_caufvd_up TYPE almb_caufvd_up_tab_int. * Servicedaten Auftragsköpfe DATA lt_pmsdo TYPE almb_caufvd_srv_tab_int. DATA lt_pmsdo_up TYPE almb_caufvd_srv_up_tab_int. * Auftragsköpfe (extern) DATA lt_bapihead TYPE almb_caufvd_tab. DATA ls_bapihead TYPE LINE OF almb_caufvd_tab. DATA lt_bapihead_up TYPE almb_caufvd_up_tab. DATA ls_bapihead_up TYPE LINE OF almb_caufvd_up_tab. DATA lt_bapihead_old TYPE almb_caufvd_tab. DATA lt_bapihead_old_up TYPE almb_caufvd_up_tab. * Servicedaten Auftragsköpfe (extern) DATA lt_bapisrvcdata TYPE almb_caufvd_srv_tab. DATA ls_bapisrvcdata TYPE LINE OF almb_caufvd_srv_tab. DATA lt_bapisrvcdata_up TYPE almb_caufvd_srv_up_tab. DATA ls_bapisrvcdata_up TYPE LINE OF almb_caufvd_srv_up_tab. DATA lt_bapisrvcdata_old TYPE almb_caufvd_srv_tab. DATA lt_bapisrvcdata_old_up TYPE almb_caufvd_srv_up_tab. * Auftragskopfdaten nach BADI für Abwärtskompatibilität DATA ls_header TYPE bapi_alm_order_headers_i. DATA ls_header_up TYPE bapi_alm_order_headers_up. DATA ls_header_srv TYPE bapi_alm_order_srvdat_e. DATA ls_header_srv_up TYPE bapi_alm_order_srvdat_up. DATA lt_header TYPE TABLE OF bapi_alm_order_headers_i. DATA lt_header_up TYPE TABLE OF bapi_alm_order_headers_up. DATA lt_header_srv TYPE TABLE OF bapi_alm_order_srvdat_e. DATA lt_header_srv_up TYPE TABLE OF bapi_alm_order_srvdat_up. * Userstatus DATA lt_userstatus TYPE almb_userstatus. * Partner DATA lt_partner TYPE almb_partner_tab. DATA lt_partner_up TYPE almb_partner_up_tab. * Vorgänge DATA lt_afvgd TYPE almb_afvgd_tab. DATA lt_afvgd_up TYPE almb_afvgd_up_tab. * Anordnungsbeziehungen DATA lt_afabd TYPE almb_afabd_tab. DATA lt_afabd_up TYPE almb_afabd_up_tab. * Komponenten DATA lt_resbd TYPE almb_resbd_tab. DATA lt_resbd_up TYPE almb_resbd_up_tab. * Objektliste DATA lt_riwol TYPE almb_riwol_tab. DATA lt_riwol_up TYPE almb_riwol_up_tab. * Objectlist: Relation Operation to Objectlist DATA lt_olist_relation TYPE almb_olist_relation_tab. * Task lists DATA lt_tasklists TYPE ibapi_order_tasklists_i_t. * Settlement rules DATA lt_cobl TYPE almb_cobl_tab. DATA lt_cobl_up TYPE almb_cobl_up_tab. * Langtexte DATA lt_text TYPE almb_text_tab. DATA lt_text_add TYPE almb_cc4_add_text_tab. "note 2756658 DATA lt_text_lines TYPE tlinetab. * Rückgabe der Nachrichten DATA lt_messages TYPE bal_t_msg. DATA ls_messages TYPE bal_s_msg. DATA ls_return LIKE LINE OF return[]. DATA lv_error TYPE sy-subrc. *Refurbishment order DATA lt_afpod TYPE ibapi_afpod_tt. DATA lt_afpod_resbd TYPE ibapi_reforder_comp_tt. DATA lt_serno_olist_ins TYPE reford_serno_olist_t. DATA lt_serno_olist_del TYPE reford_serno_olist_t. DATA lt_afpod_up TYPE ibapi_afpod_update_tt. DATA lt_afpod_resbd_up TYPE ibapi_reforder_comp_update_tt. DATA lt_reford_afvgd TYPE almb_afvgd_tab. *PRTs DATA lt_prt TYPE bapi_alm_order_prt_i_t. DATA lt_prt_up TYPE bapi_alm_order_prt_up_t. *Service packages DATA lt_serviceoutline TYPE bapi_alm_srv_outline_t. DATA lt_serviceoutline_up TYPE bapi_alm_srv_outline_up_t. DATA lt_servicelines TYPE bapi_alm_srv_service_line_t. DATA lt_servicelines_up TYPE bapi_alm_srv_service_line_up_t. DATA lt_servicelimit TYPE bapi_alm_srv_limit_data_t. DATA lt_servicelimit_up TYPE bapi_alm_srv_limit_data_up_t. DATA lt_servicecontractlimits TYPE bapi_alm_srv_contract_limit_t. DATA lt_servicecontractlimits_up TYPE bapi_alm_srv_contr_limits_u_t. * Note 1989741 - begin DATA: ls_extension_up TYPE almb_extension_up. DATA: lt_extension_up TYPE almb_extension_up_tab. * Note 1989741 - end *Permits DATA lt_permit TYPE eam_t_permit_order. DATA lt_permit_up TYPE eam_t_permit_order_up. DATA lt_permit_issue TYPE eam_t_permit_issue. * Estimated costs DATA: lt_est_cost TYPE bapi_alm_order_costs_est_i_tt. " 1672966 EAMCC PM110 * Settlement profiles DATA: lt_settlmt_profile TYPE almb_settlmt_profile_tab. * >>>>> Begin note 2304265: DFPS specific variables data lv_method_del type abap_bool. * <<<<< End note 2304265 * DATA lt_serno_olist_up TYPE REFORD_SERNO_OLIST_UPDATE_TT. FIELD-SYMBOLS <fs_olist_relation> LIKE LINE OF lt_olist_relation. FIELD-SYMBOLS <fs_methods> LIKE LINE OF lt_methods. "1837200 cl_eam_usage=>insert('BAPI_ALM_ORDER_MAINTAIN'). * BADIs * Vorwärtsdeklaration für exit handler BAdI CLASS cl_exithandler DEFINITION LOAD. * Interfacereferenz für BAdI STATICS sr_modify_input_data TYPE REF TO if_ex_ibapi_alm_ord_modify. STATICS sv_badiactive. * Konstante für BAdI-Referenzierung CONSTANTS lc_badiname TYPE exit_def VALUE 'IBAPI_ALM_ORD_MODIFY'. * start FLE MATNR BAPI Changes DATA: ls_fnames TYPE cl_matnr_chk_mapper=>ts_matnr_bapi_fnames, lt_fnames_hdr TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_hdr_srv TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_comp TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_obj_list TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_oper TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_prt TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_ref_ord_itm TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname, lt_fnames_ref_ord_opr TYPE cl_matnr_chk_mapper=>tt_matnr_bapi_fname. DATA: lt_matnr_data_to_x_key_fnames TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_key_fnames. DATA: lt_matnr_dta_2_xkey_fnames_hdr TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_key_fnames. DATA: lt_mtnr_dta2xkey_fnames_hdrsrv TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_key_fnames. DATA: lt_matnr_dta_2_xkey_fnames_opr TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_key_fnames. DATA: lt_matnr_dta_2_xkey_fnames_cmp TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_key_fnames. DATA: lt_mtnr_dta2xkey_fnames_rfoitm TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_key_fnames. DATA: ls_matnr_data_to_x_key_fnames LIKE LINE OF lt_matnr_data_to_x_key_fnames. DATA: ls_matnr_data_to_x_line_ass TYPE cl_matnr_chk_mapper=>ts_matnr_data_to_x_line_ass. DATA: lt_matnr_data_to_x_line_ass TYPE cl_matnr_chk_mapper=>tt_matnr_data_to_x_line_ass. DATA: lv_linecount_data TYPE i. DATA: lv_linecount_data_up TYPE i. * MATERIAL CLEAR ls_fnames. ls_fnames-int = 'MATERIAL'. ls_fnames-ext = 'MATERIAL_EXTERNAL'. ls_fnames-vers = 'MATERIAL_VERSION'. ls_fnames-guid = 'MATERIAL_GUID'. ls_fnames-long = 'MATERIAL_LONG'. INSERT ls_fnames INTO TABLE lt_fnames_prt. ls_fnames-int_x = 'MATERIAL'. ls_fnames-ext_x = 'MATERIAL'. "no update flag existing, flag of internal field is used ls_fnames-vers_x = 'MATERIAL'. "no update flag existing, flag of internal field is used * ls_fnames-guid_x = 'MATERIAL_GUID'. ls_fnames-long_x = 'MATERIAL_LONG'. INSERT ls_fnames INTO TABLE lt_fnames_hdr. INSERT ls_fnames INTO TABLE lt_fnames_hdr_srv. INSERT ls_fnames INTO TABLE lt_fnames_comp. * ASSEMBLY CLEAR ls_fnames. ls_fnames-int = 'ASSEMBLY'. ls_fnames-ext = 'ASSEMBLY_EXTERNAL'. ls_fnames-vers = 'ASSEMBLY_VERSION'. ls_fnames-guid = 'ASSEMBLY_GUID'. ls_fnames-long = 'ASSEMBLY_LONG'. INSERT ls_fnames INTO TABLE lt_fnames_ref_ord_opr. INSERT ls_fnames INTO TABLE lt_fnames_obj_list. ls_fnames-int_x = 'ASSEMBLY'. ls_fnames-ext_x = 'ASSEMBLY'. "no update flag existing, flag of internal field is used ls_fnames-vers_x = 'ASSEMBLY'. "no update flag existing, flag of internal field is used * ls_fnames-guid_x = 'ASSEMBLY_GUID'. ls_fnames-long_x = 'ASSEMBLY_LONG'. INSERT ls_fnames INTO TABLE lt_fnames_hdr. INSERT ls_fnames INTO TABLE lt_fnames_oper. * SERMAT CLEAR ls_fnames. ls_fnames-int = 'SERMAT'. ls_fnames-ext = 'SERMAT_EXTERNAL'. ls_fnames-vers = 'SERMAT_VERSION'. ls_fnames-guid = 'SERMAT_GUID'. ls_fnames-long = 'SERMAT_LONG'. * ls_fnames-int_x = 'SERMAT'. * ls_fnames-ext_x = 'SERMAT_EXTERNAL'. * ls_fnames-vers_x = 'SERMAT_VERSION'. * ls_fnames-guid_x = 'SERMAT_GUID'. * ls_fnames-long_x = 'SERMAT_LONG'. INSERT ls_fnames INTO TABLE lt_fnames_obj_list. * MATERIAL_TO CLEAR ls_fnames. ls_fnames-int = 'MATERIAL_TO'. ls_fnames-ext = 'MATERIAL_TO_EXTERNAL'. ls_fnames-vers = 'MATERIAL_TO_VERSION'. ls_fnames-guid = 'MATERIAL_TO_GUID'. ls_fnames-long = 'MATERIAL_TO_LONG'. ls_fnames-int_x = 'MATERIAL_TO'. ls_fnames-ext_x = 'MATERIAL_TO'. "no update flag existing, flag of internal field is used ls_fnames-vers_x = 'MATERIAL_TO'. "no update flag existing, flag of internal field is used * ls_fnames-guid_x = 'MATERIAL_TO_GUID'. ls_fnames-long_x = 'MATERIAL_TO_LONG'. INSERT ls_fnames INTO TABLE lt_fnames_ref_ord_itm. * IT_HEADER CLEAR ls_matnr_data_to_x_key_fnames. ls_matnr_data_to_x_key_fnames-data_key_field = 'ORDERID'. ls_matnr_data_to_x_key_fnames-x_key_field = 'ORDERID'. APPEND ls_matnr_data_to_x_key_fnames TO lt_matnr_dta_2_xkey_fnames_hdr. cl_matnr_chk_mapper=>bapi_tables_conv_tab_x_names( EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_hdr it_matnr_data_to_x_key_fnames = lt_matnr_dta_2_xkey_fnames_hdr CHANGING ct_matnr = it_header[] ct_matnrx = it_header_up[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3 ). IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_HEADER_SRV - No key fields DESCRIBE TABLE it_header_srv[] LINES lv_linecount_data. DESCRIBE TABLE it_header_srv_up[] LINES lv_linecount_data_up. CLEAR lt_matnr_data_to_x_line_ass[]. IF lv_linecount_data = lv_linecount_data_up. lv_linecount_data = 0. WHILE lv_linecount_data LT lv_linecount_data_up. ADD 1 TO lv_linecount_data. ls_matnr_data_to_x_line_ass-ass_x_line_idx = lv_linecount_data. ls_matnr_data_to_x_line_ass-data_line_idx = lv_linecount_data. APPEND ls_matnr_data_to_x_line_ass TO lt_matnr_data_to_x_line_ass. ENDWHILE. ENDIF. cl_matnr_chk_mapper=>bapi_tables_conv_tab_x_idx( EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_hdr_srv it_matnr_data_to_x_line_ass = lt_matnr_data_to_x_line_ass CHANGING ct_matnr = it_header_srv[] ct_matnrx = it_header_srv_up[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3 ). IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_OPERATION - No key fields * DESCRIBE TABLE it_operation[] LINES lv_linecount_data. * DESCRIBE TABLE it_operation_up[] LINES lv_linecount_data_up. * CLEAR lt_matnr_data_to_x_line_ass[]. * IF lv_linecount_data = lv_linecount_data_up. * lv_linecount_data = 0. * WHILE lv_linecount_data LT lv_linecount_data_up. * ADD 1 TO lv_linecount_data. * ls_matnr_data_to_x_line_ass-ass_x_line_idx = lv_linecount_data. * ls_matnr_data_to_x_line_ass-data_line_idx = lv_linecount_data. * APPEND ls_matnr_data_to_x_line_ass TO lt_matnr_data_to_x_line_ass. * ENDWHILE. * ENDIF. CLEAR lt_matnr_data_to_x_line_ass[]. LOOP AT it_operation_up. READ TABLE it_operation INDEX sy-tabix TRANSPORTING NO FIELDS. IF sy-subrc IS INITIAL. ls_matnr_data_to_x_line_ass-ass_x_line_idx = sy-tabix. ls_matnr_data_to_x_line_ass-data_line_idx = sy-tabix. APPEND ls_matnr_data_to_x_line_ass TO lt_matnr_data_to_x_line_ass. ENDIF. ENDLOOP. cl_matnr_chk_mapper=>bapi_tables_conv_tab_x_idx( EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_oper it_matnr_data_to_x_line_ass = lt_matnr_data_to_x_line_ass CHANGING ct_matnr = it_operation[] ct_matnrx = it_operation_up[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3 ). IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_COMPONENT - No key fields * DESCRIBE TABLE it_component[] LINES lv_linecount_data. * DESCRIBE TABLE it_component_up[] LINES lv_linecount_data_up. * CLEAR lt_matnr_data_to_x_line_ass[]. * IF lv_linecount_data = lv_linecount_data_up. * lv_linecount_data = 0. * WHILE lv_linecount_data LT lv_linecount_data_up. * ADD 1 TO lv_linecount_data. * ls_matnr_data_to_x_line_ass-ass_x_line_idx = lv_linecount_data. * ls_matnr_data_to_x_line_ass-data_line_idx = lv_linecount_data. * APPEND ls_matnr_data_to_x_line_ass TO lt_matnr_data_to_x_line_ass. * ENDWHILE. * ENDIF. CLEAR lt_matnr_data_to_x_line_ass[]. LOOP AT it_component_up. READ TABLE it_component INDEX sy-tabix TRANSPORTING NO FIELDS. IF sy-subrc IS INITIAL. ls_matnr_data_to_x_line_ass-ass_x_line_idx = sy-tabix. ls_matnr_data_to_x_line_ass-data_line_idx = sy-tabix. APPEND ls_matnr_data_to_x_line_ass TO lt_matnr_data_to_x_line_ass. ENDIF. ENDLOOP. cl_matnr_chk_mapper=>bapi_tables_conv_tab_x_idx( EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_comp it_matnr_data_to_x_line_ass = lt_matnr_data_to_x_line_ass CHANGING ct_matnr = it_component[] ct_matnrx = it_component_up[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3 ). IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_REFORDER_ITEM CLEAR ls_matnr_data_to_x_key_fnames. ls_matnr_data_to_x_key_fnames-data_key_field = 'ORDERID'. ls_matnr_data_to_x_key_fnames-x_key_field = 'ORDERID'. APPEND ls_matnr_data_to_x_key_fnames TO lt_mtnr_dta2xkey_fnames_rfoitm. cl_matnr_chk_mapper=>bapi_tables_conv_tab_x_names( EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_ref_ord_itm it_matnr_data_to_x_key_fnames = lt_mtnr_dta2xkey_fnames_rfoitm CHANGING ct_matnr = it_reforder_item[] ct_matnrx = it_reforder_item_up[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3 ). IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_OBJECTLIST * No UP-structure with material field CALL METHOD cl_matnr_chk_mapper=>bapi_tables_conv_tab EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_obj_list CHANGING ct_matnr = it_objectlist[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3. IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_PRT * No UP-structure with material field CALL METHOD cl_matnr_chk_mapper=>bapi_tables_conv_tab EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_prt CHANGING ct_matnr = it_prt[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3. IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * IT_REFORDER_OPERATION * No UP-structure CALL METHOD cl_matnr_chk_mapper=>bapi_tables_conv_tab EXPORTING iv_int_to_external = abap_false it_fnames = lt_fnames_ref_ord_opr CHANGING ct_matnr = it_reforder_operation[] EXCEPTIONS excp_matnr_ne = 1 excp_matnr_invalid_input = 2 OTHERS = 3. IF sy-subrc NE 0. CALL METHOD cl_matnr_chk_mapper=>bapi_get_last_error IMPORTING ev_return = ls_return. APPEND ls_return TO return. IF ls_return-type NA 'SIW'. RETURN. ENDIF. ENDIF. * end FLE MATNR BAPI Changes * Initialisierungen *************************************** * setzen BAPI-Flag z.B. für Prüfloserzeugung MOVE 'X' TO gv_bapi_flg. "note 1302002 * Memory refresh CALL FUNCTION 'IBAPI_PROC_INIT_REQUEST'. * Badi initialisieren IF sv_badiactive IS INITIAL. CALL METHOD cl_exithandler=>get_instance EXPORTING exit_name = lc_badiname null_instance_accepted = 'X' CHANGING instance = sr_modify_input_data. sv_badiactive = 'X'. ENDIF. * Retrunparemetertabellen löschen CLEAR return[]. CLEAR et_numbers[]. * globales Bapiflag setzen CALL FUNCTION 'IBAPI_Z_SET_BAPI_FLAG' EXPORTING iv_flag = 'X'. CALL FUNCTION 'DIALOG_GET_STATUS' "Note 1441350 IMPORTING "Note 1441350 dialog_status = gv_dialog. "Note 1441350 CALL FUNCTION 'DIALOG_SET_NO_DIALOG'. "Note 1441350 * Aktionsbuffer für Auftragskopfdaten CALL FUNCTION 'IBAPI_ALM_ORDER_INIT_ACTIONS'. * Application Log initialisieren PERFORM alm_order_msg_log_init. * Tabelle mit Methoden kopieren MOVE it_methods[] TO lt_methods. * start of note 1837200 * usage of method DIALOG together with MMSRV is not supported READ TABLE lt_methods TRANSPORTING NO FIELDS WITH KEY method = 'DIALOG'. IF sy-subrc = 0. LOOP AT lt_methods ASSIGNING <fs_methods> WHERE objecttype CS 'SERVICE'. MESSAGE e137(iwo_bapi2) WITH <fs_methods>-objecttype INTO mess. bapi_message. MESSAGE e113(iwo_bapi2) INTO mess. bapi_message. PERFORM end_bapi CHANGING return[]. PERFORM reset_created_headers USING et_numbers[] lt_method_level. RETURN. ENDLOOP. ENDIF. * end of note 1837200 * Schnittstellendaten in interne Strukturen umwandeln ***** CALL FUNCTION 'IBAPI_PROC_INTERFACE_E2I' EXPORTING it_header = it_header[] it_header_up = it_header_up[] it_header_srv = it_header_srv[] it_header_srv_up = it_header_srv_up[] it_userstatus = it_userstatus[] it_partner = it_partner[] it_partner_up = it_partner_up[] it_operation = it_operation[] it_operation_up = it_operation_up[] it_relation = it_relation[] it_relation_up = it_relation_up[] it_component = it_component[] it_component_up = it_component_up[] it_objectlist = it_objectlist[] it_objectlist_up = it_objectlist_up[] it_olist_relation = it_olist_relation[] it_srule = it_srule[] it_srule_up = it_srule_up[] it_text = it_text[] it_text_lines = it_text_lines[] it_tasklists = it_tasklists[] it_reforder_item = it_reforder_item[] it_reforder_item_up = it_reforder_item_up[] it_reforder_operation = it_reforder_operation[] it_reforder_serno_olist_ins = it_reforder_serno_olist_ins[] it_reforder_serno_olist_del = it_reforder_serno_olist_del[] it_serviceoutline = it_serviceoutline[] it_servicelines = it_servicelines[] it_servicelimit = it_servicelimit[] it_servicecontractlimits = it_servicecontractlimits[] it_serviceoutline_up = it_serviceoutline_up[] it_servicelines_up = it_servicelines_up[] it_servicelimit_up = it_servicelimit_up[] it_servicecontractlimits_up = it_servicecontractlimits_up[] it_permit = it_permit[] it_permit_up = it_permit_up[] it_permit_issue = it_permit_issue[] it_estimated_costs = it_estimated_costs[] " 1672966 EAMCC PM110 it_header_jva = it_header_jva[] it_header_jva_up = it_header_jva_up[] it_text_add = it_additional_text[] "note 2756658 IMPORTING et_caufvd = lt_caufvd et_caufvd_up = lt_caufvd_up et_caufvd_srv = lt_pmsdo et_caufvd_srv_up = lt_pmsdo_up et_userstatus = lt_userstatus et_partner = lt_partner et_partner_up = lt_partner_up et_afvgd = lt_afvgd et_afvgd_up = lt_afvgd_up et_afabd = lt_afabd et_afabd_up = lt_afabd_up et_resbd = lt_resbd et_resbd_up = lt_resbd_up et_riwol = lt_riwol et_riwol_up = lt_riwol_up et_olist_relation = lt_olist_relation et_cobl = lt_cobl et_cobl_up = lt_cobl_up et_thead = lt_text et_tlines = lt_text_lines et_tasklists = lt_tasklists et_afpod = lt_afpod et_afpod_up = lt_afpod_up et_afpod_resbd = lt_afpod_resbd et_afpod_resbd_up = lt_afpod_resbd_up et_reford_afvgd = lt_reford_afvgd et_serno_olist_ins = lt_serno_olist_ins et_serno_olist_del = lt_serno_olist_del et_serviceoutline = lt_serviceoutline et_servicelines = lt_servicelines et_servicelimit = lt_servicelimit et_servicecontractlimits = lt_servicecontractlimits et_serviceoutline_up = lt_serviceoutline_up et_servicelines_up = lt_servicelines_up et_servicelimit_up = lt_servicelimit_up et_servicecontractlimits_up = lt_servicecontractlimits_up et_permit = lt_permit et_permit_up = lt_permit_up et_permit_issue = lt_permit_issue et_estimated_costs = lt_est_cost " 1672966 EAMCC PM110 et_thead_add = lt_text_add "note 2756658 et_settlement_profile = lt_settlmt_profile EXCEPTIONS conversion_error = 1 textline_error = 2 OTHERS = 3. IF sy-subrc NE 0. PERFORM end_bapi CHANGING return[]. EXIT. ENDIF. *--- fill PRT data in int. tables (mapping is performed later) lt_prt = it_prt[]. lt_prt_up = it_prt_up[]. * BADI zum prüfen und ändern der Eingabedaten ************* * aufrufen. Zu diesem Zeitpunkt sind die meisten ********** * Daten im internen Format verfügbar ********************** IF NOT sr_modify_input_data IS INITIAL. * Abwärtskompatibilität: In frühen Versionen wurden nur die externen * Repräsentationen der Auftragskopfdaten angeboten. Dabei können nur * bestimmte Teile der Auftragsköpfe geändert werden. Falls aber Kunden * bereits eine entsprechende BAdI-Implementation erstellt haben, wird * Nacharbeit notwendig, um die alte Logik nach wie vor zu * unterstützen LOOP AT it_header. MOVE-CORRESPONDING it_header TO ls_bapihead. APPEND ls_bapihead TO lt_bapihead. ENDLOOP. LOOP AT it_header_up. MOVE-CORRESPONDING it_header_up TO ls_bapihead_up. APPEND ls_bapihead_up TO lt_bapihead_up. ENDLOOP. LOOP AT it_header_srv. MOVE-CORRESPONDING it_header_srv TO ls_bapisrvcdata. MOVE it_header_srv-material_long TO ls_bapisrvcdata-material. "MFLE APPEND ls_bapisrvcdata TO lt_bapisrvcdata. ENDLOOP. LOOP AT it_header_srv_up. MOVE-CORRESPONDING it_header_srv_up TO ls_bapisrvcdata_up. MOVE it_header_srv_up-material_long TO ls_bapisrvcdata_up-material. "MFLE APPEND ls_bapisrvcdata_up TO lt_bapisrvcdata_up. ENDLOOP. * Before-Image für externe Datenrepräsentation sichern lt_bapihead_old = lt_bapihead. lt_bapihead_old_up = lt_bapihead_up. lt_bapisrvcdata_old = lt_bapisrvcdata. lt_bapisrvcdata_old_up = lt_bapisrvcdata_up. CLEAR lt_extension_up. " Note 1989741 cl_im_eams_ord_cfd_write=>extension_in_tab = extension_in[]. LOOP AT extension_in. CALL METHOD sr_modify_input_data->modify_input_data EXPORTING extension_in = extension_in CHANGING ct_methods = lt_methods ct_header = lt_bapihead ct_header_up = lt_bapihead_up ct_header_srv = lt_bapisrvcdata ct_header_srv_up = lt_bapisrvcdata_up ct_userstatus = lt_userstatus ct_partner = lt_partner ct_partner_up = lt_partner_up ct_operation = lt_afvgd ct_operation_up = lt_afvgd_up ct_relation = lt_afabd ct_relation_up = lt_afabd_up ct_component = lt_resbd ct_component_up = lt_resbd_up ct_objectlist = lt_riwol ct_text = lt_text ct_text_lines = lt_text_lines ct_messages = lt_messages ct_header_int = lt_caufvd ct_header_int_up = lt_caufvd_up ct_pmsdo_srv = lt_pmsdo ct_pmsdo_srv_up = lt_pmsdo_up ct_reforder_item_int = lt_afpod ct_reforder_item_int_up = lt_afpod_up ct_reforder_comp = lt_afpod_resbd ct_reforder_comp_up = lt_afpod_resbd_up ct_reforder_serno_olist_ins = lt_serno_olist_ins ct_reforder_serno_olist_del = lt_serno_olist_del ct_prt = lt_prt ct_prt_up = lt_prt_up ct_serviceoutline = lt_serviceoutline ct_serviceoutline_up = lt_serviceoutline_up ct_servicelines = lt_servicelines ct_servicelines_up = lt_servicelines_up ct_servicelimit = lt_servicelimit ct_servicelimit_up = lt_servicelimit_up ct_servicecontractlimits = lt_servicecontractlimits ct_servicecontractlimits_up = lt_servicecontractlimits_up ct_estimated_costs = lt_est_cost. " 1672966 EAMCC PM110 * Note 1989741 - begin IF extension_in-structure IS NOT INITIAL. ls_extension_up-fieldname = extension_in-structure. ls_extension_up-bapiupdate = 'X'. APPEND ls_extension_up TO lt_extension_up. ENDIF. * Note 1989741 - end ENDLOOP. * Before- und After-Image für alte Logik vergleichen: * Bei Delta nur die externe Repräsentation der Kopfdaten verwenden IF lt_bapihead_old <> lt_bapihead OR lt_bapihead_old_up <> lt_bapihead_up OR lt_bapisrvcdata_old <> lt_bapisrvcdata OR lt_bapisrvcdata_old_up <> lt_bapisrvcdata_up. * Aus im BAdI veränderten Daten Import-Daten wiederherstellen, * Konvertierung für Kopfdaten erneut durchführen LOOP AT lt_bapihead INTO ls_bapihead. MOVE-CORRESPONDING ls_bapihead TO ls_header. APPEND ls_header TO lt_header. ENDLOOP. LOOP AT lt_bapihead_up INTO ls_bapihead_up. MOVE-CORRESPONDING ls_bapihead_up TO ls_header_up. APPEND ls_header_up TO lt_header_up. ENDLOOP. LOOP AT lt_bapisrvcdata INTO ls_bapisrvcdata. MOVE-CORRESPONDING ls_bapisrvcdata TO ls_header_srv. ls_header_srv-material_long = ls_bapisrvcdata-material. "MFLE CLEAR: ls_header_srv-material. "MFLE APPEND ls_header_srv TO lt_header_srv. ENDLOOP. LOOP AT lt_bapisrvcdata_up INTO ls_bapisrvcdata_up. MOVE-CORRESPONDING ls_bapisrvcdata_up TO ls_header_srv_up. ls_header_srv_up-material_long = ls_bapisrvcdata_up-material. "MFLE APPEND ls_header_srv_up TO lt_header_srv_up. ENDLOOP. CALL FUNCTION 'IBAPI_PROC_INTERFACE_E2I' EXPORTING it_header = lt_header[] it_header_up = lt_header_up[] it_header_srv = lt_header_srv[] it_header_srv_up = lt_header_srv_up[] it_userstatus = it_userstatus[] it_partner = it_partner[] it_operation = it_operation[] it_relation = it_relation[] it_component = it_component[] it_text = it_text[] it_text_lines = it_text_lines[] IMPORTING et_caufvd = lt_caufvd et_caufvd_up = lt_caufvd_up et_caufvd_srv = lt_pmsdo et_caufvd_srv_up = lt_pmsdo_up EXCEPTIONS conversion_error = 1 textline_error = 2 OTHERS = 3. IF sy-subrc NE 0. PERFORM end_bapi CHANGING return[]. EXIT. ENDIF. ENDIF. ENDIF. * Messages vom BADI auswerten und ins BAPI-Log scheiben * Fehler in Tabelle RETURN schreiben. * Bei Message E oder A bricht der Bapi ab CLEAR return[]. LOOP AT lt_messages INTO ls_messages. CALL FUNCTION 'BALW_BAPIRETURN_GET2' EXPORTING type = ls_messages-msgty cl = ls_messages-msgid number = ls_messages-msgno par1 = ls_messages-msgv1 par2 = ls_messages-msgv2 par3 = ls_messages-msgv3 par4 = ls_messages-msgv4 IMPORTING return = ls_return. APPEND ls_return TO return[]. IF ls_messages-msgty CA 'AE'. MOVE 4 TO lv_error. ENDIF. ENDLOOP. "Message-Log zurückgeben IF lv_error NE 0. EXIT. ENDIF. * Prüfen, ob der Trace geschrieben werden soll, * und ihn dann auf das Frontend schreiben. Dies * geht natürlich nur, wenn der BAPI vom Frontend * aus aufgerufen wird. * Der Trace kann auch dazu dienen festzustellen, ob die * Daten korrekt kovertiert wurden, und der BADI das * richtige gemacht hat. CALL FUNCTION 'IBAPI_PROC_SAVE_TRACE' EXPORTING it_header = lt_caufvd it_header_up = lt_caufvd_up it_header_srv = lt_pmsdo it_header_srv_up = lt_pmsdo_up it_userstatus = lt_userstatus it_partner = lt_partner it_partner_up = lt_partner_up it_operation = lt_afvgd it_operation_up = lt_afvgd_up it_relation = lt_afabd it_relation_up = lt_afabd_up it_component = lt_resbd it_component_up = lt_resbd_up it_objectlist = lt_riwol it_srule = lt_cobl it_srule_up = lt_cobl_up it_text = lt_text it_text_lines = lt_text_lines it_tasklists = lt_tasklists CHANGING ct_methods = lt_methods. * Methodentabelle auf Konsistenz prüfen und in internes * Format umsetzen. Bestimmen, welche Aufträge in die * Belegtabelle gelesen werden müssen. CALL FUNCTION 'IBAPI_PROC_METHOD_TABLE_E2I' IMPORTING et_orders = lt_orders CHANGING ct_method_table = lt_methods EXCEPTIONS object_unknown = 1 method_unknown = 2 invalid_order_key = 3 required_order_no_created = 4 save_or_dialog_required = 5 OTHERS = 6. IF sy-subrc NE 0. * Fehler werden bereits in FB geloggt * setzen des Fehlerflags und verlassen des Bapis PERFORM end_bapi CHANGING return[]. EXIT. ENDIF. * Reihenfolge der Bearbeitung festlegen. ****************** * dies ist vor allem dann wichtig, wenn ******************* * Anordnungsbeziehungen zwischen neu ********************** * angelegten Vorgängen erzeugt werden sollen. ************* CALL FUNCTION 'IBAPI_SET_METHOD_LEVEL' EXPORTING it_methods = lt_methods IMPORTING et_method_level = lt_method_level. * Lesen der Aufträge in die Belegtabellen und sperren. CALL FUNCTION 'IBAPI_READ_AND_LOCK_ORDERS' EXPORTING it_aufnr = lt_orders it_methods = lt_methods EXCEPTIONS order_not_found = 1 release_no_change = 2 order_locked = 3 OTHERS = 4. IF sy-subrc NE 0. * Fehler beim Lesen der Aufträge in die Belegtabellen PERFORM end_bapi CHANGING return[]. EXIT. ENDIF. * For supporting geospatial data processing,the code related to note 2550268 is disabled **-- check orders is geo enabled note 2550268 * PERFORM eamgef_order_check USING it_header[] * lt_method_level * CHANGING lv_error. * IF lv_error NE 0. * PERFORM end_bapi CHANGING return[]. * EXIT. * ENDIF. "note 2550268 * For supporting geospatial data processing,the code related to note 2550268 is disabled * Linear Asset Management EhP5 IF cl_ops_switch_check=>eam_sfws_lfe( ) IS NOT INITIAL. CALL METHOD cl_eaml_ea_bapi_util=>set_order_data_buf EXPORTING it_header = it_header[] it_header_up = it_header_up[] it_operation = it_operation[] it_operation_up = it_operation_up[]. ENDIF. * >>>>> Begin note 2304265: DFPS specific checks clear lv_method_del. if cl_check_switch=>dfps_is_active( ) = abap_true. perform dfps_auth_check tables it_header return changing lt_method_level lv_method_del. endif. if lv_method_del = abap_true. * At least one method was deleted by the DFPS change protection checks, therefore it will be checked in the following * if only a save method remains in the processing methods. If yes, this save must no longer be processed. if lines( lt_method_level ) = 1. read table lt_method_level transporting no fields with key method = if_eams_bo_const=>gc_bapi_ord_method-save. if sy-subrc = 0. * only a save method exists ==> delete this method too clear lt_method_level. endif. endif. endif. if lt_method_level is not initial. * <<<<< End note 2304265 * Ausführen der in der Methodentabelle hinterlegten ******* * Methoden ************************************************ CALL FUNCTION 'IBAPI_PROC_METHOD_TABLE_EXEC' EXPORTING it_proc_level_tab = lt_method_level it_order_tab = lt_caufvd it_order_up_tab = lt_caufvd_up it_order_srv_tab = lt_pmsdo it_order_srv_up_tab = lt_pmsdo_up it_userstatus_tab = lt_userstatus it_partner_tab = lt_partner it_partner_up_tab = lt_partner_up it_operation_tab = lt_afvgd it_operation_up_tab = lt_afvgd_up it_relation_tab = lt_afabd it_relation_up_tab = lt_afabd_up it_component_tab = lt_resbd it_component_up_tab = lt_resbd_up it_objectlist_tab = lt_riwol it_objectlist_up_tab = lt_riwol_up it_olist_relation_tab = lt_olist_relation it_cobl_tab = lt_cobl it_cobl_up_tab = lt_cobl_up it_text_tab = lt_text it_text_lines_tab = lt_text_lines it_tasklists = lt_tasklists it_extension_up = lt_extension_up " Note 1989741 it_reforder_item = lt_afpod it_reforder_item_up = lt_afpod_up it_reforder_comp = lt_afpod_resbd it_reforder_comp_up = lt_afpod_resbd_up it_reforder_operation = lt_reford_afvgd it_reforder_serno_olist_ins = lt_serno_olist_ins it_reforder_serno_olist_del = lt_serno_olist_del it_prt = lt_prt it_prt_up = lt_prt_up it_serviceoutline = lt_serviceoutline it_serviceoutline_up = lt_serviceoutline_up it_servicelines = lt_servicelines it_servicelines_up = lt_servicelines_up it_servicelimit = lt_servicelimit it_servicelimit_up = lt_servicelimit_up it_servicecontractlimits = lt_servicecontractlimits it_servicecontractlimits_up = lt_servicecontractlimits_up it_permit = lt_permit it_permit_up = lt_permit_up it_permit_issue = lt_permit_issue iv_mmsrv_external_maintenace = iv_mmsrv_external_maintenace it_estimated_costs = lt_est_cost " 1672966 EAMCC PM110 it_text_add_tab = lt_text_add "note 2756658 it_settlmt_profile = lt_settlmt_profile IMPORTING et_numbers = et_numbers[] et_notif_numbers = et_notification_numbers[] EXCEPTIONS data_for_method_not_found = 1 method_not_supported = 2 error_in_processing = 3 OTHERS = 4. IF sy-subrc NE 0. * Fehler &1 beim Bearbeiten der Bapi-Methoden MESSAGE e113(iwo_bapi2) INTO mess. bapi_message. * New with ERP 2005: If order headers are created BUT subsequent objects * led to an error, the order header update flag is now set to 'IGNORE' for * update processes. PERFORM reset_created_headers USING et_numbers[] lt_method_level. PERFORM end_bapi CHANGING return[]. EXIT. ENDIF. endif. "DFPS note 2304265 * Lesen des Application Logs und zurückgeben der ********** * Meldungen in die Exporttabelle ************************** PERFORM end_bapi CHANGING return[]. ENHANCEMENT-POINT bapi_alm_order_maintain_g7 SPOTS es_saplibapi_alm_order. ENDFUNCTION.
09-04
using UnityEngine; using System.Collections.Generic; [ExecuteInEditMode] public class CubeMirrorReflection : MonoBehaviour { [Tooltip("是否禁用像素光以提高性能")] public bool m_DisablePixelLights = true; [Tooltip("每个面的反射纹理分辨率")] public int m_TextureSize = 256; [Tooltip("裁剪平面偏移量,防止z-fighting")] public float m_ClipPlaneOffset = 0.07f; [Tooltip("反射层掩码,选择哪些层级的物体会被反射")] public LayerMask m_ReflectLayers = -1; [Tooltip("启用哪些面的反射(前、后、左、右)")] public bool enableFront = true, enableBack = true, enableLeft = true, enableRight = true; // 存储每个面的反射相机和纹理 private Dictionary<Camera, Dictionary<Vector3, Camera>> m_ReflectionCameras = new Dictionary<Camera, Dictionary<Vector3, Camera>>(); private Dictionary<Vector3, RenderTexture> m_ReflectionTextures = new Dictionary<Vector3, RenderTexture>(); private Dictionary<Vector3, int> m_OldReflectionTextureSizes = new Dictionary<Vector3, int>(); // 定义四个面的法线方向(本地坐标系) private readonly Vector3[] m_FaceNormals = new Vector3[] { Vector3.forward, // 前 Vector3.back, // 后 Vector3.left, // 左 Vector3.right // 右 }; private readonly string[] m_FaceNames = new string[] { "Front", "Back", "Left", "Right" }; private bool[] m_FaceEnabled = new bool[4]; private static bool s_InsideRendering = false; void Start() { UpdateEnabledFaces(); } void OnValidate() { UpdateEnabledFaces(); } /// <summary> /// 更新启用面的状态 /// </summary> private void UpdateEnabledFaces() { m_FaceEnabled[0] = enableFront; m_FaceEnabled[1] = enableBack; m_FaceEnabled[2] = enableLeft; m_FaceEnabled[3] = enableRight; } /// <summary> /// 当物体即将被渲染时调用 /// </summary> public void OnWillRenderObject() { var rend = GetComponent<Renderer>(); if (!enabled || !rend || !rend.sharedMaterial || !rend.enabled) return; Camera cam = Camera.current; if (!cam) return; if (s_InsideRendering) return; s_InsideRendering = true; // 为每个启用面生成反射 for (int i = 0; i < 4; i++) { if (m_FaceEnabled[i]) { RenderFaceReflection(cam, m_FaceNormals[i], m_FaceNames[i]); } } s_InsideRendering = false; } /// <summary> /// 为特定面渲染反射 /// </summary> private void RenderFaceReflection(Camera currentCamera, Vector3 faceNormal, string faceName) { var rend = GetComponent<Renderer>(); Camera reflectionCamera; CreateMirrorObjects(currentCamera, faceNormal, faceName, out reflectionCamera); if (!reflectionCamera) return; // 计算世界空间中的反射平面位置和法线 Vector3 pos = transform.position; Vector3 normal = transform.TransformDirection(faceNormal); // 将本地法线转换为世界空间 // 可选禁用像素光 int oldPixelLightCount = QualitySettings.pixelLightCount; if (m_DisablePixelLights) QualitySettings.pixelLightCount = 0; UpdateCameraModes(currentCamera, reflectionCamera); // 计算反射平面方程 float d = -Vector3.Dot(normal, pos) - m_ClipPlaneOffset; Vector4 reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d); // 计算反射矩阵 Matrix4x4 reflection = Matrix4x4.zero; CalculateReflectionMatrix(ref reflection, reflectionPlane); Vector3 oldpos = currentCamera.transform.position; Vector3 newpos = reflection.MultiplyPoint(oldpos); reflectionCamera.worldToCameraMatrix = currentCamera.worldToCameraMatrix * reflection; // 设置倾斜投影矩阵 Vector4 clipPlane = CameraSpacePlane(reflectionCamera, pos, normal, 1.0f); Matrix4x4 projection = currentCamera.CalculateObliqueMatrix(clipPlane); reflectionCamera.projectionMatrix = projection; reflectionCamera.cullingMask = ~(1 << 4) & m_ReflectLayers.value; reflectionCamera.targetTexture = m_ReflectionTextures[faceNormal]; // 渲染反射 GL.invertCulling = true; reflectionCamera.transform.position = newpos; Vector3 euler = currentCamera.transform.eulerAngles; reflectionCamera.transform.eulerAngles = new Vector3(0, euler.y, euler.z); reflectionCamera.Render(); reflectionCamera.transform.position = oldpos; GL.invertCulling = false; // 将反射纹理传递给材质 Material[] materials = rend.sharedMaterials; foreach (Material mat in materials) { if (mat.HasProperty("_ReflectionTex" + faceName)) mat.SetTexture("_ReflectionTex" + faceName, m_ReflectionTextures[faceNormal]); } // 恢复像素光设置 if (m_DisablePixelLights) QualitySettings.pixelLightCount = oldPixelLightCount; } /// <summary> /// 禁用时清理资源 /// </summary> void OnDisable() { foreach (var texture in m_ReflectionTextures.Values) { if (texture) DestroyImmediate(texture); } m_ReflectionTextures.Clear(); foreach (var cameraDict in m_ReflectionCameras.Values) { foreach (var reflectionCamera in cameraDict.Values) { if (reflectionCamera != null) DestroyImmediate(reflectionCamera.gameObject); } } m_ReflectionCameras.Clear(); } /// <summary> /// 创建反射所需的对象 /// </summary> private void CreateMirrorObjects(Camera currentCamera, Vector3 faceNormal, string faceName, out Camera reflectionCamera) { reflectionCamera = null; // 创建或更新反射纹理 if (!m_ReflectionTextures.ContainsKey(faceNormal) || !m_ReflectionTextures[faceNormal] || (!m_OldReflectionTextureSizes.ContainsKey(faceNormal) || m_OldReflectionTextureSizes[faceNormal] != m_TextureSize)) { if (m_ReflectionTextures.ContainsKey(faceNormal) && m_ReflectionTextures[faceNormal]) DestroyImmediate(m_ReflectionTextures[faceNormal]); RenderTexture texture = new RenderTexture(m_TextureSize, m_TextureSize, 16); texture.name = $"__CubeMirrorReflection{faceName}_{GetInstanceID()}"; texture.isPowerOfTwo = true; texture.hideFlags = HideFlags.DontSave; m_ReflectionTextures[faceNormal] = texture; m_OldReflectionTextureSizes[faceNormal] = m_TextureSize; } // 获取或创建反射相机 if (!m_ReflectionCameras.ContainsKey(currentCamera)) m_ReflectionCameras[currentCamera] = new Dictionary<Vector3, Camera>(); var cameraDict = m_ReflectionCameras[currentCamera]; if (!cameraDict.ContainsKey(faceNormal) || cameraDict[faceNormal] == null) { GameObject go = new GameObject( $"CubeMirror Refl Camera {faceName} id{GetInstanceID()} for {currentCamera.GetInstanceID()}", typeof(Camera), typeof(Skybox)); reflectionCamera = go.GetComponent<Camera>(); reflectionCamera.enabled = false; reflectionCamera.transform.position = transform.position; reflectionCamera.transform.rotation = transform.rotation; go.AddComponent<FlareLayer>(); go.hideFlags = HideFlags.HideAndDontSave; cameraDict[faceNormal] = reflectionCamera; } else { reflectionCamera = cameraDict[faceNormal]; } } private void UpdateCameraModes(Camera src, Camera dest) { if (dest == null) return; dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent<Skybox>(); Skybox mysky = dest.GetComponent<Skybox>(); if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; } private Vector4 CameraSpacePlane(Camera cam, Vector3 pos, Vector3 normal, float sideSign) { Vector3 offsetPos = pos + normal * m_ClipPlaneOffset; Matrix4x4 m = cam.worldToCameraMatrix; Vector3 cpos = m.MultiplyPoint(offsetPos); Vector3 cnormal = m.MultiplyVector(normal).normalized * sideSign; return new Vector4(cnormal.x, cnormal.y, cnormal.z, -Vector3.Dot(cpos, cnormal)); } private static void CalculateReflectionMatrix(ref Matrix4x4 reflectionMat, Vector4 plane) { reflectionMat.m00 = (1F - 2F * plane[0] * plane[0]); reflectionMat.m01 = (-2F * plane[0] * plane[1]); reflectionMat.m02 = (-2F * plane[0] * plane[2]); reflectionMat.m03 = (-2F * plane[3] * plane[0]); reflectionMat.m10 = (-2F * plane[1] * plane[0]); reflectionMat.m11 = (1F - 2F * plane[1] * plane[1]); reflectionMat.m12 = (-2F * plane[1] * plane[2]); reflectionMat.m13 = (-2F * plane[3] * plane[1]); reflectionMat.m20 = (-2F * plane[2] * plane[0]); reflectionMat.m21 = (-2F * plane[2] * plane[1]); reflectionMat.m22 = (1F - 2F * plane[2] * plane[2]); reflectionMat.m23 = (-2F * plane[3] * plane[2]); reflectionMat.m30 = 0F; reflectionMat.m31 = 0F; reflectionMat.m32 = 0F; reflectionMat.m33 = 1F; } }Shader "Unlit/CubeMirrorSurface" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} [HideInInspector] _ReflectionTexFront ("Front Reflection", 2D) = "white" {} [HideInInspector] _ReflectionTexBack ("Back Reflection", 2D) = "white" {} [HideInInspector] _ReflectionTexLeft ("Left Reflection", 2D) = "white" {} [HideInInspector] _ReflectionTexRight ("Right Reflection", 2D) = "white" {} [HideInInspector] _ReflectionTexUp ("Up Reflection", 2D) = "white" {} [HideInInspector] _ReflectionTexDown ("Down Reflection", 2D) = "white" {} _ReflectionIntensity ("Reflection Intensity", Range(0, 1)) = 1.0 } SubShader { Tags { "RenderType"="Opaque" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; float3 normal : NORMAL; }; struct v2f { float2 uv : TEXCOORD0; float4 reflFront : TEXCOORD1; float4 reflBack : TEXCOORD2; float4 reflLeft : TEXCOORD3; float4 reflRight : TEXCOORD4; float4 reflUp : TEXCOORD5; float4 reflDown : TEXCOORD6; float3 worldNormal : TEXCOORD7; float4 pos : SV_POSITION; }; float4 _MainTex_ST; sampler2D _MainTex; sampler2D _ReflectionTexFront; sampler2D _ReflectionTexBack; sampler2D _ReflectionTexLeft; sampler2D _ReflectionTexRight; sampler2D _ReflectionTexUp; sampler2D _ReflectionTexDown; float _ReflectionIntensity; v2f vert (appdata v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); // 为每个面计算屏幕空间坐标 o.reflFront = ComputeScreenPos(o.pos); o.reflBack = ComputeScreenPos(o.pos); o.reflLeft = ComputeScreenPos(o.pos); o.reflRight = ComputeScreenPos(o.pos); o.reflUp = ComputeScreenPos(o.pos); o.reflDown = ComputeScreenPos(o.pos); // 转换法线到世界空间,用于判断当前渲染的是哪个面 o.worldNormal = UnityObjectToWorldNormal(v.normal); return o; } fixed4 frag (v2f i) : SV_Target { // 采样主纹理 fixed4 tex = tex2D(_MainTex, i.uv); // 采样各面的反射纹理 fixed4 reflFront = tex2Dproj(_ReflectionTexFront, UNITY_PROJ_COORD(i.reflFront)); fixed4 reflBack = tex2Dproj(_ReflectionTexBack, UNITY_PROJ_COORD(i.reflBack)); fixed4 reflLeft = tex2Dproj(_ReflectionTexLeft, UNITY_PROJ_COORD(i.reflLeft)); fixed4 reflRight = tex2Dproj(_ReflectionTexRight, UNITY_PROJ_COORD(i.reflRight)); fixed4 reflUp = tex2Dproj(_ReflectionTexUp, UNITY_PROJ_COORD(i.reflUp)); fixed4 reflDown = tex2Dproj(_ReflectionTexDown, UNITY_PROJ_COORD(i.reflDown)); // 根据世界法线方向混合不同面的反射 float3 absNormal = abs(i.worldNormal); float maxComponent = max(max(absNormal.x, absNormal.y), absNormal.z); fixed4 finalReflection = fixed4(0,0,0,0); // 根据法线方向选择正确的反射面 if (absNormal.z == maxComponent) // Z轴分量最大 - 前或后面 { if (i.worldNormal.z > 0) finalReflection = reflFront; // 前表面 (Z+) else finalReflection = reflBack; // 后表面 (Z-) } else if (absNormal.x == maxComponent) // X轴分量最大 - 左或右面 { if (i.worldNormal.x > 0) finalReflection = reflRight; // 右表面 (X+) else finalReflection = reflLeft; // 左表面 (X-) } else if (absNormal.y == maxComponent) // Y轴分量最大 - 上或下面 { if (i.worldNormal.y > 0) finalReflection = reflUp; // 上表面 (Y+) else finalReflection = reflDown; // 下表面 (Y-) } else { // 默认使用前面反射 finalReflection = reflFront; } // 混合原始纹理和反射 fixed4 result = tex * lerp(fixed4(1,1,1,1), finalReflection, _ReflectionIntensity); return result; } ENDCG } } FallBack "Diffuse" } 以上代码前后两面和左右两面的镜面反射分别怎么实现的
最新发布
11-29
//*********************************************************************************** //Filename: SatellitePosition.cpp // //Date Author Revison History //05/08/2017 Guled Sheikh version 1 // //*********************************************************************************** // //Copyright 2017~2018. All Rights Reserved // //*********************************************************************************** #include "SatellitePosition.h" //Computes the Euclidean distance double SatellitePosition::EucldNorm(double x, double y, double z) { double norm = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)); return norm; } // Fucntion that returns satellite positions corrected for Earth rotation errors vector<double> SatellitePosition::EarthRot_Corr(double time, vector<double> pos) { /*...Returns rotated satellite ECEF coordinates due to Earth rotation during signal travel time /*....time represents the travel time...*/ /*....WGS 84 value of the earth's rotation rate (rad/sec)...*/ double OMEGA_e = 7.2921151467e-5; double OMEGA_tau = OMEGA_e*time; Eigen::Matrix3d R3; Eigen::Vector3d POS_ROT; Eigen::Vector3d POS(pos[0], pos[1], pos[2]); vector <double> POSITION; double R11, R12, R13, R21, R22, R23, R31, R32, R33; R11 = cos(OMEGA_tau); R21 = -sin(OMEGA_tau); R31 = 0; R12 = sin(OMEGA_tau); R22 = cos(OMEGA_tau); R32 = 0; R13 = 0; R23 = 0; R33 = 1; R3 << R11, R12, R13, R21, R22, R23, R31, R32, R33; POS_ROT = R3*POS; POSITION.push_back(POS_ROT[0]); POSITION.push_back(POS_ROT[1]); POSITION.push_back(POS_ROT[2]); return POSITION; } // Function that corrects for tropospheric effects double SatellitePosition::Tropo_Corr(vector<double> pos, vector<double> ini_pos) { Eigen::Vector3d POS(pos[0], pos[1], pos[2]); Eigen::Vector3d INI_POS(ini_pos[0], ini_pos[1], ini_pos[2]); double dtrop; double tot_p = 1013; // Mbar double pwv = 16; //Mbar double pd = tot_p - pwv; // Mbar double T = 300; // Kelvins double R = 6371e3; double sat_pos_norm = EucldNorm(pos[0], pos[1], pos[2]); double rec_pos_norm = EucldNorm(ini_pos[0], ini_pos[1], ini_pos[2]); double g = acos((POS.dot(INI_POS)) / (sat_pos_norm*rec_pos_norm)); double e = atan((sat_pos_norm*cos(g) - R) / (sat_pos_norm*sin(g))); //cout << (e*180)/ PI << endd; //cin.get(); double z = (PI / 2) - e; if (z == 0) { dtrop = (0.002277 / cos(z))*(pd + (((1255 / T) + 0.05)*pwv)); } else { dtrop = (0.002277 / cos(z))*(pd + (((1255 / T) + 0.05)*pwv) - (1.16*(pow(tan(z), 2)))); } return dtrop; } // This function removes effects of ionosphere based on the iono-free model double SatellitePosition::iono_free(double count) { double gamma = pow((1575.42 / 1227.6), 2); double P1_temp = 0.0, P2_temp = 0.0, PR_temp = 0.0, C1_temp = 0.0; // Finding the pseudoranges if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P1") - RinexFile->head.obstype.begin() != 0) { ptrdiff_t pos_P1 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P1") - RinexFile->head.obstype.begin(); if (pos_P1 == RinexFile->head.obstype.size()) { } else { P1_temp = RinexFile->obs.record[count][pos_P1]; } } if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P2") - RinexFile->head.obstype.begin() != 0) { ptrdiff_t pos_P2 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P2") - RinexFile->head.obstype.begin(); if (pos_P2 == RinexFile->head.obstype.size()) { } else { P2_temp = RinexFile->obs.record[count][pos_P2]; } } if (P2_temp != 0 && P1_temp != 0) { PR_temp = (P2_temp - (gamma*P1_temp)) / (1 - gamma); } else { ptrdiff_t pos_PR = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "C1") - RinexFile->head.obstype.begin(); PR_temp = RinexFile->obs.record[count][pos_PR]; } return PR_temp; } // This function removes effects of ionosphere based on the Klobuchar model double SatellitePosition::klobuchar(double fi, double lambda, double elev, double azimuth, double tow) { VectorXd alfa; VectorXd beta; alfa << 9.3132e-09, 1.4901e-08, -5.9605e-08, -1.1921e-07; beta << 8.8064e+04, 4.9152e+04, -1.3107e+05, -3.2768e+05; double c = 299792458, deg2semi = 1.0 / 180.0, semi2rad = PI, deg2rad = PI / 180.0, dIon1; double a = azimuth*deg2rad; // asimuth in radians double e = elev*deg2semi; // elevation angle in semicircles double psi = 0.0137 / (e + 0.11) - 0.022; //Earth Centered angle double lat_i = fi*deg2semi + psi*cos(a); // Subionospheric lat if (lat_i > 0.416) { lat_i = 0.416; } else if (lat_i < -0.416) { lat_i = -0.416; } //Subionospheric long double long_i = lambda*deg2semi + (psi*sin(a) / cos(lat_i*semi2rad)); // Geomagnetic latitude double lat_m = lat_i + 0.064*cos((long_i - 1.617)*semi2rad); double t = 4.32e4*long_i + tow; t = fmod(t, 86400.0); // Seconds of day if (t > 86400.0) { t = t - 86400.0; } if (t < 86400.0) { t = t + 86400.0; } double sF = 1.0 + 16.0* pow((0.53 - e), 3); // Slant factor // Period of model double PER = beta(0) + beta(1)*lat_m + beta(2)* pow(lat_m, 2) + beta(3)* pow(lat_m, 3); if (PER < 72000.0) { PER = 72000.0; } double x = 2.0*PI*(t - 50400.0) / PER; // Phase of the model double AMP = alfa(0) + alfa(1) *lat_m + alfa(2) * pow(lat_m, 2) + alfa(3) * pow(lat_m, 3); // Amplitud of the model if (AMP < 0.0) { AMP = 0.0; } if (abs(x) > 1.57) { dIon1 = sF * (5.0e-9); } else { dIon1 = sF * (5.0e-9 + AMP*(1.0 - x*x / 2.0 + x*x*x*x / 24.0)); } return dIon1; } // This function computes the gps time in seconds double SatellitePosition::gpstimeCalc(double year, double month, double day, double hour, double min, double sec) { double y, m, JD, gps_week, gps_seconds; double secs_per_week = 604800; // Seconds in one week //Converts the two digit year to a four digit year. //Two digit year represents a year in the range 1980 - 2079. if (year >= 80 && year <= 99) { year = 1900 + year; } if (year >= 0 && year <= 79) { year = 2000 + year; } //Calculates the 'm' term used below from the given calendar month. if (month <= 2) { y = year - 1; m = month + 12; } if (month > 2) { y = year; m = month; } //Computes the Julian date corresponding to the given calendar date. JD = floor((365.25 * y)) + floor((30.6001 * (m + 1))) + day + ((hour + min / 60 + sec / 3600) / 24) + 1720981.5; //Computes the GPS week corresponding to the given calendar date. gps_week = floor((JD - 2444244.5) / 7); //Computes the GPS seconds corresponding to the given calendar date. gps_seconds = round(((((JD - 2444244.5) / 7) - gps_week)*secs_per_week) / 0.5)*0.5; return gps_seconds; } //This functions corrects for tropospheric effects based on initial values given in the navigation file double SatellitePosition::NMF_hyd(double sat_elev) { double A = 33.748; double B = -0.782; double A1 = 38.079; double B1 = -0.8088; double Y1 = A*pow(sat_elev, B); double Y2 = A1*pow(sat_elev, B1); double Y = Y1 + Y2; return Y; } // This function initializes the observation and navigation filenames void SatellitePosition::SetFilenames(const char * ObsFile, const char * NavFile) { size_t obs_size = strlen(ObsFile); size_t nav_size = strlen(NavFile); if (ObsFile != NULL) { strcpy(obsFile, ObsFile); } if (NavFile != NULL) { strcpy(navFile, NavFile); } obsFile[obs_size] = '\0'; navFile[nav_size] = '\0'; RinexFile = new reader(SatellitePosition::obsFile, SatellitePosition::navFile); RinexFile->rinexNAVReader(RinexFile->SV_data); } //This function opens the observation and navigation files from the environment file void SatellitePosition::OpenEnvFile(ENVI_FILE & envi_records, SatellitePosition & object1, SatellitePosition & object2) { Env_File = fopen("EnvFileGMIS.txt", "rt"); if (Env_File == NULL) perror("Error opening file"); char line[MAX_STRLEN]; fgets(line, MAX_STRLEN, Env_File); while (!feof(Env_File)) { if (sizeof(line) >= 61) { if (strstr(line, "VERSION / TYPE")) { string sline(line); // convert the line (char) to string class type sLine string token = sline.substr(4, 4); // from 4th character and 4 spaces envi_records.version = token; } if (strstr(line, "BASE FILE(OBS/NAV)")) { std::istringstream iss(line); std::vector<std::string> results((std::istream_iterator<std::string>(iss)), std::istream_iterator<std::string>()); Filename1_Obs = results[0]; Filename1_Nav = results[1]; object1.SetFilenames(Filename1_Obs.c_str(), Filename1_Nav.c_str()); } if (strstr(line, "ROVER FILE(OBS/NAV)")) { std::istringstream iss2(line); std::vector<std::string> results2((std::istream_iterator<std::string>(iss2)), std::istream_iterator<std::string>()); Filename2_Obs = results2[0]; Filename2_Nav = results2[1]; object2.SetFilenames(Filename2_Obs.c_str(), Filename2_Nav.c_str()); } if (strstr(line, "BASE FINAL COORDINATES")) { string sline(line); // convert the line (char) to string class type sLine string token = sline.substr(4, 56); // from 4th character upto 56 char cline[MAX_BYTE]; // cline is a char line strncpy(cline, token.c_str(), sizeof(cline)); cline[sizeof(cline) - 1] = 0; for (char * r = strtok(cline, " "); r; r = strtok(NULL, " ")) { double rr = atof(r); envi_records.base_final_coord.push_back(rr); } } } //......... Get a new line....................... fgets(line, MAX_STRLEN, Env_File); } } // This function computes the satellite positions and stores them in a global file void SatellitePosition::Sat_Pos(SATPOS_struct &EPOCH_DATA) { RinexFile->rinexOBSReader(RinexFile->head, RinexFile->obs, RinexFile->SENTINEL); // Read the observation file epoch_count = epoch_count + 1; vector< vector<double> > pos_rot_epoch_temp; vector< vector<double> > initial_satpos_temp; vector <double> pr_epoch_temp; vector <double> P1_epoch_temp; vector <double> P2_epoch_temp; vector <double> C1_epoch_temp; vector <double> L1_epoch_temp; vector <double> L2_epoch_temp; vector <double> pr_epoch_Iono_temp; vector <double> sat_offset_epoch_temp; vector<double> sat_elev_temp; double Tropo; reader::NAVRECORDS storer; if (RinexFile->obs.NumOfSat != 0) { double count = 0; for (int j = 0; j < RinexFile->obs.NumOfSat; j++) { // Each satellite double gamma = pow((1575.42 / 1227.6), 2); double c = 299792458; double P1_temp = 0.0, P2_temp = 0.0, PR_temp = 0.0, L1_temp = 0.0, L2_temp = 0.0, C1_temp = 0.0, TIME_temp; //reader::NAVRECORDS storer; int curPrn = RinexFile->obs.prn[count]; // Current observation satelite vehicle double time_LOGGER = std::numeric_limits<double>::max(); //search through the navigation file for (size_t k = 0; k < RinexFile->SV_data.size(); k++) { if (RinexFile->SV_data[k].PRN == curPrn) { //Compare obs prn with nav prn if (time_LOGGER > abs(RinexFile->SV_data[k].gpstime - RinexFile->obs.time)) { time_LOGGER = abs(RinexFile->SV_data[k].gpstime - RinexFile->obs.time); storer = RinexFile->SV_data[k]; } } } // Finding the pseudoranges P1 code if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P1") - RinexFile->head.obstype.begin() != RinexFile->head.nobstype) { ptrdiff_t pos_P1 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P1") - RinexFile->head.obstype.begin(); if (pos_P1 == RinexFile->head.obstype.size()) { } else { P1_temp = RinexFile->obs.record[j][pos_P1]; } } // Finding the pseudoranges P2 code if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P1") - RinexFile->head.obstype.begin() != RinexFile->head.nobstype) { ptrdiff_t pos_P2 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "P1") - RinexFile->head.obstype.begin(); if (pos_P2 == RinexFile->head.obstype.size()) { } else { P2_temp = RinexFile->obs.record[j][pos_P2]; } } // Finding the pseudoranges L1 carrier if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "L1") - RinexFile->head.obstype.begin() != RinexFile->head.nobstype) { ptrdiff_t pos_L1 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "L1") - RinexFile->head.obstype.begin(); if (pos_L1 == RinexFile->head.obstype.size()) { } else { L1_temp = RinexFile->obs.record[j][pos_L1]; } } // Finding the pseudoranges L2 carrier if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "L2") - RinexFile->head.obstype.begin() != RinexFile->head.nobstype) { ptrdiff_t pos_L2 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "L2") - RinexFile->head.obstype.begin(); if (pos_L2 == RinexFile->head.obstype.size()) { } else { L2_temp = RinexFile->obs.record[j][pos_L2]; } } // Finding the pseudoranges C1 code if (find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "C1") - RinexFile->head.obstype.begin() != RinexFile->head.nobstype) { ptrdiff_t pos_C1 = find(RinexFile->head.obstype.begin(), RinexFile->head.obstype.end(), "C1") - RinexFile->head.obstype.begin(); if (pos_C1 == RinexFile->head.obstype.size()) { } else { C1_temp = RinexFile->obs.record[j][pos_C1]; } } PR_temp = iono_free(j); TIME_temp = RinexFile->obs.time - (PR_temp / c); //GPS system time at time of transmission corrected for transit time // SATELLITE POSITIONING // Constants //WGS 84 value of the earth's gravitational constant for GPS user double mu = 3.986005e14; //WGS 84 value of the earth's rotation rate (rad/sec) double OMEGA_e = 7.2921151467e-5; // Initialize necessary variables from NAV double A = pow(storer.Sqrta, 2); //Semi-major axis double toe = storer.Toe; //toe = Time of Ephemeris double deltaN = storer.DeltaN; //Delta n double Mo = storer.Mo; // Mo angle double e = storer.Eccentricity; //Orbit Eccentricity double omega = storer.omega; //omega Angle // Second Harmonic Perturbations double Cus = storer.Cus; //Latitude Correction Sinus Component double Cuc = storer.Cuc; //Latitude Correction Cosinus Component double Crs = storer.Crs; //Radius Correction Sinus Component double Crc = storer.Crc; //Radius Correction Cosinus Component double Cis = storer.Cis; //Angular Velocity double Cic = storer.Cic; //Inclination Correction Cosinus Component double IDOT = storer.IDOT; //Inclination Rate double Io = storer.Io; //Initial Inclination double OMEGA = storer.OMEGA; //OMEGA Angle double OMEGADOT = storer.OMEGADOT; //Angular Velocity double SVCB = storer.SVClockBias; //SVClockBias (sec) double SVCD = storer.SVClockDrift; //SVClockDrift (sec) double SVCDR = storer.SVClockDriftRate; //SVClockDriftRate (sec) double SAT_TIME = storer.gpstime; //double SAT_TIME = storer.SEC; double tk = TIME_temp - toe; //Time from ephemeris reference epoch // Correct tk within range of -302400 to 302400 if (tk > 302400) { tk = tk - 604800; } else if (tk < -302400) { tk = tk + 604800; } // Computed mean motion (rad/sec) double n0 = sqrt(mu / (pow(A, 3))); // Corrected mean motion double n = n0 + deltaN; //Mean anomaly double Mk = Mo + n*tk; // Keep Mk with in 360 degrees ....// Mk = rem(Mk+2*pi,2*pi); // Kepler's Equation for Eccentric Anomaly (may be solved by iteration)(radians) double Ek = Mk; double Ek0 = Mk + e*sin(Ek); double limit = 1e-11; // limit while (abs(Ek - Ek0) > limit) { Ek0 = Ek; Ek = Mk + e*sin(Ek0); } // Keep Ek with in 360 degrees.....// Ek = rem(Ek + 2 * pi, 2 * pi); // True Anomaly double Y = (sqrt(1 - pow(e, 2))*sin(Ek)) / (1 - e*cos(Ek)); double X = (cos(Ek) - e) / (1 - e*cos(Ek)); double vk = atan2(Y, X); //Argument of Latitude double Phi_k = vk + omega; double del_uk = Cus*sin(2 * Phi_k) + Cuc*cos(2 * Phi_k); // Argument of Latitude Correction double del_rk = Crs*sin(2 * Phi_k) + Crc*cos(2 * Phi_k); //Radius Correction double del_ik = Cis*sin(2 * Phi_k) + Cic*cos(2 * Phi_k); //Inclination Correction //Corrected Argument of Latitude double uk = Phi_k + del_uk; //Corrected Radius double rk = A*(1 - e*cos(Ek)) + del_rk; //Corrected Inclination double ik = Io + del_ik + IDOT*tk; //Positions in orbital plane. double xk_prime = rk*cos(uk); double yk_prime = rk*sin(uk); //Corrected longitude of ascending node double OMEGA_k = OMEGA + (OMEGADOT - OMEGA_e)*tk - OMEGA_e*toe; //Earth-fixed coordinates double xk = xk_prime*cos(OMEGA_k) - yk_prime*cos(ik)*sin(OMEGA_k); double yk = xk_prime*sin(OMEGA_k) + yk_prime*cos(ik)*cos(OMEGA_k); double zk = yk_prime*sin(ik); // Satellite position without tropo, iono and Earth rotation corrections vector <double> POSITION; //Store the Earth-fixed coordinates (satellite position xk,yk,zk of satellite k) POSITION.push_back(xk); POSITION.push_back(yk); POSITION.push_back(zk); // Satellite elevation angle calculation //--------------------------------------------------------------------------------------------------------------// Eigen::Vector3d POS(POSITION[0], POSITION[1], POSITION[2]); Eigen::Vector3d INI_POS(RinexFile->head.antpos[0], RinexFile->head.antpos[1], RinexFile->head.antpos[2]); double R = 6371e3; double sat_pos_norm = EucldNorm(POSITION[0], POSITION[1], POSITION[2]); double rec_pos_norm = EucldNorm(RinexFile->head.antpos[0], RinexFile->head.antpos[1], RinexFile->head.antpos[2]); double g = acos((POS.dot(INI_POS)) / (sat_pos_norm*rec_pos_norm)); double sat_elev = (atan((sat_pos_norm*cos(g) - R) / (sat_pos_norm*sin(g))))*(180 / PI); // in degrees sat_elev_temp.push_back(sat_elev); // store the current satellite elevation //----------------------------------------------------------------------------------------------------------------// // CUT_OFF ANGLE OF 15 DEGREES if (sat_elev >= 15) { // Realativistic Correction Term (sec) double F = -4.442807633e-10; double Del_tr = F*e*sqrt(A)*sin(Ek); // Realativistic Correction Term(sec) // Satellite Clock Errors (sec) double Del_tsv = SVCB + SVCD*(SAT_TIME - toe) + SVCDR*(pow((SAT_TIME - toe), 2)) + Del_tr; // CORRECTIONS // Range before earth rotation correction double geom_range = EucldNorm((POSITION[0] - RinexFile->head.antpos[0]), (POSITION[1] - RinexFile->head.antpos[1]), (POSITION[2] - RinexFile->head.antpos[2])); double t = (geom_range) / c; // CORRECTIONS // Earth rotation correction vector <double> POSITION_ROT = EarthRot_Corr(t, POSITION); double geom_range_corr = EucldNorm((POSITION_ROT[0] - RinexFile->head.antpos[0]), (POSITION_ROT[1] - RinexFile->head.antpos[1]), (POSITION_ROT[2] - RinexFile->head.antpos[2])); pos_rot_epoch_temp.push_back(POSITION_ROT); double check_pseudo = (PR_temp - geom_range_corr) + c*(Del_tsv); // Tropo correction //double dtropo = NMF_hyd(sat_elev); // Niell Mapping Function double dtropo = Tropo_Corr(POSITION_ROT, RinexFile->head.antpos); // SAASTAMOINEN //Tropo = dtropo; // Corrected pseudorange for iono only pr_epoch_Iono_temp.push_back(PR_temp); // Corrected pseudorange for iono and tropo //double Corr_Pseudo = PR_temp - dtropo; doing tropo correc in kalman!!!!! double Corr_Pseudo = PR_temp - dtropo; pr_epoch_temp.push_back(Corr_Pseudo); P1_epoch_temp.push_back(P1_temp); P2_epoch_temp.push_back(P2_temp); C1_epoch_temp.push_back(C1_temp); L1_epoch_temp.push_back(L1_temp); L2_epoch_temp.push_back(L2_temp); sat_offset_epoch_temp.push_back(Del_tsv); initial_satpos_temp.push_back(POSITION); count = count + 1; } else { //remove the satellite from the prn vector count = count; RinexFile->obs.prn.erase(RinexFile->obs.prn.begin() + count); } } EPOCH_DATA.Sat_elev = sat_elev_temp; // Satellite elevations for the epoch EPOCH_DATA.pos_rot_epoch = pos_rot_epoch_temp; // corrected satellite positions for the epoch EPOCH_DATA.Initial_SatPos = initial_satpos_temp; EPOCH_DATA.pr_epoch = pr_epoch_temp; // Corrected pseudorange EPOCH_DATA.P1_epoch = P1_epoch_temp; EPOCH_DATA.P2_epoch = P2_epoch_temp; EPOCH_DATA.C1_epoch = C1_epoch_temp; EPOCH_DATA.L1_epoch = L1_epoch_temp; EPOCH_DATA.L2_epoch = L2_epoch_temp; EPOCH_DATA.pr_epoch_iono = pr_epoch_Iono_temp; EPOCH_DATA.sat_offset_epoch = sat_offset_epoch_temp; // satellite clock offset } } 讲解该代码
08-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值