VRML export: add support of S_POLYGON in DRAWSEGMENT export.
This commit is contained in:
parent
4c29ab6c09
commit
888a9e7371
|
@ -706,6 +706,40 @@ static void export_vrml_drawsegment( MODEL_VRML& aModel, DRAWSEGMENT* drawseg )
|
||||||
export_vrml_arc( aModel, layer, x, y, x, y+r, w, 180.0 );
|
export_vrml_arc( aModel, layer, x, y, x, y+r, w, 180.0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case S_POLYGON:
|
||||||
|
if( drawseg->IsPolyShapeValid() )
|
||||||
|
{
|
||||||
|
VRML_LAYER* vlayer;
|
||||||
|
|
||||||
|
if( !GetLayer( aModel, layer, &vlayer ) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
SHAPE_POLY_SET shape = drawseg->GetPolyShape();
|
||||||
|
|
||||||
|
const int circleSegmentsCount = 16;
|
||||||
|
|
||||||
|
if( drawseg->GetWidth() )
|
||||||
|
{
|
||||||
|
shape.Inflate( drawseg->GetWidth()/2, circleSegmentsCount );
|
||||||
|
shape.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||||
|
}
|
||||||
|
|
||||||
|
const SHAPE_LINE_CHAIN& outline = shape.COutline( 0 );
|
||||||
|
|
||||||
|
int seg = vlayer->NewContour();
|
||||||
|
|
||||||
|
for( int j = 0; j < outline.PointCount(); j++ )
|
||||||
|
{
|
||||||
|
if( !vlayer->AddVertex( seg, (double)outline.CPoint( j ).x * BOARD_SCALE,
|
||||||
|
-((double)outline.CPoint( j ).y * BOARD_SCALE ) ) )
|
||||||
|
throw( std::runtime_error( vlayer->GetError() ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
vlayer->EnsureWinding( seg, false );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
export_vrml_line( aModel, layer, x, y, xf, yf, w );
|
export_vrml_line( aModel, layer, x, y, xf, yf, w );
|
||||||
break;
|
break;
|
||||||
|
@ -1038,8 +1072,22 @@ static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline,
|
||||||
if( !GetLayer( aModel, layer, &vl ) )
|
if( !GetLayer( aModel, layer, &vl ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::vector<wxPoint> poly = aOutline->BuildPolyPointsList();
|
SHAPE_POLY_SET shape = aOutline->GetPolyShape();
|
||||||
int nvert = poly.size() - 1;
|
|
||||||
|
const int circleSegmentsCount = 16;
|
||||||
|
|
||||||
|
if( aOutline->GetWidth() )
|
||||||
|
{
|
||||||
|
shape.Inflate( aOutline->GetWidth()/2, circleSegmentsCount );
|
||||||
|
shape.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||||
|
}
|
||||||
|
|
||||||
|
shape.Rotate( -aModule->GetOrientationRadians(), VECTOR2I( 0, 0 ) );
|
||||||
|
shape.Move( aModule->GetPosition() );
|
||||||
|
|
||||||
|
const SHAPE_LINE_CHAIN& outline = shape.COutline( 0 );
|
||||||
|
|
||||||
|
int nvert = outline.PointCount() - 1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if( nvert < 3 ) break;
|
if( nvert < 3 ) break;
|
||||||
|
@ -1051,11 +1099,8 @@ static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline,
|
||||||
|
|
||||||
while( i < nvert )
|
while( i < nvert )
|
||||||
{
|
{
|
||||||
RotatePoint( &poly[i], aModule->GetOrientation() );
|
x = outline.CPoint( i ).x * BOARD_SCALE;
|
||||||
poly[i] += aModule->GetPosition();
|
y = - ( outline.CPoint( i ).y * BOARD_SCALE );
|
||||||
|
|
||||||
x = poly[i].x * BOARD_SCALE;
|
|
||||||
y = - ( poly[i].y * BOARD_SCALE );
|
|
||||||
|
|
||||||
if( !vl->AddVertex( seg, x, y ) )
|
if( !vl->AddVertex( seg, x, y ) )
|
||||||
throw( std::runtime_error( vl->GetError() ) );
|
throw( std::runtime_error( vl->GetError() ) );
|
||||||
|
|
Loading…
Reference in New Issue