Ticket #4683 (closed enhancement: fixed)
DXF problem reading polyline splines
| Reported by: | pduarte | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.9.2 |
| Component: | OGR_SF | Version: | 1.9.1 |
| Severity: | normal | Keywords: | dxf |
| Cc: |
Description (last modified by pduarte) (diff)
When reading a spline control point vertexes are added to the output line. With this change control points vertexes are discarded.
Attached is a sample dxf file. Bellow is the corrected TranslatePOLYLINE function with the changes in bold style:
/************************************************************************/ /* TranslatePOLYLINE() */ /* */ /* We also capture the following VERTEXes. */ /************************************************************************/
OGRFeature *OGRDXFLayer::TranslatePOLYLINE()
{
char szLineBuf[257]; int nCode; int nPolylineFlag = 0; OGRFeature *poFeature = new OGRFeature( poFeatureDefn );
/* -------------------------------------------------------------------- */ /* Collect information from the POLYLINE object itself. */ /* -------------------------------------------------------------------- */
while( (nCode = poDS->ReadValue?(szLineBuf,sizeof(szLineBuf))) > 0 ) {
switch( nCode ) {
case 70:
nPolylineFlag = atoi(szLineBuf); break;
default:
TranslateGenericProperty?( poFeature, nCode, szLineBuf ); break;
}
}
/* -------------------------------------------------------------------- */ /* Collect VERTEXes as a smooth polyline. */ /* -------------------------------------------------------------------- */
double dfX = 0.0, dfY = 0.0, dfZ = 0.0; double dfBulge = 0.0; DXFSmoothPolyline smoothPolyline;
int nVertexFlag;
smoothPolyline.setCoordinateDimension(2);
while( nCode == 0 && !EQUAL(szLineBuf,"SEQEND") ) {
// Eat non-vertex objects. if( !EQUAL(szLineBuf,"VERTEX") ) {
while( (nCode = poDS->ReadValue?(szLineBuf,sizeof(szLineBuf)))>0 ) {} continue;
}
// process a Vertex while( (nCode = poDS->ReadValue?(szLineBuf,sizeof(szLineBuf))) > 0 ) {
switch( nCode ) {
case 10:
dfX = CPLAtof(szLineBuf); break;
case 20:
dfY = CPLAtof(szLineBuf); break;
case 30:
dfZ = CPLAtof(szLineBuf); smoothPolyline.setCoordinateDimension(3); break;
case 42:
dfBulge = CPLAtof(szLineBuf); break;
case 70:
nVertexFlag = atoi(szLineBuf);
break;
default:
break;
}
}
if (nVertexFlag!=16) { // Ignore Spline frame control points
smoothPolyline.AddPoint?( dfX, dfY, dfZ, dfBulge );
}
dfBulge = 0.0;
}
if(smoothPolyline.IsEmpty?()) {
delete poFeature; return NULL;
}
/* -------------------------------------------------------------------- */ /* Close polyline if necessary. */ /* -------------------------------------------------------------------- */
if(nPolylineFlag & 0x01)
smoothPolyline.Close();
OGRGeometry* poGeom = smoothPolyline.Tesselate(); ApplyOCSTransformer( poGeom ); poFeature->SetGeometryDirectly?( poGeom );
PrepareLineStyle?( poFeature );
return poFeature;
}

