[cgma-dev] OCCModifyEngine method implementations

Jane Hu janejhu at gmail.com
Tue Dec 20 09:17:43 CST 2011


Hi, Boyd:

Thank you for your codes. I believe that Cubit/geom now has these methods
to call either ACIS or OCC engine to  directly create such surfaces. Our
CGM based geom, which uses old cubit geom codes,  doesn't have these method
in ACIS or OCC to directly create such surfaces. Users usually first create
3-D model and copy surfaces to create such surfaces, or it can also go with
vertex to surface route.

Since CGM will be merged with Cubit, with user interface accessible to
those method, these methods will make great ease to the users. I'll put
these methods to our OCC base code then, and ready to be called through
upper level geom codes.

Jane



On Mon, Dec 19, 2011 at 3:31 PM, Boyd Tidwell <bktidwell373 at gmail.com>wrote:

> Tim and Jane,
>
>  In my testing I discovered a number of methods that hadn't been
> implemented and, because they didn't seem to difficult, I implemented
> them.
>
> I am told that it is OK to share them with cgma so here they are.  I
> can't claim they are perfect but they passed all the testing I threw
> at them.
>
> Enjoy!
>
>  - Boyd
>
>
>
>
> CubitStatus OCCModifyEngine::create_rectangle_surface( double width,
>
>             double height,
>
>             CubitVector plane,
>
>             BodySM *&sheet_body) const
> {
>  //create points at the 4 corners
>  CubitVector pos1( width*0.5, height*0.5, 0 );
>  CubitVector pos2( -width*0.5, height*0.5, 0 );
>  CubitVector pos3( -width*0.5, -height*0.5, 0 );
>  CubitVector pos4( width*0.5, -height*0.5, 0 );
>
>  DLIList<CubitVector*> vec_list(4);
>  vec_list.append( &pos1 );
>  vec_list.append( &pos2 );
>  vec_list.append( &pos3 );
>  vec_list.append( &pos4 );
>
>  CubitStatus status = OCCModifyEngine::instance()->create_surface(
> vec_list, sheet_body, 0, CUBIT_FALSE );
>
>  //rotate it so that it is aligned with the plane defined by vector 'plane'
>  CubitVector current_plane(0,0,1);
>  CubitVector axis_of_rotation = current_plane * plane;
>  double angle_of_rotation = axis_of_rotation.vector_angle(
> current_plane, plane );
>
>  OCCQueryEngine::instance()->rotate( sheet_body, axis_of_rotation,
> RADIANS_TO_DEGREES(angle_of_rotation) );
>
>  return status;
> }
>
> CubitStatus OCCModifyEngine::create_ellipse_surface( TBPoint *pt1,
>
>          TBPoint *pt3,
>
>          CubitVector center_point,
>
>          BodySM *&sheet_body) const
> {
>  // make ellipse by creating two ellipse arcs in each sense direction
>  Curve *ellipse1 =
> OCCModifyEngine::instance()->make_elliptical_Curve( pt1, pt3,
> center_point, 0, 360, CUBIT_FORWARD );
>  if( NULL == ellipse1 )
>    return CUBIT_FAILURE;
>  DLIList<Curve*> curve_list(2);
>  curve_list.append( ellipse1 );
>
>  Curve *ellipse2 =
> OCCModifyEngine::instance()->make_elliptical_Curve( pt1, pt3,
> center_point, 0, 360, CUBIT_REVERSED );
>  if( NULL == ellipse2 )
>    return CUBIT_FAILURE;
>  curve_list.append( ellipse2 );
>
>  Surface *tmp_surface = OCCModifyEngine::instance()->make_Surface(
> PLANE_SURFACE_TYPE, curve_list, NULL, false );
>  if( NULL == tmp_surface )
>    return CUBIT_FAILURE;
>
>  sheet_body = OCCModifyEngine::instance()->make_BodySM( tmp_surface );
>  if( NULL == sheet_body)
>    return CUBIT_FAILURE;
>
>  return CUBIT_SUCCESS;
> }
>
> CubitStatus OCCModifyEngine::create_ellipse_surface( double major_radius,
>
>          double minor_radius,
>
>          CubitVector plane,
>
>          BodySM *&sheet_body) const
> {
>  //create the points
>  CubitVector tmp_pt( major_radius, 0, 0 );
>  TBPoint *pt1 = OCCModifyEngine::instance()->make_Point( tmp_pt );
>
>  tmp_pt.set( 0, minor_radius, 0 );
>  TBPoint *pt2 = OCCModifyEngine::instance()->make_Point( tmp_pt );
>
>  CubitVector center_point(0,0,0);
>
>  // make ellipse by creating two ellipse arcs in each sense direction
>  Curve *ellipse1 =
> OCCModifyEngine::instance()->make_elliptical_Curve( pt1, pt2,
> center_point, 0, 360, CUBIT_FORWARD );
>  if( NULL == ellipse1 )
>    return CUBIT_FAILURE;
>  DLIList<Curve*> curve_list(2);
>  curve_list.append( ellipse1 );
>
>  Curve *ellipse2 =
> OCCModifyEngine::instance()->make_elliptical_Curve( pt1, pt2,
> center_point, 0, 360, CUBIT_REVERSED );
>  if( NULL == ellipse2 )
>    return CUBIT_FAILURE;
>  curve_list.append( ellipse2 );
>
>  Surface *tmp_surface = OCCModifyEngine::instance()->make_Surface(
> PLANE_SURFACE_TYPE, curve_list, NULL, false );
>  if( NULL == tmp_surface )
>    return CUBIT_FAILURE;
>
>  sheet_body = OCCModifyEngine::instance()->make_BodySM( tmp_surface );
>  if( NULL == sheet_body)
>    return CUBIT_FAILURE;
>
>  //rotate it so that it is aligned with the plane defined by vector 'plane'
>  CubitVector current_plane(0,0,1);
>  CubitVector axis_of_rotation = current_plane * plane;
>  double angle_of_rotation = axis_of_rotation.vector_angle(
> current_plane, plane );
>
>  OCCQueryEngine::instance()->rotate( sheet_body, axis_of_rotation,
> RADIANS_TO_DEGREES(angle_of_rotation) );
>
>  return CUBIT_SUCCESS;
> }
>
> Curve* OCCModifyEngine::make_elliptical_Curve( TBPoint const* point1,
>
>  TBPoint const* point2,
>
>  CubitVector &center_point,
>
>  double start_angle,
>
>  double end_angle,
>
>  CubitSense sense) const
> {
>  GeometryType curve_type = ELLIPSE_CURVE_TYPE;
>  Curve *curve = make_Curve(curve_type, point1, point2, &center_point,
> sense );
>  if ( curve == NULL )
>  {
>    PRINT_ERROR("In OCCModifyEngine::make_elliptical_Curve\n"
>                "       Cannot make Curve object.\n");
>    return (Curve *)NULL;
>  }
>  return curve;
> }
>
> CubitStatus OCCModifyEngine::create_circle_surface( TBPoint *pt1,
>
>        CubitVector center_point,
>
>        TBPoint *pt3,
>
>        BodySM *&sheet_body) const
> {
>  TBPoint *tmp_pt = OCCModifyEngine::instance()->make_Point( center_point );
>  Curve *circle = OCCModifyEngine::instance()->create_arc_three( pt1,
> tmp_pt, pt3, CUBIT_TRUE );
>
>  OCCQueryEngine::instance()->delete_solid_model_entities( tmp_pt );
>
>  DLIList<Curve*> curve_list(1);
>  curve_list.append( circle );
>  Surface *tmp_surface = OCCModifyEngine::instance()->make_Surface(
> PLANE_SURFACE_TYPE, curve_list, NULL, false );
>  if( NULL == tmp_surface )
>    return CUBIT_FAILURE;
>
>  sheet_body = OCCModifyEngine::instance()->make_BodySM( tmp_surface );
>  if( NULL == sheet_body)
>    return CUBIT_FAILURE;
>
>  return CUBIT_SUCCESS;
> }
>
> CubitStatus OCCModifyEngine::create_circle_surface( TBPoint *pt1,
>
>        TBPoint *pt3,
>
>        CubitVector center_point,
>
>        BodySM *&sheet_body) const
> {
>  TBPoint *tmp_center_pt =      OCCModifyEngine::instance()->make_Point(
> center_point );
>  CubitVector normal(0,0,0);
>  Curve *circle = OCCModifyEngine::instance()->create_arc_center_edge(
> tmp_center_pt, pt1, pt3, normal, CUBIT_DBL_MAX, CUBIT_TRUE );
>
>  if( NULL == circle )
>    return CUBIT_FAILURE;
>
>  OCCQueryEngine::instance()->delete_solid_model_entities( tmp_center_pt );
>
>  DLIList<Curve*> curve_list(1);
>  curve_list.append( circle );
>  Surface *tmp_surface = OCCModifyEngine::instance()->make_Surface(
> PLANE_SURFACE_TYPE, curve_list, NULL, false );
>  if( NULL == tmp_surface )
>    return CUBIT_FAILURE;
>
>  sheet_body = OCCModifyEngine::instance()->make_BodySM( tmp_surface );
>  if( NULL == sheet_body)
>    return CUBIT_FAILURE;
>
>  return CUBIT_SUCCESS;
> }
>
> CubitStatus OCCModifyEngine::create_circle_surface( double radius,
>
>        CubitVector plane,
>
>        BodySM *&sheet_body) const
> {
>  CubitVector center_pt;
>  center_pt.set(0, 0, 0);
>  CubitVector pt2, pt3;
>  if (plane.x() > 0 )
>  {
>    pt2.set( 0, radius, 0 );
>    pt3.set( 0, 0, radius);
>  }
>  else if (plane.y() > 0)
>  {
>    pt2.set(radius, 0, 0);
>    pt3.set(0, 0, -radius);
>  }
>  else if (plane.z() > 0)
>  {
>    pt2.set(radius, 0, 0);
>    pt3.set(0, radius, 0);
>  }
>  else
>  {
>    PRINT_ERROR("In OCCModifyEngine::create_circle_surface\n"
>                "       Invalid plane specified.\n");
>    return CUBIT_FAILURE;
>  }
>  CubitVector normal(plane.x(), plane.y(), plane.z());
>
>  TBPoint *tbpt1 = OCCModifyEngine::instance()->make_Point( center_pt );
>  TBPoint *tbpt2 = OCCModifyEngine::instance()->make_Point( pt2 );
>  TBPoint *tbpt3 = OCCModifyEngine::instance()->make_Point( pt3 );
>  Curve *circle = OCCModifyEngine::instance()->create_arc_center_edge(
>                               tbpt1, tbpt2, tbpt3, normal, radius,
> CUBIT_DBL_MAX, CUBIT_FALSE);
>
>  DLIList<Curve*> curve_list(1);
>  curve_list.append( circle );
>  Surface *tmp_surface = OCCModifyEngine::instance()->make_Surface(
> PLANE_SURFACE_TYPE, curve_list, NULL, false );
>  if( NULL == tmp_surface )
>    return CUBIT_FAILURE;
>
>  sheet_body = OCCModifyEngine::instance()->make_BodySM( tmp_surface );
>  if( NULL == sheet_body)
>    return CUBIT_FAILURE;
>
>  return CUBIT_SUCCESS;
>
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/cgma-dev/attachments/20111220/f97dbe7d/attachment-0001.htm>


More information about the cgma-dev mailing list