Double linked list structure

本文详细介绍了双链表的基本结构及各种操作实现,包括初始化、插入、删除等关键方法,并提供了具体的伪代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1 // Double linked list structure. Can be used as either a list head, or as link words.
 2 
 3 // @struct USBH_DLIST |
 4 //   The USBH_DLIST structure is the link element of the double linked list. It is used as either a list head, or as link entry.
 5 // @field  struct tDLIST * | Flink |
 6 //   Pointer to the successor (forward link).
 7 // @field  struct tDLIST * | pPrev |
 8 //   Pointer to the predecessor (backward link).
 9 // @comm By means of such elements any structures may be handled as a double linked list. The USBH_DLIST structure is to be inserted
10 //   into the structure which is to be handled. A pointer to the original structure can be obtained by means of the macro <f STRUCT_BASE_POINTER>.
11 typedef struct USBH_DLIST USBH_DLIST;
12 struct USBH_DLIST {
13   USBH_DLIST * pNext;
14   USBH_DLIST * pPrev;
15 };
16 
17 void         USBH_DLIST_Append     (USBH_DLIST * ListHead, USBH_DLIST * List);
18 void         USBH_DLIST_InsertTail (USBH_DLIST * ListHead, USBH_DLIST * Entry);
19 void         USBH_DLIST_InsertHead (USBH_DLIST * ListHead, USBH_DLIST * Entry);
20 void         USBH_DLIST_InsertEntry(USBH_DLIST * Entry,    USBH_DLIST * NewEntry);
21 void         USBH_DLIST_RemoveTail (USBH_DLIST * ListHead, USBH_DLIST ** Entry);
22 void         USBH_DLIST_RemoveHead (USBH_DLIST * ListHead, USBH_DLIST ** Entry);
23 void         USBH_DLIST_RemoveEntry(USBH_DLIST * Entry);
24 USBH_DLIST * USBH_DLIST_GetPrev    (USBH_DLIST * Entry);
25 USBH_DLIST * USBH_DLIST_GetNext    (USBH_DLIST * Entry);
26 int          USBH_DLIST_IsEmpty    (USBH_DLIST * ListHead);
27 void         USBH_DLIST_Init       (USBH_DLIST * ListHead);
28 
29 
30 /*********************************************************************
31 *
32 *       USBH_DLIST
33 */
34 typedef struct USBH_DLIST_ITEM {
35   struct USBH_DLIST_ITEM * pNext;
36   struct USBH_DLIST_ITEM * pPrev;
37 } USBH_DLIST_ITEM;
38 
39 typedef struct {
40   struct USBH_DLIST_ITEM * pFirst;
41   int NumItems;
42 } USBH_DLIST_HEAD;
43 
44 void USBH_DLIST_Remove(USBH_DLIST_HEAD * pHead, USBH_DLIST_ITEM * pItem);
45 void USBH_DLIST_Add   (USBH_DLIST_HEAD * pHead, USBH_DLIST_ITEM * pNew);
  1 typedef struct USBH_DLIST USBH_DLIST;
  2 struct USBH_DLIST
  3 {
  4   USBH_DLIST * pNext;
  5   USBH_DLIST * pPrev;
  6 };
  7 
  8 // USBH_DLIST_Init
  9 //     STR     R0, [R0,#4]
 10 //     STR     R0, [R0]
 11 //     BX      LR
 12 void USBH_DLIST_Init(USBH_DLIST * ListHead)
 13 {
 14   ListHead->pPrev = ListHead;
 15   ListHead->pNext = ListHead;
 16 }
 17 
 18 // USBH_DLIST_Append
 19 //     LDR     R2, [R0,#4]
 20 //     STR     R1, [R2]
 21 //     LDR     R3, [R1,#4]
 22 //     STR     R0, [R3]
 23 //     LDR     R3, [R1,#4]
 24 //     STR     R3, [R0,#4]
 25 //     STR     R2, [R1,#4]
 26 //     BX      LR
 27 
 28 //  /---<<<<<<<<<<<<<<<<<<<<<<pNext---\         /---<<<<<<<<<<<<<<<<<<pNext---\
 29 //  ListHead <----> 0 <----> 1 <----> N         List <----> 0 <----> 1 <----> N
 30 //  pPrev >>>>>>>>>>>>>>>>>>>>>>>>>---/         pPrev >>>>>>>>>>>>>>>>>>>>>---/
 31 //
 32 //  /---<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<pNext---\
 33 //  ListHead <----> 0 <----> 1 <----> N <---->  List <----> 0 <----> 1 <----> N
 34 //  pPrev >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>---/
 35 void USBH_DLIST_Append(USBH_DLIST * ListHead, USBH_DLIST * List)
 36 {
 37   ListHead->pPrev->pNext = List;
 38   List->pPrev->pNext = ListHead;
 39   ListHead->pPrev = List->pPrev;
 40   List->pPrev = ListHead->pPrev;
 41 }
 42 
 43 // USBH_DLIST_IsEmpty
 44 //     LDR     R1, [R0]
 45 //     CMP     R1, R0
 46 //     ITE EQ
 47 //     MOVEQ   R0, #1
 48 //     MOVNE   R0, #0
 49 //     BX      LR
 50 int USBH_DLIST_IsEmpty(USBH_DLIST * ListHead)
 51 {
 52   return ListHead == ListHead->pNext;
 53 }
 54 
 55 // USBH_DLIST_GetNext          USBH_DLIST_GetPrev
 56 //     LDR     R0, [R0]            LDR     R0, [R0,#4]
 57 //     BX      LR                  BX      LR
 58 USBH_DLIST * USBH_DLIST_GetNext(USBH_DLIST * Entry)
 59 {
 60   return Entry->pNext;
 61 }
 62 USBH_DLIST * USBH_DLIST_GetPrev(USBH_DLIST * Entry)
 63 {
 64   return Entry->pPrev;
 65 }
 66 
 67 //                             USBH_DLIST_RemoveHead     USBH_DLIST_RemoveTail
 68 //                                LDR     R0, [R0]          LDR     R0, [R0,#4]
 69 // USBH_DLIST_RemoveEntry         STR     R0, [R1]          STR     R0, [R1]
 70 //
 71 //    LDRD.W  R1, R2, [R0]        LDRD.W  R1, R2, [R0]      LDRD.W  R1, R2, [R0]
 72 //    STR     R1, [R2]            STR     R1, [R2]          STR     R1, [R2]
 73 //
 74 //    LDRD.W  R1, R2, [R0]        LDRD.W  R1, R2, [R0]      LDRD.W  R1, R2, [R0]
 75 //    STR     R2, [R1,#4]         STR     R2, [R1,#4]       STR     R2, [R1,#4]
 76 //
 77 //    STR     R0, [R0,#4]         STR     R0, [R0,#4]       STR     R0, [R0,#4]
 78 //    STR     R0, [R0]            STR     R0, [R0]          STR     R0, [R0]
 79 //    BX      LR                  BX      LR                BX      LR
 80 
 81 // pPrev [ Entry ] pNext ---> pPrev pNext
 82 void USBH_DLIST_RemoveEntry(USBH_DLIST * Entry)
 83 {
 84   Entry->pPrev->pNext = Entry->pNext;
 85   Entry->pNext->pPrev = Entry->pPrev;
 86   //USBH_DLIST_Init( Entry );
 87   Entry->pPrev = Entry;
 88   Entry->pNext = Entry;
 89 }
 90 
 91 
 92 void USBH_DLIST_RemoveHead(USBH_DLIST * ListHead, USBH_DLIST ** Entry)
 93 {
 94   (*Entry)->pNext = ListHead->pNext;
 95   USBH_DLIST_RemoveEntry( ListHead->pNext );
 96 }
 97 
 98 
 99 void USBH_DLIST_RemoveTail(USBH_DLIST * ListHead, USBH_DLIST ** Entry)
100 {
101   (*Entry)->pNext = ListHead->pPrev;
102   USBH_DLIST_RemoveEntry( ListHead->pPrev );
103 }
104 
105 //                                                       USBH_DLIST_InsertTail
106 // USBH_DLIST_InsertEntry      USBH_DLIST_InsertHead         LDR     R0, [R0,#4]
107 //     LDR     R2, [R0]            LDR     R2, [R0]          LDR     R2, [R0]
108 //     STRD.W  R2, R0, [R1]        STRD.W  R2, R0, [R1]      STRD.W  R2, R0, [R1]
109 //     LDR     R2, [R0]            LDR     R2, [R0]          LDR     R2, [R0]
110 //     STR     R1, [R2,#4]         STR     R1, [R2,#4]       STR     R1, [R2,#4]
111 //     STR     R1, [R0]            STR     R1, [R0]          STR     R1, [R0]
112 //     BX      LR                  BX      LR                BX      LR
113 
114 void USBH_DLIST_InsertEntry(USBH_DLIST * Entry, USBH_DLIST * NewEntry)
115 {
116   NewEntry->pNext = Entry->pNext;
117   NewEntry->pPrev = Entry;
118 
119   Entry->pNext->pPrev = NewEntry;
120   Entry->pNext = NewEntry;
121 }
122 
123 void USBH_DLIST_InsertHead(USBH_DLIST * ListHead, USBH_DLIST * Entry)
124 {
125   USBH_DLIST_InsertEntry( ListHead, Entry );
126 }
127 
128 void USBH_DLIST_InsertTail(USBH_DLIST * ListHead, USBH_DLIST * Entry)
129 {
130   USBH_DLIST_InsertEntry( ListHead->pPrev, Entry );
131 }
132 
133 // -------------------------------------------------------------------------------
134  typedef struct USBH_DLIST_ITEM {
135    struct USBH_DLIST_ITEM * pNext;
136    struct USBH_DLIST_ITEM * pPrev;
137  } USBH_DLIST_ITEM;
138 
139  typedef struct {
140    struct USBH_DLIST_ITEM * pFirst;
141    int NumItems;
142  } USBH_DLIST_HEAD;
143 
144 
145 void USBH_DLIST_InitHead(USBH_DLIST_HEAD * pHead)
146 {
147   pHead->pFirst = 0;
148   pHead->NumItems = 0;
149 }
150 
151 // USBH_DLIST_Add
152 //     MOVS    R2, #0
153 //     STR     R2, [R1,#4]   ; pNew->pPrev = 0;
154 //
155 //     LDR     R2, [R0]
156 //     STR     R2, [R1]      ; pNew->pNext = pHead->pFirst;
157 //
158 //     LDR     R2, [R0]
159 //     CMP     R2, #0
160 //     IT NE                 ; pHead->pFirst != 0
161 //     STRNE   R1, [R2,#4]   ; pHead->pFirst->pPrev = pNew;
162 //
163 //     STR     R1, [R0]      ; pHead->pFirst = pNew;
164 //     BX      LR
165 //
166 //  pFirst --> pNew
167 //  0 <------- pNew ----> 0
168 //
169 //  0 <------- pNew ----> pOld
170 //  pNew <---- pOld ----> 0
171 //
172 void USBH_DLIST_Add(USBH_DLIST_HEAD * pHead, USBH_DLIST_ITEM * pNew)
173 {
174   pNew->pPrev = 0;
175   pNew->pNext = 0;
176   if (pHead->pFirst != 0)
177   {
178     pNew->pNext = pHead->pFirst;
179     pHead->pFirst->pPrev = pNew;
180   }
181   pHead->pFirst = pNew;
182   //pHead->NumItems++;
183 }
184 
185 // USBH_DLIST_Remove
186 //     LDR     R3, [R0]
187 //     LDR     R2, [R1]
188 //
189 //     CMP     R3, R1
190 //     IT NE
191 //     LDRNE   R0, [R1,#4]
192 //     STR     R2, [R0]
193 //
194 //     LDR     R0, [R1]
195 //     CMP     R0, #0
196 //     ITT NE
197 //     LDRNE   R1, [R1,#4]
198 //     STRNE   R1, [R0,#4]
199 //
200 //     BX      LR
201 
202 //
203 void USBH_DLIST_Remove(USBH_DLIST_HEAD * pHead, USBH_DLIST_ITEM * pItem)
204 {
205   if (pHead->pFirst == pItem)
206     pHead->pFirst->pNext = pItem->pNext;
207   else
208     pItem->pPrev->pNext = pItem->pNext;
209 
210   if (pItem->pNext != 0)
211   {
212     pHead->NumItems = (int)pItem->pPrev;
213   }
214 }

 

UF_MODL_ask_bounding_box(bodyTag, minPoint, maxPoint);“maxPoint”函数调用中的参数太多 ,参考以下文档:/***************************************************************************** Copyright (c) 1999-2007 UGS Corp. All Rights Reserved File description: Open API modeling utility functions. *****************************************************************************/ #ifndef UF_MODL_UTILITIES_H_INCLUDED #define UF_MODL_UTILITIES_H_INCLUDED /*************************************************************************** ***************************************************************************/ #include <uf_defs.h> #include <uf_modl_types.h> #include <libufun_exports.h> #ifdef __cplusplus extern "C" { #endif /**************************************************************************** This function cycles the database for the first, or next, available object that matches both the type, and subtype, for the values entered. When searching for the first object, just input a NULL_TAG for the value of object identifier. Then, when you need the next object, just input the previous value, and the next matching object is returned to the user. When the final object has been returned to the user, the next call to UF_MODL_ask_object() returns a NULL_TAG value for obj_id and an integer return code that corresponds to "Invalid object type" when input into UF_get_fail_message. Environment: Internal and External See Also: History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_object( int ug_type ,/* <I> Object Type */ int ug_subtype ,/* <I> Object subtype */ tag_t * object /* <I/O> Object's object identifier within a file */ ); /**************************************************************************** Retrieves the count from a linked list of objects. A list of objects may contain identifiers for bodies, features, faces, and edges. If one of the nodes in the list contains an object identifier that is a NULL_TAG, it is possible to receive an incorrect count. Environment: Internal and External See Also: UF_MODL_ask_list_item UF_MODL_create_list UF_MODL_delete_list UF_MODL_put_list_item UF_MODL_delete_list_item History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_list_count( uf_list_p_t list ,/* <I> List of object identifiers. */ int * count /* <O> Count of items in linked list. */ ); /**************************************************************************** Retrieves an object from a linked list of objects. A list of objects may contain identifiers for bodies, features, faces, and edges. Normal C indexing is used; i.e., the list begins at zero. Environment: Internal and External See Also: UF_MODL_create_list UF_MODL_delete_list UF_MODL_ask_list_count UF_MODL_put_list_item UF_MODL_delete_list_item History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_list_item( uf_list_p_t list ,/* <I> List of object identifiers. */ int index ,/* <I> Count into the list. */ tag_t * object /* <O> Object to be located. */ ); /**************************************************************************** Adds the input object identifier to the end of the list that you input. NOTE: Duplicate tags added to the list are ignored. Environment: Internal and External See Also: UF_MODL_ask_list_item UF_MODL_create_list UF_MODL_delete_list UF_MODL_ask_list_count UF_MODL_delete_list_item History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_put_list_item( uf_list_p_t list ,/* <I> List of object identifiers. */ tag_t obj_id /* <I> Object identifier to put into list */ ); /**************************************************************************** Creates a linked list of objects. A list of objects may contain identifiers for bodies, features, faces and edges. You use this routine to create a list for those modeling routines that require a list as an input; please do not use this for ask routines that return lists. Environment: Internal and External See Also: UF_MODL_ask_list_item UF_MODL_delete_list UF_MODL_ask_list_count UF_MODL_put_list_item UF_MODL_delete_list_item History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_create_list( uf_list_p_t * list /* <OF> List of object identifiers. */ ); /**************************************************************************** Deallocates the memory for a linked list of objects, the objects themselves are not deleted. A list of objects may contain identifiers for bodies, features, faces and edges. Environment: Internal and External See Also: UF_MODL_ask_list_item UF_MODL_create_list UF_MODL_ask_list_count UF_MODL_put_list_item UF_MODL_delete_list_item History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_delete_list( uf_list_p_t * list /* <I> List of object identifiers */ ); /* <NON_NXOPEN> */ /**************************************************************************** Delete object identifier from a linked list of object identifiers. NOTE: Deleting all the items in a list also causes the list to be deleted. Environment: Internal and External See Also: UF_MODL_ask_list_item UF_MODL_create_list UF_MODL_delete_list UF_MODL_ask_list_count UF_MODL_put_list_item History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_delete_list_item( uf_list_p_t * list ,/* <I> list of object identifiers */ tag_t object /* <I> object to be deleted from list. */ ); /* <NON_NXOPEN> */ /**************************************************************************** Retrieves an object from a linked list of objects. A list of objects may contain identifiers for bodies, features, faces and edges. Loop type for a face is Peripheral only for a non-periodic (topologically flat) face. Loops on a periodic face are either Holes or "Other". Environment: Internal and External See Also: UF_MODL_ask_face_topology UF_MODL_delete_loop_list UF_MODL_ask_loop_list_count History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_loop_list_item( uf_loop_p_t loop_list ,/* <I> List of object identifiers */ int index ,/* <I> Count into the list */ int * type ,/* <O> Peripheral=1, Hole=2, Other=3 */ uf_list_p_t * list /* <OF,free:UF_MODL_delete_loop_list> Pointer to the list of edge object identifiers. This should not be freed, as it will be freed when the entire loop list is freed by calling UF_MODL_delete_loop_list. */ ); /**************************************************************************** The input is a single pointer to a loop list, which frees each edge list within the loop list. Environment: Internal and External See Also: UF_MODL_ask_loop_list_item UF_MODL_ask_loop_list_count History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_delete_loop_list( uf_loop_p_t * list /* <I> Pointer to a loop list */ ); /* <NON_NXOPEN> */ /**************************************************************************** This routine returns the count of elements within a loop list specified by the user. Environment: Internal and External See Also: UF_MODL_ask_loop_list_item UF_MODL_delete_loop_list History: ***************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_loop_list_count( uf_loop_p_t list ,/* <I> Pointer to a loop list */ int * count /* <O> Pointer to an int for the loop count */ ); /***************************************************************************** Compute the direction flag for a curve or edge The direction flag is computed base on the input point and the input curve or edge. We assign UF_MODL_CURVE_START_FROM_BEGIN , if the input point is closer to the starting point than the end point of the curve, and UF_MODL_CURVE_START_FROM_END, otherwise. If the curve or edge is closed and the point is on both end points, we assign UF_MODL_CURVE_START_FROM_END. Return: error code Environment: Internal and External See Also: History: ****************************************************************************/ extern UFUNEXPORT int UF_MODL_get_curve_edge_direction ( double end_point[3] , /* <I> : The input endpoint */ tag_t curve_edge_eid , /* <I> : The input curve or edge */ int * direction /* <O> : Ouput direction */ ) ; /***************************************************************************** Assign the direction flags in a string list structure. The direction flags are computed base on the input points and the input string list structure. The number of points must be the same as the number of profiles in the string list structure. For each profile, we use the first curve or edge. We assign UF_MODL_CURVE_START_FROM_BEGIN , if the input point is closer to the starting point than the end point of the curve, and UF_MODL_CURVE_START_FROM_END, otherwise, to the direction of the corresponding profile in the string list structure. If the curve or edge is closed and the point is on both end points, we assign UF_MODL_CURVE_START_FROM_END to the direction of this profile in the string list structure. Return: error code. Environment: Internal and External See Also: History: ****************************************************************************/ extern UFUNEXPORT int UF_MODL_assign_string_directions ( double * end_points , /* <I> An array of 3*string_list->num doubles. */ UF_STRING_p_t string_list1 /* <IOF> A string list structure. */ ) ; /***************************************************************************** Creates a string list structure. The output of this function is a pointer to the string list structure. Example: UF_MODL_create_string_list call setup UF_STRING_t guide; UF_STRING_p_t gu = &guide; UF_MODL_create_string_list( 3, 50, gu ); Creates 3 guides containing 50 entities Return: void Environment: Internal and External See Also: History: ****************************************************************************/ extern UFUNEXPORT void UF_MODL_create_string_list( int num_string ,/* <I> Number of strings */ int num_object ,/* <I> Number of object */ UF_STRING_p_t string_list1 /* <IOF> The caller passes in a pointer to an already allocated UF_STRING_t structure, and this routine allocates space for the arrays in the structure. The arrays allocated inside of this structure must be freed by calling UF_MODL_free_string_list. */ ); /***************************************************************************** Frees a string list structure. Environment: Internal and External See Also: History: ****************************************************************************/ extern UFUNEXPORT void UF_MODL_free_string_list( UF_STRING_p_t string_list /* <I> Pointer to string list structure */ ); /***************************************************************************** Initializes a string list structure. Return: void Environment: Internal and External See Also: History: ****************************************************************************/ extern UFUNEXPORT void UF_MODL_init_string_list( UF_STRING_p_t string_list1 /* <I> Pointer to string list structure */ ); /******************************************************************************* Sort features by order of update. Notice that if feature1 updates before feature2 then it is legal for feature2 to reference feature1. This can be used in a selection filter during edit. Environment:Internal and External See Also: History: *******************************************************************************/ extern UFUNEXPORT int UF_MODL_sort_features ( tag_t feature1, /* <I> first feature */ tag_t feature2, /* <I> second feature */ int *result /* <O> -1 if feature1 updates before feature2 0 if feature1 equals feature2 1 if feature1 updates after feature2 */ ); /***************************************************************************** Return the next feature in the feature graph based on the time stamp of the features. Environment:Internal and External See Also: History: Originally released in V16.0 ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_next_feature( tag_t feature, /* <I> Feature to check */ tag_t *next_feature /* <O> Next feature. If there is not a next feature, NULL_TAG is returned. */ ); /***************************************************************************** Return the previous feature in the feature graph based on the time stamp of the features. Environment:Internal and External See Also: History: Originally released in V16.0 ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_previous_feature( tag_t feature, /* <I> Feature to check */ tag_t *prev_feature /* <O> Previous feature. If there is not a previous feature, then NULL_TAG is returned. */ ); /***************************************************************************** Returns full name (type and time stamp) of feature. The name is the NX system defined name and will not reflect renaming that the user may have applied to the feature unless the feature is a UDF. If the input feature is a user defined feature (UDF) the system feature name 'User Defined Feature' is considered insignificant compared to any name applied by the user. UDF features will return the user applied feature name. In some cases, further refinement of the feature type is neccessary to distinguish which functions are usable for a given feature. For example, UF_MODL_ask_feat_type will indicate that a feature is a SWEEP, but further refinement of the feature is needed to know if UF_MODL_ask_extrusion or the UF_MODL_ask_sweep... functions can be used to retrieve the parameters for the given SWEEP. Environment:Internal and External See Also: UF_MODL_ask_feat_name UF_MODL_ask_feat_type History: Originally released in V19.0 ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_feat_sysname( tag_t feature_eid, /* <I> Feature to inguire upon */ char **feature_name /* <OF> String containing feature name. Must be freed using UF_free */ ); /***************************************************************************** Returns full name (type and time stamp) of feature. The name is the NX system defined name and will not reflect renaming that the user may have applied to the feature. In some cases, further refinement of the feature type is neccessary to distinguish which functions are usable for a given feature. For example, UF_MODL_ask_feat_type will indicate that a feature is a SWEEP, but further refinement of the feature is needed to know if UF_MODL_ask_extrusion or the UF_MODL_ask_sweep... functions can be used to retrieve the parameters for the given SWEEP. Environment:Internal and External See Also: UF_MODL_ask_feat_name UF_MODL_ask_feat_type History: Originally released in NX6.0.1 ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_feat_or_udf_sysname( tag_t feature_eid, /* <I> Feature to inguire upon */ char **feature_name /* <OF> String containing feature name. Must be freed using UF_free */ ); /****************************************************************************** Returns the bounding box of wireframe and solid type objects. Wireframe objects include lines, arcs, splines, and conics. Solid type objects include bodies, faces, and edges. Bounding box values are returned in absolute coordinate values according to where the object exists in the part file. If you call this function with an occurrence, the bounding box of the underlying geometry is transformed into assembly space. This may cause the bounding box that is returned to be larger than expected. This happens in cases when the axes of the component part are transformed such that they don't align with the axes of the assembly coordinate system. Note that the box returned favors speed over accuracy. The returned box will contain the given entity and it will usually be close to the minimum bounding box but this is not guaranteed. This function may not return the correct information when the body has been trimmed or is the result of a boolean operation. In those cases UF_MODL_ask_extreme can be used to get the correct bounding box size. Environment: Internal and External See Also: History: ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_bounding_box( tag_t object ,/* <I> Object identifier of object to ask bounding box. */ double bounding_box[6] /* <O> Bounding box of object. [0] - minimum x value [1] - minimum y value [2] - minimum z value [3] - maximum x value [4] - maximum y value [5] - maximum z value */ ); /****************************************************************************** Returns the bounding box information of wireframe and solid type objects aligned to a CSYS. Wireframe objects include lines, arcs, splines, and conics. Solid type objects include bodies, faces, and edges. Bounding box values are returned in absolute coordinate values according to where the object exists in the part file and aligned to the input CSYS. If you call this function with an occurrence, the bounding box of the underlying geometry is transformed into assembly space. Use occurrence object tags when working in an assembly context and prototype object tags when working in non-assembly situations. Passing in a prototype object tag when in an assembly may produce undesired results. The csys_tag should always be in the context of the current work part. Due to distance and angle tolerances, the data returned cannot be guaranteed to be larger than the original object. The expand parameter allows for an expanded box to be created. The expand option will expand the box in all directions by a factor of 0.1 of the prototype part units. To derive the corner points, use the X,Y,X components of the min_corner and then add the X,Y,Z components of the directions multiplied by the X,Y,Z distances. For Example, to derive the 2 corner points: corner_pts[2][3] corner_pts[0][0] = min_corner[0] corner_pts[0][1] = min_corner[1] corner_pts[0][2] = min_corner[2] for i = 0 -> 2 inclusive corner_pts[1][i] = min_corner[i] for j = 0 -> 2 inclusive corner_pts[1][i] += directions[j][i] * distances[j] Note that the box returned favors speed over accuracy. The returned box will contain the given entity and it will usually be close to the minimum bounding box but this is not guaranteed. Environment: Internal and External See Also: History: Originally released in V19.0 ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_bounding_box_aligned( tag_t object , /* <I> Object identifier of object to ask bounding box. */ tag_t csys_tag, /* <I> CSYS to use for box alignment. NULL_TAG - Use Work CSYS */ logical expand, /* <I> Expand the box to increase enclosure coverage FALSE - Do not expand TRUE - Expand */ double min_corner[3], /* <O> Minimum corner of box of object. [0] - minimum x value [1] - minimum y value [2] - minimum z value */ double directions[3][3], /* <O>: direction vectors of bounding box [0][] - X Direction [1][] - Y Direction [2][] - Z Direction */ double distances[3] /* <O> Distances to move along directions of CSYS to derive all points of the bounding box. [0] - X distance value [1] - Y distance value [2] - Z distance value */ ); /****************************************************************************** Returns the bounding box information of wireframe and solid type objects aligned to a CSYS. Wireframe objects include lines, arcs, splines, and conics. Solid type objects include bodies, faces, and edges. Bounding box values are returned in absolute coordinate values according to where the object exists in the part file and aligned to the input CSYS. If you call this function with an occurrence, the bounding box of the underlying geometry is transformed into assembly space. Use occurrence object tags when working in an assembly context and prototype object tags when working in non-assembly situations. Passing in a prototype object tag when in an assembly may produce undesired results. The csys_tag should always be in the context of the current work part. To derive the corner points, use the X,Y,X components of the min_corner and then add the X,Y,Z components of the directions multiplied by the X,Y,Z distances. For Example, to derive the 2 corner points: corner_pts[2][3] corner_pts[0][0] = min_corner[0] corner_pts[0][1] = min_corner[1] corner_pts[0][2] = min_corner[2] for i = 0 -> 2 inclusive corner_pts[1][i] = min_corner[i] for j = 0 -> 2 inclusive corner_pts[1][i] += directions[j][i] * distances[j] While a more accurate box is produced, processing time may be increased significantly. Environment: Internal and External See Also: History: Originally released in NX V4.0 ******************************************************************************/ extern UFUNEXPORT int UF_MODL_ask_bounding_box_exact( tag_t object , /* <I> Object identifier of object to ask bounding box. */ tag_t csys_tag, /* <I> CSYS to use for box alignment. NULL_TAG - Use Work CSYS */ double min_corner[3], /* <O> Minimum corner of box of object. [0] - minimum x value [1] - minimum y value [2] - minimum z value */ double directions[3][3], /* <O>: direction vectors of bounding box [0][] - X Direction [1][] - Y Direction [2][] - Z Direction */ double distances[3] /* <O> Distances to move along directions of CSYS to derive all points of the bounding box. [0] - X distance value [1] - Y distance value [2] - Z distance value */ ); #ifdef __cplusplus } #endif #undef EXPORTLIBRARY #endif /* UF_MODL_UTILITIES_H_INCLUDED */
08-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值