Home
Reply
Visitor
137800636
Posts: 2

Deformable Modeling

Hi!

      I'm a new leraner about ACIS.I want you give me help about Deformable Modeling,I have been studied it about two monthes,but I have litte haverst.I want  to add an area constraint to a splinesurface,then solve this model,last save the model.my codes are ;


#include <iostream>

#include "kernapi.hxx"
#include <splsurf.hxx>
#include <entity.hxx>


#include <dsapi.hxx>


#include "cstrapi.hxx"
#include "body.hxx"
#include "fileinfo.hxx"
#include "lists.hxx"
#include <dmapi.hxx>
#include <dsdmod.hxx>
#include <dszone.hxx>
#include <param.hxx>
#include <ds2acis.hxx>
#include <adm_options.hxx>
#include <acis_options.hxx>
#include <dmrend_opt.hxx>

 

 

 

 

 

void save_ent(char* filename, ENTITY* ent);
void printerr(outcome result,char* api_name);
void unlock_spatial_products_3679();


using namespace std;

void main()
{
 std::cout << "Hello world" << endl;

 // initialization
 unlock_spatial_products_3679();
 outcome rc = api_start_modeller(0);
 rc = api_initialize_kernel();
 rc = api_initialize_constructors();
 

 //创建简单的样条曲面
        splsurf *Asplsurf5 = new splsurf;
        SPAposition ctrlps5[9] = {  SPAposition(1,1,0), SPAposition(2,1,0), SPAposition(3,1,0),
                                                 SPAposition(1,2,0.1),SPAposition(2,2,0.1),SPAposition(3,2,0.1),
                                                 SPAposition(1,3,0), SPAposition(2,3,0),  SPAposition(3,3,0)
        };

        Asplsurf5->set_ctrlpt_array(ctrlps5,3,3);

        Asplsurf5->set_u_param(2,0,0,0);
        Asplsurf5->set_v_param(2,0,0,0);       
        double uknot_array5[7] = {0, 0, 0, 0.5, 1, 1, 1};
        Asplsurf5->set_u_knot_array(uknot_array5,7);
        double vknot_array5[7] = {0, 0, 0, 0.5, 1, 1, 1};
        Asplsurf5->set_v_knot_array(vknot_array5, 7);

        double weight5[9]={1,1,1,
                1,1,1,
                1,1,1};

        Asplsurf5->set_weight_array(weight5);
       
        FACE *face5 = NULL;
        outcome res = api_face_spl_ctrlpts (Asplsurf5, face5);
  
   DS_dmod *dmod=NULL;

   int  domain_flag=1;
   double  min[2];min[0]=0.2,min[1]=0.2;
   double  max[2];max[0]=0.8,max[1]=0.8;
          SDM_options *sdmo = NULL;

  int rtn_err;
  DS_zone *zone;

  zone = DM_build_square_zone (rtn_err,dmod,domain_flag, min, max ) ;
            
    

  int  tag_flag=2;
   int  zone_flag=0;
   void *src_data = NULL;
   int  tag = -1;

 DM_add_area_cstrn  (rtn_err,dmod,tag_flag,zone_flag,zone,src_data,tag,sdmo ) ;
 

      int  iter_count = -1;
      double  max_move = 0.0;
 DM_solve  (rtn_err,dmod,iter_count,max_move ,sdmo) ;
  ATTRIB_DM2ACIS *  attrib_dm2acis=NULL;
  adm_options *  admO = NULL;
  AcisOptions *  acisO = NULL  ;
 api_dm_commit_attrib_dm2acis  (  attrib_dm2acis, admO ,  acisO) ;
ENTITY *  face2=NULL;
 api_dm_get_attrib_dm2acis  (face2,   attrib_dm2acis,  admO ,acisO) ;


DM_delete_dmod  (rtn_err,dmod,sdmo);


        printerr(res,"5: api_face_spl_ctrlpts!");
        save_ent("face5.sat",(ENTITY *)face5);
 save_ent("face2.sat",face2);
save_ent("face4.sat",(ENTITY *)  dmod);
 
  api_terminate_constructors();
  api_terminate_kernel();
  api_stop_modeller();
 exit(0);
}

 


void save_ent(char* filename, ENTITY* ent)
{

        FileInfo info;
        info.set_product_id("ZWW DESIGN");
        info.set_units(1.0);
        info.set_product_id("20.0");       

        api_set_file_info(FileId|FileUnits,info);

        FILE *fp = fopen(filename,"w+");
       
        if (fp!=NULL)
        {
                ENTITY_LIST* savelist= new ENTITY_LIST;
                savelist->add(ent);
                outcome result = api_save_entity_list(fp,TRUE,*savelist);
                if (!result.ok())
                {
                        err_mess_type err_no = result.error_number();
                        printf ("ERROR in api_save_entity_list() %d: %s\n",
                                err_no, find_err_mess (err_no));
                       
                }
                delete savelist;
                fclose(fp);
        }else
                printf("不能打开文件!\n");
       
       
}


void printerr(outcome result,char* api_name)
{
        if (!result.ok())
        {
                err_mess_type err_no = result.error_number();
                printf ("ERROR in %s() %d: %s\n",
                        api_name,err_no, find_err_mess (err_no));
                exit(1);
               
        }

}

I hope you give me some suggestions about Deformable Modeling learning,then give me some examples about it .thank you!

Spatial Moderator
ybiyani
Posts: 223

Re: Deformable Modeling

Hello,

 

 

Pls see http://doc.spatial.com/qref/ACIS/html/group__DMAPI.html#gb410efc9608144efcb52c5170faf2f81 . Seems like step 4 is missing -  "Modify the parameters of the constraints, loads, or deformation parameters."...try adding a call to DM_add_dist_press or DM_add_attractor and call  DM_Solve again to see the changes....

 

Your current example is similar to http://doc.spatial.com/index.php/SchemeExt:Ds:solve where you add a constraint and solve

 

(define dsmodel1 (ds:test-face 6 6 36 36 0))
;; dsmodel1
; Do not display entity / ds test face exists.
(define erase (entity:erase dsmodel1))
;; erase
; Render the loads and constraints.
(ds:set-draw-state dsmodel1 1 (+ ds-draw-cstrns ds-draw-loads))
;; ()
; Add a point constraint.
(define cc1 (ds:add-pt-cstrn dsmodel1 1 "position" (par-pos 0.5 0.5)))
;; cc1
(ds:solve dsmodel1 1 1)

;; ()
; The system should not move since the constraint was added to an equilibrium position.

 

 

In order to change the model you will have modify the load or constraint to see the change.

 

; Change the constraint point's 3 space position.
(ds:set-pt-xyz dsmodel1 cc1 0 (position 18 18 15))
;; 8
; Solve for the new equilibrium position.
(ds:solve dsmodel1 1 1)
;; ()
; The surface changes its' shape to interpolate the point.

 

I hope this helps.

 

Regards,

Yogesh

 

Visitor
137800636
Posts: 2

Re: Deformable Modeling

Hello,

   Thank you for your help, I habe saw,the example you given to me! I think I hnve a misstake in "the add_area_cnstrn"step.I don't understand this funtion of "domd".Does this parameter want me to choose the deformable model.This problem have been disturbed long time,I hope you could modifile my program.

                                                                                                                                                                      Danffer

                                                                                                                                                                 2011.4.9