*====================================================================*\
FUNCTION : ProUtilSectionInfoCopy
PURPOSE : Copies section defining entities to a new section
applying translation vector
\*====================================================================*/
ProError ProUtilSectionInfoCopy(ProSection exist_section,
ProSection new_section,
ProVector trans_vector)
{
ProError err;
ProIntlist ent_ids, new_ent_ids;
int n_ids,i,j,k;
ProBoolean is_proj;
Pro2dEntdef *p_entity;
ProIntlist dim_ids;
int n_dim_ids,*p_ent_refs;
ProSecdimType d_type;
ProSectionPointType *p_pnt_types;
int n_refs,new_ent_refs[5],dim_id, tmp_id;
ProBoolean ref_proj;
ProVector mid_pnt, d1, d2;
Pro2dPnt dim_pnt;
Pro2dPointdef dim_loc;
err = ProSectionEntityIdsGet(exist_section,&ent_ids,&n_ids);
TEST_CALL_REPORT("ProSectionEntityIdsGet()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
err = ProArrayAlloc(n_ids,sizeof(ProIntlist),n_ids,
(ProArray *)&new_ent_ids);
TEST_CALL_REPORT("ProArrayAlloc()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
for (i=0; i<n_ids; i++)
{
err = ProSectionEntityIsProjection(exist_section,ent_ids[i],
&is_proj);
TEST_CALL_REPORT("ProSectionEntityIsProjection()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
if (is_proj == PRO_B_TRUE)
{
new_ent_ids[i] = -1;
continue;
}
err = ProSectionEntityGet(exist_section,ent_ids[i],&p_entity);
TEST_CALL_REPORT("ProSectionEntityGet()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
if (err != PRO_TK_NO_ERROR)
{
ProTKPrintf(
"ProUtilSectionInfoCopy Section Entity Id: %d not suppported\n",
ent_ids[i]);
continue;
}
err = ProSectionEntityAdd(new_section,p_entity,
&new_ent_ids[i]);
TEST_CALL_REPORT("ProSectionEntityAdd()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
err = ProSectionEntityTranslate(new_section,new_ent_ids[i],
trans_vector);
TEST_CALL_REPORT("ProSectionEntityTranslate()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
}
err = ProSecdimIdsGet(exist_section,&dim_ids,&n_dim_ids);
TEST_CALL_REPORT("ProSecdimIdsGet()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
for (i=0; i<n_dim_ids; i++)
{
err = ProSecdimTypeGet(exist_section,dim_ids[i],&d_type);
TEST_CALL_REPORT("ProSecdimTypeGet()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
err = ProSecdimReferencesGet(exist_section,dim_ids[i],
&p_ent_refs,&p_pnt_types,&n_refs);
TEST_CALL_REPORT("ProSecdimReferencesGet()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
ref_proj = PRO_B_FALSE;
for (j=0; j<n_refs; j++)
{
err = ProSectionEntityIsProjection(exist_section,
p_ent_refs[j],&is_proj);
TEST_CALL_REPORT("ProSectionEntityFromProjection()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
if ( is_proj == PRO_B_TRUE )
{
ref_proj = PRO_B_TRUE;
break;
}
}
if (ref_proj == PRO_B_TRUE)
{
ref_proj = PRO_B_FALSE;
continue;
}
for (j=0; j<n_refs; j++)
{
for (k=0; k<n_ids; k++)
if ( ent_ids[k] == p_ent_refs[j] )
break;
new_ent_refs[j] = new_ent_ids[k];
}
err = ProSecdimLocationGet(exist_section, dim_ids[i], dim_loc.pnt);
TEST_CALL_REPORT("ProSecdimLocationGet",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
dim_loc.type = PRO_2D_POINT;
err = ProSectionEntityAdd(new_section, (Pro2dEntdef*)&dim_loc, &tmp_id);
TEST_CALL_REPORT("ProSectionEntityAdd",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
err = ProSectionEntityTranslate(new_section, tmp_id, trans_vector);
TEST_CALL_REPORT("ProSectionEntityTranslate()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
err = ProSectionEntityEval(new_section, tmp_id, 0, mid_pnt, d1, d2);
TEST_CALL_REPORT("ProSectionEntityEval()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
err = ProSectionEntityDelete(new_section, tmp_id);
TEST_CALL_REPORT("ProSectionEntityDelete()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
dim_pnt[0] = mid_pnt[0];
dim_pnt[1] = mid_pnt[1];
err = ProSecdimCreate(new_section,new_ent_refs,
p_pnt_types,n_refs,d_type,dim_pnt,&dim_id);
TEST_CALL_REPORT("ProSecdimCreate()",
"ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
}
return(err);
}