Skip to content

Instantly share code, notes, and snippets.

@TNick
Created March 21, 2013 08:31
Show Gist options
  • Save TNick/5211527 to your computer and use it in GitHub Desktop.
Save TNick/5211527 to your computer and use it in GitHub Desktop.
DRW_Vertex parseDwg
bool DRW_Vertex::parseDwg2D(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing vertex *********************************************\n");
/* Flags EC 70 NOT bit-pair-coded. */
/** @todo investigate what an EC is */ Q_ASSERT(false);
/** @todo NOTE THAT THE Z SEEMS TO ALWAYS BE 0.0! The Z must be taken
from the 2D POLYLINE elevation. */
basePoint.x = buf->getBitDouble(); /* Point 3BD 10 */
basePoint.y = buf->getBitDouble();
basePoint.z = buf->getBitDouble();
/* Start width BD 40 If it's negative, use the abs val for start AND end
widths (and note that no end width will be present). This is a compression
trick for cases where the start and end widths are identical and non-0. */
stawidth = buf->getBitDouble();
if ( stawidth < 0 )
{
stawidth *= -1;
endwidth = stawidth;
}
else
{
/* End width BD 41 Not present if the start width is < 0.0; see above. */
endwidth = buf->getBitDouble();
}
bulge =buf->getBitDouble();/* Bulge BD 42 */
if (version > DRW::AC1021) {//2010+
/* Vertex ID BL 91 */
identifier = buf->getBitLong();
}
/* Tangent dir BD 50 */
tgdir = buf->getBitDouble();
/* Common Entity Handle Data */
ret = DRW_Entity::parseDwgEntHandle(version, buf);
if (!ret)
return ret;
/* CRC X --- */
return buf->isGood();
}
bool DRW_Vertex::parseDwg3D(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing vertex *********************************************\n");
/* Flags EC 70 NOT bit-pair-coded. */
/** @todo investigate what an EC is */ Q_ASSERT(false);
basePoint.x = buf->getBitDouble(); /* Point 3BD 10 */
basePoint.y = buf->getBitDouble();
basePoint.z = buf->getBitDouble();
/* Common Entity Handle Data */
ret = DRW_Entity::parseDwgEntHandle(version, buf);
if (!ret)
return ret;
/* CRC X --- */
return buf->isGood();
}
bool DRW_Vertex::parseDwgMesh(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing vertex *********************************************\n");
/** @todo Same as VERTEX (3D) (11) except for type code.
TNick: what is the type code? Is the "Flags EC 70" field missing?
*/ Q_ASSERT(false);
/* Common Entity Handle Data */
ret = DRW_Entity::parseDwgEntHandle(version, buf);
if (!ret)
return ret;
/* CRC X --- */
return buf->isGood();
}
bool DRW_Vertex::parseDwgPFace(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing vertex *********************************************\n");
/** @todo Same as VERTEX (3D) (11) except for type code.
R13 .dwg files seem to have color and linetype data for all
PFACE VERTEXs (both types), but R12 and SAVEASR12 seem to omit
color and linetype when writing out the location VERTEXs.
TNick: what is the type code? Is the "Flags EC 70" field missing?
*/ Q_ASSERT(false);
/* Common Entity Handle Data */
ret = DRW_Entity::parseDwgEntHandle(version, buf);
if (!ret)
return ret;
/* CRC X --- */
return buf->isGood();
}
bool DRW_Vertex::parseDwgPFaceFace(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing vertex *********************************************\n");
/** @todo is a 1-based vertex index (see DXF doc);
*
* TNick: should we convert it to 0 based index?
*/
vindex1 = buf->getBitShort(); /* Vert index BS 71 */
vindex2 = buf->getBitShort(); /* Vert index BS 72 */
vindex3 = buf->getBitShort(); /* Vert index BS 73 */
vindex4 = buf->getBitShort(); /* Vert index BS 74 */
/* Common Entity Handle Data */
ret = DRW_Entity::parseDwgEntHandle(version, buf);
if (!ret)
return ret;
/* CRC X --- */
return buf->isGood();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment