cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to find the surface normal

KB_9753804
12-Amethyst

How to find the surface normal

Hello Friends,

 

I have collected all surfaces of body , But now I want to find the normal of surface , Is there any API to get face normal.

 

Regards,

Kunal

1 ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:KB_9753804)

Try this:

 

ProSurfaceInit(...)

ProSurfaceDataGet(surface, &gitem_data)

ProSurfaceTypeGet(...)

 

if Plane or Planar get Csys from 

&gitem_data->data.p_surface_data->srf_shape.plane

 

plane->e1[0..2]

plane->e2[0..2]

plane->e3[0..2]

 

plane->origin[0..2]


On Top:


This explains the link from geom to surface Data

 

typedef struct geom_item_data_struct
{
ProType obj_type;
union
{
ProCurvedata *p_curve_data;
ProSurfacedata *p_surface_data;
ProCsysdata *p_csys_data;
} data;
} ProGeomitemdata;

#define PRO_CURVE_DATA(p_data) p_data == NULL ? NULL : \
p_data -> data.p_curve_data

#define PRO_SURF_DATA(p_data) p_data == NULL ? NULL : \
p_data -> data.p_surface_data

#define PRO_CSYS_DATA(p_data) p_data == NULL ? NULL : \
p_data -> data.p_csys_data

 

typedef enum pro_srf_type
{
PRO_SRF_NONE = -3,
PRO_SRF_PLANE = 34,
PRO_SRF_CYL = 36,
PRO_SRF_CONE = 37,
PRO_SRF_TORUS = 38,
PRO_SRF_COONS = 39,
PRO_SRF_SPL = 40,
PRO_SRF_FIL = 41,
PRO_SRF_RUL = 42,
PRO_SRF_REV = 43,
PRO_SRF_TABCYL = 44,
PRO_SRF_B_SPL = 45,
PRO_SRF_FOREIGN = 46,
PRO_SRF_CYL_SPL = 48,
PRO_SRF_SPL2DER = 50
} ProSrftype;

 

typedef struct Ptc_plane
{
ProVector e1, e2, e3;
Pro3dPnt origin;
/* Local coordinate system. */
} ProPlanedata;


Just one input:

 

extern ProError ProSurfacedataGet ( ProSurfacedata *p_surf_data,
ProSrftype *p_surf_type,
ProUvParam surf_uv_min,
ProUvParam surf_uv_max,
ProSurfaceOrient *p_surf_orient,
ProSurfaceshapedata *p_surf_shape,
int *p_surf_id );
/*
Purpose: Retrieves information from the surface data structure.
<p>
NOTE:
<p>
The function ignores the output arguments with NULL pointers.

Input Arguments:
p_surf_data - The surface data structure

Output Arguments:
p_surf_type - The surface type
surf_uv_min - The surface minimum UV extents
surf_uv_max - The surface maximum UV extents
p_surf_orient - The surface orientation
p_surf_shape - The surface shape
p_surf_id - The surface identifier

Return Values:
PRO_TK_NO_ERROR - The function successfully retrieved the information.
PRO_TK_BAD_INPUTS - The input argument is invalid.
*/

 

 

extern ProError ProPlanedataGet ( ProSurfaceshapedata *p_surf_shape,
ProVector e1,
ProVector e2,
ProVector e3,
Pro3dPnt origin );

 

 

Note there is a ProSurfaceDataGet and a ProSurfacedataGet function.

 

View solution in original post

2 REPLIES 2

Hello @KB_9753804 ,

I think you can use here ProSurfaceXyzdataEval Toolkit API  ProSurfaceXyzdataEval. Here from TK User Guide

The function ProSurfaceXyzdataEval() evaluates the parametric equations for a surface at a point specified by its u and v values. The inputs to the function are the ProSurface object and the u and v values. The u and v values are obtained by specifying the projection type as PRO_SRFTESS_NO_PROJECTION for the function

 

ProError ProSurfaceXyzdataEval (p_handle, uv_point, xyz_point, deriv1, deriv2,normal)

 

here is an example;

 

 /*--------------------------------------------------------------------*\
 Find the surface the datum point sits on, and find its first
 derivative vectors and the normal
 \*--------------------------------------------------------------------*/
 ProTestPointSrfGet (data->point, &surface);
 
  err = ProSurfaceParamEval ((ProSolid)modelitem.owner, surface,
  data->csysdata.origin, uv);
 
  
 err = ProSurfaceXyzdataEval (surface, uv, NULL, der1, NULL, normal);

 

so first you need get the uv coord  for the point XYZ coord (ProSurfaceParamEval) and then call the ProSurfaceXyzdataEval

RPN
17-Peridot
17-Peridot
(To:KB_9753804)

Try this:

 

ProSurfaceInit(...)

ProSurfaceDataGet(surface, &gitem_data)

ProSurfaceTypeGet(...)

 

if Plane or Planar get Csys from 

&gitem_data->data.p_surface_data->srf_shape.plane

 

plane->e1[0..2]

plane->e2[0..2]

plane->e3[0..2]

 

plane->origin[0..2]


On Top:


This explains the link from geom to surface Data

 

typedef struct geom_item_data_struct
{
ProType obj_type;
union
{
ProCurvedata *p_curve_data;
ProSurfacedata *p_surface_data;
ProCsysdata *p_csys_data;
} data;
} ProGeomitemdata;

#define PRO_CURVE_DATA(p_data) p_data == NULL ? NULL : \
p_data -> data.p_curve_data

#define PRO_SURF_DATA(p_data) p_data == NULL ? NULL : \
p_data -> data.p_surface_data

#define PRO_CSYS_DATA(p_data) p_data == NULL ? NULL : \
p_data -> data.p_csys_data

 

typedef enum pro_srf_type
{
PRO_SRF_NONE = -3,
PRO_SRF_PLANE = 34,
PRO_SRF_CYL = 36,
PRO_SRF_CONE = 37,
PRO_SRF_TORUS = 38,
PRO_SRF_COONS = 39,
PRO_SRF_SPL = 40,
PRO_SRF_FIL = 41,
PRO_SRF_RUL = 42,
PRO_SRF_REV = 43,
PRO_SRF_TABCYL = 44,
PRO_SRF_B_SPL = 45,
PRO_SRF_FOREIGN = 46,
PRO_SRF_CYL_SPL = 48,
PRO_SRF_SPL2DER = 50
} ProSrftype;

 

typedef struct Ptc_plane
{
ProVector e1, e2, e3;
Pro3dPnt origin;
/* Local coordinate system. */
} ProPlanedata;


Just one input:

 

extern ProError ProSurfacedataGet ( ProSurfacedata *p_surf_data,
ProSrftype *p_surf_type,
ProUvParam surf_uv_min,
ProUvParam surf_uv_max,
ProSurfaceOrient *p_surf_orient,
ProSurfaceshapedata *p_surf_shape,
int *p_surf_id );
/*
Purpose: Retrieves information from the surface data structure.
<p>
NOTE:
<p>
The function ignores the output arguments with NULL pointers.

Input Arguments:
p_surf_data - The surface data structure

Output Arguments:
p_surf_type - The surface type
surf_uv_min - The surface minimum UV extents
surf_uv_max - The surface maximum UV extents
p_surf_orient - The surface orientation
p_surf_shape - The surface shape
p_surf_id - The surface identifier

Return Values:
PRO_TK_NO_ERROR - The function successfully retrieved the information.
PRO_TK_BAD_INPUTS - The input argument is invalid.
*/

 

 

extern ProError ProPlanedataGet ( ProSurfaceshapedata *p_surf_shape,
ProVector e1,
ProVector e2,
ProVector e3,
Pro3dPnt origin );

 

 

Note there is a ProSurfaceDataGet and a ProSurfacedataGet function.

 

Top Tags