iCAx开思工具箱

标题: 【求助】请教各位,用什么命令可以求curve的两断点坐标? [打印本页]

作者: yanfang1108    时间: 2004-6-24 20:45
标题: 【求助】请教各位,用什么命令可以求curve的两断点坐标?
用什么命令可以求curve的两断点坐标?3x!!
作者: 深夜摔键盘    时间: 2004-6-28 07:44
可以查询到曲线的控制点
第一个控制点和最后一个控制点坐标就是两端点。
作者: goodluckwu    时间: 2004-6-28 14:04
#include <stdio.h>
#include <uf_part.h>
#include <uf_defs.h>
#include <uf.h>
#include <uf_curve.h>
#include <uf_ui.h>
#include <uf_object_types.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
    if (irc)
    {
        char    messg[133];
        printf("%s, line %d:  %s\n", file, line, call);
        (UF_get_fail_message(irc, messg)) ?
            printf("    returned a %d\n", irc) :
            printf("    returned error %d:  %s\n", irc, messg);
    }
    return(irc);
}
static void do_ugopen_api(void)
{
  char prtnam[]={"temp"};
  char buffer[UF_UI_MAX_STRING_LEN];
  int english = 2;
  int curve_type;
  double  *curve_data;
  tag_t id;
  tag_t part_tag;
  UF_CURVE_struct_p_t curve;
  
  UF_CURVE_line_t line;
  line.start_point[0] = 1.0;
  line.start_point[1] = 1.0;
  line.start_point[2] = 1.0;
  line.end_point[0] = 2.0;
  line.end_point[1] = 0.0;
  line.end_point[2] = 1.0;
  
  UF_CALL(UF_PART_new(prtnam,english,[$part_tag))]
  UF_CALL(UF_CURVE_create_line([$line, &id))]
  UF_CALL(UF_CURVE_ask_curve_struct(id,[$curve))]
  UF_CALL(UF_CURVE_ask_curve_struct_data(curve,
                                         &curve_type,
                                         [$curve_data))]
  if(curve_type == UF_line_type)
  {
    UF_CALL(UF_UI_open_listing_window());
    sprintf(buffer,"\nStart Parameter, t0 = %f\n", curve_data[0]);
    UF_CALL(UF_UI_write_listing_window(buffer));
    sprintf(buffer,"The scale value, tscale = %f\n",
curve_data[1]);
    UF_CALL(UF_UI_write_listing_window(buffer));
    sprintf(buffer,"The periodicity is: %f\n", curve_data[2]);
    UF_CALL(UF_UI_write_listing_window(buffer));
    sprintf(buffer, "The first point (x,y,z) is: %f, %f, %f\n",
            curve_data[3], curve_data[4], curve_data[5]);
    UF_CALL(UF_UI_write_listing_window(buffer));
    sprintf(buffer,"The second point (x,y,z) is: %f, %f, %f\n",
            curve_data[6],curve_data[7],curve_data[8]);
    UF_CALL(UF_UI_write_listing_window(buffer));
  
  }
  UF_CALL(UF_CURVE_free_curve_struct(curve));
  UF_free(curve_data);
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
    if (!UF_CALL(UF_initialize()))
    {
        do_ugopen_api();
        UF_CALL(UF_terminate());
    }
}
int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}
作者: yanfang1108    时间: 2004-7-2 17:02
多谢各位!!!涕零!!!
作者: acoka    时间: 2004-7-2 19:10
说catia的做法把,
  
{
...
  do {
    
  
    CATISpecObject_var spFeature = spCurve;
    CATBody_var spBody = NULL_var;
    if( !ispFeature ) {
      break;
    }
    CATIMfBRep_var spBRepOnFeature = ispFeature;
    if( !!spBRepOnFeature ) {
      spBody = spBRepOnFeature->GetBody();
    }
    else {
      CATIGeometricalElement_var spGeometricalElementOnFeature = ispFeature;
      if( !!spGeometricalElementOnFeature ) {
        spBody = spGeometricalElementOnFeature->GetBodyResult();
      }
      else {
        CATIBodyRequest_var spBodyRequestOnModel = ispFeature;
        if( !spBodyRequestOnModel ){
          break;
        }
        CATListValCATBaseUnknown_var listResult;
        HRESULT rc = spBodyRequestOnModel->GetResults("MfDefault3DView",listResult);
        if(FAILED(rc)){
          break;
        }
        if( listResult.Size() <= 0 ) {
          break;
        }
        CATIGeometricalElement_var spGeometricalElementOnBody = listResult[1];
        if(!spGeometricalElementOnBody){
          break;
        }            
        spBody = spGeometricalElementOnBody->GetBodyResult();
      }
    }
    if( !spBody ) {
      break;
    }
    
    //  
    CATLISTP(CATCell) LISTCell;
    CATLISTV(CATMathPoint) LISTMathPoint;
    spIntersectBody->GetAllCells( LISTCell, 0 );
    for( int index = 1; index <= LISTCell.Size(); index++ ){
      CATCell *pPointCell = LISTCell[index];
      if(!pPointCell){
        continue;
      }
      CATCell_var spPointCell = pPointCell;
      if(!spPointCell){
        continue;
      };
      CATVertex_var spVertex = spPointCell;
      if( !spVertex ){
        continue;
      }
      CATPoint *pPoint = spVertex->GetPoint();
      if(!pPoint){
        continue;
      }
      double pointX = 0.0;
      double pointY = 0.0;
      double pointZ = 0.0;
      pPoint->GetCoord(pointX, pointY, pointZ);
      CATMathPoint mathPoint( pointX, pointY, pointZ );
      LISTMathPoint.Append(mathPoint);
    }
  
  } while(FALSE);
...
}
作者: yanfang1108    时间: 2004-7-6 15:07
goodluckwu wrote:
#include <stdio.h>  
  #include <uf_part.h>  
  #include <uf_defs.h>  
  #include <uf.h>  
  #include <uf_curve.h>  
  #include <uf_ui.h>  
  #include <uf_object_types.h>  
  #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))  
  static int report( char *file, int line, char *call, int irc)  
  {  
      if (irc)  
      {  
          char    messg[133];  
          printf("%s, line %d:  %s\n", file, line, call);  
          (UF_get_fail_message(irc, messg)) ?  
              printf("    returned a %d\n", irc) :  
              printf("    returned error %d:  %s\n", irc, messg);  
      }  
      return(irc);  
  }  
  static void do_ugopen_api(void)  
  {  
    char prtnam[]={"temp"};  
    char buffer[UF_UI_MAX_STRING_LEN];  
    int english = 2;  
    int curve_type;  
    double  *curve_data;  
    tag_t id;  
    tag_t part_tag;  
    UF_CURVE_struct_p_t curve;  
  
    UF_CURVE_line_t line;  
    line.start_point[0] = 1.0;  
    line.start_point[1] = 1.0;  
    line.start_point[2] = 1.0;  
    line.end_point[0] = 2.0;  
    line.end_point[1] = 0.0;  
    line.end_point[2] = 1.0;  
  
    UF_CALL(UF_PART_new(prtnam,english,[$part_tag))]  
    UF_CALL(UF_CURVE_create_line([$line, &id))]  
    UF_CALL(UF_CURVE_ask_curve_struct(id,[$curve))]  
    UF_CALL(UF_CURVE_ask_curve_struct_data(curve,  
                                           &curve_type,  
                                           [$curve_data))]  
    if(curve_type == UF_line_type)  
    {  
      UF_CALL(UF_UI_open_listing_window());  
      sprintf(buffer,"\nStart Parameter, t0 = %f\n", curve_data[0]);  
      UF_CALL(UF_UI_write_listing_window(buffer));  
      sprintf(buffer,"The scale value, tscale = %f\n",  
  curve_data[1]);  
      UF_CALL(UF_UI_write_listing_window(buffer));  
      sprintf(buffer,"The periodicity is: %f\n", curve_data[2]);  
      UF_CALL(UF_UI_write_listing_window(buffer));  
      sprintf(buffer, "The first point (x,y,z) is: %f, %f, %f\n",  
              curve_data[3], curve_data[4], curve_data[5]);  
      UF_CALL(UF_UI_write_listing_window(buffer));  
      sprintf(buffer,"The second point (x,y,z) is: %f, %f, %f\n",  
              curve_data[6],curve_data[7],curve_data[8]);  
      UF_CALL(UF_UI_write_listing_window(buffer));  
  
    }  
    UF_CALL(UF_CURVE_free_curve_struct(curve));  
    UF_free(curve_data);  
  }  
  /*ARGSUSED*/  
  void ufusr(char *param, int *retcode, int paramLen)  
  {  
      if (!UF_CALL(UF_initialize()))  
      {  
          do_ugopen_api();  
          UF_CALL(UF_terminate());  
      }  
  }  
  int ufusr_ask_unload(void)  
  {  
      return (UF_UNLOAD_IMMEDIATELY);  
  }

  
兄弟,请问你用过这个函数没有?能否再给个实例啊?我要求的是交线的端点,交线有很多种类型,如line_type,spline_type,arc_type等。万分感激!Coffee,please!
作者: goodluckwu    时间: 2004-7-9 16:44
yanfang1108 wrote:
   
  
  兄弟,请问你用过这个函数没有?能否再给个实例啊?我要求的是交线的端点,交线有很多种类型,如line_type,spline_type,arc_type等。万分感激!Coffee,please!

  
实例我是没有了,不过好想不存在你说的问题,那几个类型都可以用的。




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3