void DemoSplit (HANDLE hLcWnd)
{
HANDLE hBlock, hCirc, hArc, hEnt, hEntNext;
int EntType, i, nArcs;
double Xc, Yc, Xm, Ym, X2, Y2, Ang;
bool bSplit = true;
// get a block, linked with CAD window
hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );
// add 1st circle
lcBlockAddCircle( hBlock, 0,0, 10, false );
// add 2nd circle
hCirc = lcBlockAddCircle( hBlock, 30,30, 10, false );
lcPropPutFloat( hCirc, LC_PROP_CIRCLE_ANG0, 270 * LC_DEG_TO_RAD );
lcPropPutBool( hCirc, LC_PROP_CIRCLE_DIRCW, true );
// add 3rd circle
hCirc = lcBlockAddCircle( hBlock, 60,0, 10, false );
lcPropPutFloat( hCirc, LC_PROP_CIRCLE_ANG0, 180 * LC_DEG_TO_RAD );
if (bSplit){
nArcs = 4; // number of arcs instead of a circle
// split all circles on several arcs and offset the arcs
hEnt = lcBlockGetFirstEnt( hBlock );
while( hEnt ){
// get next entity here, because lcEntSplit will insert
// new entities instead of hEnt
hEntNext = lcBlockGetNextEnt( hBlock, hEnt );
EntType = lcPropGetInt( hEnt, LC_PROP_ENT_TYPE );
if (EntType == LC_ENT_CIRCLE){
hArc = lcEntSplit( hEnt, nArcs, false, true );
if (hArc){
for (i=0; i<nArcs; ++i){
// get arc's center point
Xc = lcPropGetFloat( hArc, LC_PROP_ARC_X );
Yc = lcPropGetFloat( hArc, LC_PROP_ARC_Y );
// get arc's middle point
Xm = lcPropGetFloat( hArc, LC_PROP_ARC_XMID );
Ym = lcPropGetFloat( hArc, LC_PROP_ARC_YMID );
// offset arc's center
lcGetPolarPrm( Xc, Yc, Xm, Ym, &Ang, 0 );
lcGetPolarPoint( Xc, Yc, Ang, 5.0, &X2, &Y2 );
lcPropPutFloat( hArc, LC_PROP_ARC_X, X2 );
lcPropPutFloat( hArc, LC_PROP_ARC_Y, Y2 );
lcEntUpdate( hArc );
// get next arc
hArc = lcBlockGetNextEnt( hBlock, hArc );
}
}
}
// go to next entuty
hEnt = hEntNext;
}
}
// display jump lines
lcPropPutBool( hLcWnd, LC_PROP_WND_JUMPLINES, true );
// update view
lcBlockUpdate( hBlock, false, 0 );
lcWndZoomRect( hLcWnd, -20, -20, 80, 50 );
}