58 controlPointIndex = 0;
64 leaderVertices =
NULL;
65 maxLeaderVertices = 0;
66 leaderVertexIndex = 0;
73 if (vertices !=
NULL) {
79 if (controlPoints !=
NULL) {
80 delete[] controlPoints;
82 if (fitPoints !=
NULL) {
85 if (weights !=
NULL) {
88 if (leaderVertices !=
NULL) {
89 delete[] leaderVertices;
111 fp = fopen(file.c_str(),
"rt");
113 std::locale oldLocale =
114 std::locale::global(std::locale(
"C"));
117 std::locale::global(oldLocale);
175 groupCode = (
unsigned int)
toInt(groupCodeTmp);
195 groupCode = (
unsigned int)
toInt(groupCodeTmp);
200 return !stream.eof();
226 char* wholeLine =
new char[
size];
230 line = fgets(wholeLine,
size, fp);
232 if (line !=
NULL && line[0] !=
'\0') {
240 assert(
size > s.length());
257 std::stringstream& stream,
261 char* line =
new char[
size + 1];
262 char* oriLine = line;
263 stream.getline(line,
size);
266 assert(
size > s.length());
287 int lastChar =
static_cast<int>(strlen(*s)) - 1;
290 while ((lastChar >= 0) &&
291 (((*s)[lastChar] == 10) || ((*s)[lastChar] == 13) ||
293 ((*s)[lastChar] ==
' ' || ((*s)[lastChar] ==
'\t'))))) {
294 (*s)[lastChar] =
'\0';
300 while ((*s)[0] ==
' ' || (*s)[0] ==
'\t') {
305 return ((*s) ? true :
false);
322 const std::string& groupValue) {
328 settingValue[0] =
'\0';
333 if (groupCode == 999) {
334 if (!groupValue.empty()) {
335 if (groupValue.substr(0, 6) ==
"dxflib") {
344 else if (groupCode == 0 || groupCode == 9) {
382 int elevationGroupCode = 30;
385 elevationGroupCode = 38;
388 elevationGroupCode = 30;
396 switch (currentObjectType) {
434 addRay(creationInterface);
451 addArc(creationInterface);
564 settingValue[0] =
'\0';
566 firstHatchLoop =
true;
570 xRecordValues =
false;
575 int prevEntity = currentObjectType;
578 if (groupValue[0] ==
'$') {
580 settingKey = groupValue;
584 else if (groupValue ==
"LAYER") {
589 else if (groupValue ==
"LTYPE") {
594 else if (groupValue ==
"BLOCK") {
596 }
else if (groupValue ==
"ENDBLK") {
601 else if (groupValue ==
"STYLE") {
606 else if (groupValue ==
"POINT") {
608 }
else if (groupValue ==
"LINE") {
610 }
else if (groupValue ==
"XLINE") {
612 }
else if (groupValue ==
"RAY") {
614 }
else if (groupValue ==
"POLYLINE") {
616 }
else if (groupValue ==
"LWPOLYLINE") {
618 }
else if (groupValue ==
"VERTEX") {
620 }
else if (groupValue ==
"SPLINE") {
622 }
else if (groupValue ==
"ARC") {
624 }
else if (groupValue ==
"ELLIPSE") {
626 }
else if (groupValue ==
"CIRCLE") {
628 }
else if (groupValue ==
"INSERT") {
630 }
else if (groupValue ==
"TEXT") {
632 }
else if (groupValue ==
"MTEXT") {
634 }
else if (groupValue ==
"ARCALIGNEDTEXT") {
636 }
else if (groupValue ==
"ATTRIB") {
638 }
else if (groupValue ==
"DIMENSION") {
640 }
else if (groupValue ==
"LEADER") {
642 }
else if (groupValue ==
"HATCH") {
644 }
else if (groupValue ==
"IMAGE") {
646 }
else if (groupValue ==
"IMAGEDEF") {
648 }
else if (groupValue ==
"TRACE") {
650 }
else if (groupValue ==
"SOLID") {
652 }
else if (groupValue ==
"3DFACE") {
654 }
else if (groupValue ==
"SEQEND") {
656 }
else if (groupValue ==
"XRECORD") {
658 }
else if (groupValue ==
"DICTIONARY") {
683 bool handled =
false;
685 switch (currentObjectType) {
729 values[groupCode] = groupValue;
742 const std::string& comment) {
760 std::map<int, std::string>::iterator it = values.begin();
761 if (it != values.end()) {
772 if (c >= 0 && c <= 9) {
777 values[c].c_str(), c);
781 else if (c >= 10 && c <= 39) {
789 else if (c >= 40 && c <= 59) {
794 else if (c >= 60 && c <= 99) {
818 std::transform(linetype.begin(), linetype.end(), linetype.begin(),
820 if (linetype ==
"BYLAYER" || linetype ==
"BYBLOCK") {
826 if (
name.length() == 0) {
838 if (
name.length() == 0) {
859 if (
name !=
"By Layer" &&
name !=
"By Block" &&
name !=
"BYLAYER" &&
869 if (groupCode == 49) {
882 if (
name.length() == 0) {
907 if (
name.length() == 0) {
972 creationInterface->
addRay(d);
984 maxVertices = std::min(maxVertices, vertexIndex + 1);
987 for (
int i = 0; i < maxVertices; i++) {
989 vertices[i * 4 + 2], vertices[i * 4 + 3]);
1032 for (i = 0; i < maxControlPoints; i++) {
1034 controlPoints[i * 3 + 2], weights[i]);
1038 for (i = 0; i < maxFitPoints; i++) {
1040 fitPoints[i * 3 + 2]);
1044 for (i = 0; i < maxKnots; i++) {
1047 creationInterface->
addKnot(k);
1060 creationInterface->
addArc(d);
1098 if (
name.length() == 0) {
1127 for (
int k = 0; k < 4; k++) {
1141 for (
int k = 0; k < 4; k++) {
1158 for (
int k = 0; k < 4; k++) {
1173 if (libVersion <= 0x02000200) {
1183 if (fabs(
x) < 1.0e-6) {
1187 angle =
M_PI / 2.0 * 3.0;
1190 angle = atan(
y /
x);
1224 if (groupCode == 105) {
1228 if (groupCode == 5) {
1233 if (groupCode == 280) {
1234 xRecordValues =
true;
1238 if (!xRecordValues) {
1243 if (groupCode <= 9 || groupCode == 100 || groupCode == 102 ||
1244 groupCode == 105 || (groupCode >= 300 && groupCode <= 369) ||
1245 (groupCode >= 1000 && groupCode <= 1009)) {
1251 else if ((groupCode >= 60 && groupCode <= 99) ||
1252 (groupCode >= 160 && groupCode <= 179) ||
1253 (groupCode >= 270 && groupCode <= 289)) {
1259 else if (groupCode >= 290 && groupCode <= 299) {
1265 else if ((groupCode >= 10 && groupCode <= 59) ||
1266 (groupCode >= 110 && groupCode <= 149) ||
1267 (groupCode >= 210 && groupCode <= 239)) {
1279 if (groupCode == 3) {
1283 if (groupCode == 5) {
1288 if (groupCode == 350) {
1300 if (groupCode == 1001) {
1303 }
else if (groupCode >= 1000 && groupCode <= 1009) {
1306 }
else if (groupCode >= 1010 && groupCode <= 1059) {
1309 }
else if (groupCode >= 1060 && groupCode <= 1070) {
1312 }
else if (groupCode == 1071) {
1325 if (groupCode == 3) {
1338 if (groupCode == 90) {
1339 maxVertices =
toInt(groupValue);
1340 if (maxVertices > 0) {
1341 if (vertices !=
NULL) {
1344 vertices =
new double[4 * maxVertices];
1345 for (
int i = 0; i < maxVertices; ++i) {
1346 vertices[i * 4] = 0.0;
1347 vertices[i * 4 + 1] = 0.0;
1348 vertices[i * 4 + 2] = 0.0;
1349 vertices[i * 4 + 3] = 0.0;
1357 else if (groupCode == 10 || groupCode == 20 || groupCode == 30 ||
1359 if (vertexIndex < maxVertices - 1 && groupCode == 10) {
1363 if (groupCode <= 30) {
1364 if (vertexIndex >= 0 && vertexIndex < maxVertices) {
1365 vertices[4 * vertexIndex + (groupCode / 10 - 1)] =
1368 }
else if (groupCode == 42 && vertexIndex < maxVertices) {
1369 vertices[4 * vertexIndex + 3] =
toReal(groupValue);
1381 if (groupCode == 72) {
1382 maxKnots =
toInt(groupValue);
1384 if (knots !=
NULL) {
1387 knots =
new double[maxKnots];
1388 for (
int i = 0; i < maxKnots; ++i) {
1397 else if (groupCode == 73) {
1398 maxControlPoints =
toInt(groupValue);
1399 if (maxControlPoints > 0) {
1400 if (controlPoints !=
NULL) {
1401 delete[] controlPoints;
1403 if (weights !=
NULL) {
1406 controlPoints =
new double[3 * maxControlPoints];
1407 weights =
new double[maxControlPoints];
1408 for (
int i = 0; i < maxControlPoints; ++i) {
1409 controlPoints[i * 3] = 0.0;
1410 controlPoints[i * 3 + 1] = 0.0;
1411 controlPoints[i * 3 + 2] = 0.0;
1415 controlPointIndex = -1;
1421 else if (groupCode == 74) {
1422 maxFitPoints =
toInt(groupValue);
1423 if (maxFitPoints > 0) {
1424 if (fitPoints !=
NULL) {
1427 fitPoints =
new double[3 * maxFitPoints];
1428 for (
int i = 0; i < maxFitPoints; ++i) {
1429 fitPoints[i * 3] = 0.0;
1430 fitPoints[i * 3 + 1] = 0.0;
1431 fitPoints[i * 3 + 2] = 0.0;
1439 else if (groupCode == 40) {
1440 if (knotIndex < maxKnots - 1) {
1442 knots[knotIndex] =
toReal(groupValue);
1448 else if (groupCode == 10 || groupCode == 20 || groupCode == 30) {
1449 if (controlPointIndex < maxControlPoints - 1 && groupCode == 10) {
1450 controlPointIndex++;
1453 if (controlPointIndex >= 0 && controlPointIndex < maxControlPoints) {
1454 controlPoints[3 * controlPointIndex + (groupCode / 10 - 1)] =
1461 else if (groupCode == 11 || groupCode == 21 || groupCode == 31) {
1462 if (fitPointIndex < maxFitPoints - 1 && groupCode == 11) {
1466 if (fitPointIndex >= 0 && fitPointIndex < maxFitPoints) {
1467 fitPoints[3 * fitPointIndex + ((groupCode - 1) / 10 - 1)] =
1474 else if (groupCode == 41) {
1475 if (weightIndex < maxControlPoints - 1) {
1479 if (weightIndex >= 0 && weightIndex < maxControlPoints) {
1480 weights[weightIndex] =
toReal(groupValue);
1492 if (groupCode == 76) {
1493 maxLeaderVertices =
toInt(groupValue);
1494 if (maxLeaderVertices > 0) {
1495 if (leaderVertices !=
NULL) {
1496 delete[] leaderVertices;
1498 leaderVertices =
new double[3 * maxLeaderVertices];
1499 for (
int i = 0; i < maxLeaderVertices; ++i) {
1500 leaderVertices[i * 3] = 0.0;
1501 leaderVertices[i * 3 + 1] = 0.0;
1502 leaderVertices[i * 3 + 2] = 0.0;
1505 leaderVertexIndex = -1;
1510 else if (groupCode == 10 || groupCode == 20 || groupCode == 30) {
1511 if (leaderVertexIndex < maxLeaderVertices - 1 && groupCode == 10) {
1512 leaderVertexIndex++;
1515 if (groupCode <= 30) {
1516 if (leaderVertexIndex >= 0 &&
1517 leaderVertexIndex < maxLeaderVertices) {
1518 leaderVertices[3 * leaderVertexIndex + (groupCode / 10 - 1)] =
1555 creationInterface->
addText(d);
1803 for (
int i = 0; i < maxLeaderVertices; i++) {
1805 leaderVertices[i * 3 + 2]);
1822 for (
unsigned int i = 0; i < hatchEdges.size(); i++) {
1825 for (
unsigned int k = 0; k < hatchEdges[i].size(); k++) {
1835 hatchEdges.push_back(std::vector<DL_HatchEdgeData>());
1840 if (hatchEdges.size() > 0) {
1841 hatchEdges.back().push_back(hatchEdge);
1853 if (groupCode == 92 || groupCode == 93) {
1854 if (firstHatchLoop) {
1856 firstHatchLoop =
false;
1858 if (groupCode == 92 && (
toInt(groupValue) & 2) == 2) {
1861 if (groupCode == 93) {
1868 if (groupCode == 72 || groupCode == 0 || groupCode == 78 ||
1871 if (groupCode != 72 || (
getIntValue(92, 0) & 2) == 0) {
1875 if (groupCode == 0 ) {
1885 switch (groupCode) {
1888 hatchEdge.
vertices.push_back(std::vector<double>());
1906 if (hatchEdge.
type == 1) {
1907 switch (groupCode) {
1925 if (hatchEdge.
type == 2) {
1926 switch (groupCode) {
1943 hatchEdge.
ccw = (bool)
toInt(groupValue);
1950 if (hatchEdge.
type == 3) {
1951 switch (groupCode) {
1974 hatchEdge.
ccw = (bool)
toInt(groupValue);
1981 if (hatchEdge.
type == 4) {
1982 switch (groupCode) {
2008 std::vector<double> v;
2009 v.push_back(
toReal(groupValue));
2028 std::vector<double> v;
2029 v.push_back(
toReal(groupValue));
2035 hatchEdge.
fitPoints.back().size() == 1) {
2150 char* f =
new char[strlen(file) + 1];
2329 if (fabs(
data.bulge) > 1.0e-10) {
2337 if (fabs(
data.bulge) > 1.0e-10) {
2577 if (
data.name.empty()) {
2578 std::cerr <<
"DL_Dxf::writeInsert: "
2579 <<
"Block name must not be empty\n";
2589 if (
data.cols != 1 ||
data.rows != 1) {
2592 dw.
dxfString(100,
"AcDbBlockReference");
2599 if (
data.sx != 1.0 ||
data.sy != 1.0) {
2604 if (
data.angle != 0.0) {
2607 if (
data.cols != 1 ||
data.rows != 1) {
2611 if (
data.colSp != 0.0 ||
data.rowSp != 0.0) {
2645 int length =
static_cast<int>(
data.text.length());
2648 for (i = 250; i < length; i += 250) {
2649 strncpy(chunk, &
data.text.c_str()[i - 250], 250);
2653 strncpy(chunk, &
data.text.c_str()[i - 250], 250);
2801 dw.
dxfString(100,
"AcDbAlignedDimension");
2859 dw.
dxfString(100,
"AcDbAlignedDimension");
2873 dw.
dxfString(100,
"AcDbRotatedDimension");
2923 dw.
dxfString(100,
"AcDbRadialDimension");
2979 dw.
dxfString(100,
"AcDbDiametricDimension");
3035 dw.
dxfString(100,
"AcDb2LineAngularDimension");
3099 dw.
dxfString(100,
"AcDb3PointAngularDimension");
3162 dw.
dxfString(100,
"AcDbOrdinateDimension");
3246 if (
data.solid ==
false) {
3268 if (
data.solid ==
false) {
3277 dw.
dxfReal(45, -0.0883883476483184);
3278 dw.
dxfReal(46, 0.0883883476483185);
3324 if (
data.type < 1 ||
data.type > 4) {
3325 printf(
"WARNING: unsupported hatch edge type: %d",
data.type);
3330 switch (
data.type) {
3368 for (
unsigned int i = 0; i <
data.knots.size(); i++) {
3371 for (
unsigned int i = 0; i <
data.controlPoints.size(); i++) {
3375 for (
unsigned int i = 0; i <
data.weights.size(); i++) {
3378 if (
data.nFit > 0) {
3380 for (
unsigned int i = 0; i <
data.fitPoints.size(); i++) {
3385 if (fabs(
data.startTangentX) > 1.0e-4 ||
3386 fabs(
data.startTangentY) > 1.0e-4) {
3390 if (fabs(
data.endTangentX) > 1.0e-4 ||
3391 fabs(
data.endTangentY) > 1.0e-4) {
3481 dw.
dxfString(100,
"AcDbRasterImageDef");
3511 if (
data.name.empty()) {
3512 std::cerr <<
"DL_Dxf::writeLayer: "
3513 <<
"Layer name must not be empty\n";
3519 std::cerr <<
"Layer color cannot be " <<
color <<
". Changed to 7.\n";
3527 if (
data.name ==
"0") {
3541 (attrib.
getLinetype().length() == 0 ? std::string(
"CONTINUOUS")
3546 std::string lstr =
data.name;
3547 std::transform(lstr.begin(), lstr.end(), lstr.begin(), tolower);
3548 if (lstr ==
"defpoints") {
3565 std::string nameUpper =
data.name;
3566 std::transform(nameUpper.begin(), nameUpper.end(), nameUpper.begin(),
3569 if (
data.name.empty()) {
3570 std::cerr <<
"DL_Dxf::writeLinetype: "
3571 <<
"Line type name must not be empty\n";
3577 if (nameUpper ==
"BYBLOCK" || nameUpper ==
"BYLAYER") {
3583 if (nameUpper ==
"BYBLOCK") {
3585 }
else if (nameUpper ==
"BYLAYER") {
3587 }
else if (nameUpper ==
"CONTINUOUS") {
3596 if (nameUpper ==
"BYBLOCK") {
3601 }
else if (nameUpper ==
"BYLAYER") {
3606 }
else if (nameUpper ==
"CONTINUOUS") {
3616 for (
int i = 0; i <
data.numberOfDashes; i++) {
3632 std::cerr <<
"DL_Dxf::writeAppid: "
3633 <<
"Application name must not be empty\n";
3637 std::string n =
name;
3638 std::transform(n.begin(), n.end(), n.begin(), ::toupper);
3653 if (
data.name.empty()) {
3654 std::cerr <<
"DL_Dxf::writeBlock: "
3655 <<
"Block name must not be empty\n";
3659 std::string n =
data.name;
3660 std::transform(n.begin(), n.end(), n.begin(), ::toupper);
3662 if (n ==
"*PAPER_SPACE") {
3664 }
else if (n ==
"*MODEL_SPACE") {
3666 }
else if (n ==
"*PAPER_SPACE0") {
3684 std::string n =
name;
3685 std::transform(n.begin(), n.end(), n.begin(), ::toupper);
3687 if (n ==
"*PAPER_SPACE") {
3689 }
else if (n ==
"*MODEL_SPACE") {
3691 }
else if (n ==
"*PAPER_SPACE0") {
3721 dw.
dxfString(100,
"AcDbSymbolTableRecord");
3722 dw.
dxfString(100,
"AcDbViewportTableRecord");
3730 dw.
dxfReal(12, 286.3055555555555);
3745 dw.
dxfReal(41, 1.92798353909465);
3794 if (style.
name ==
"Standard") {
3796 styleHandleStd = dw.
handle();
3803 dw.
dxfString(100,
"AcDbSymbolTableRecord");
3804 dw.
dxfString(100,
"AcDbTextStyleTableRecord");
3821 xFlags = xFlags | 0x2000000;
3824 xFlags = xFlags | 0x1000000;
3902 dw.
dxfString(100,
"AcDbSymbolTableRecord");
3903 dw.
dxfString(100,
"AcDbDimStyleTableRecord");
3943 dw.
dxfReal(143, 0.03937007874016);
3970 dw.
dxfHex(340, styleHandleStd);
4002 dw.
dxfString(100,
"AcDbSymbolTableRecord");
4003 dw.
dxfString(100,
"AcDbBlockTableRecord");
4016 dw.
dxfString(100,
"AcDbSymbolTableRecord");
4017 dw.
dxfString(100,
"AcDbBlockTableRecord");
4030 dw.
dxfString(100,
"AcDbSymbolTableRecord");
4031 dw.
dxfString(100,
"AcDbBlockTableRecord");
4049 dw.
dxfString(100,
"AcDbSymbolTableRecord");
4050 dw.
dxfString(100,
"AcDbBlockTableRecord");
4062 const std::string& appDictionaryName) {
4081 dw.
dxfString(3,
"AcDbVariableDictionary");
4082 int acDbVariableDictionaryHandle = dw.
handle(350);
4087 if (appDictionaryName.length() != 0) {
4089 appDictionaryHandle = dw.
handle(350);
4112 dw.
dxfString(100,
"AcDbDictionaryWithDefault");
4218 dw.
dxfReal(14, 1.000000000000000E+20);
4219 dw.
dxfReal(24, 1.000000000000000E+20);
4220 dw.
dxfReal(34, 1.000000000000000E+20);
4221 dw.
dxfReal(15, -1.000000000000000E+20);
4222 dw.
dxfReal(25, -1.000000000000000E+20);
4223 dw.
dxfReal(35, -1.000000000000000E+20);
4367 dw.
dxfHex(5, acDbVariableDictionaryHandle);
4383 dw.
dxfString(100,
"DictionaryVariables");
4391 dw.
dxfString(100,
"DictionaryVariables");
4399 dw.
dxfHex(5, appDictionaryHandle);
4415 dw.
dxfHex(330, appDictionaryHandle);
4424 dw.
dxfHex(330, appDictionaryHandle);
4433 dw.
dxfHex(330, appDictionaryHandle);
4441 const std::string& value) {
4444 dw.
dxfHex(330, appDictionaryHandle);
4472 if (!strcmp(var,
"$ACADVER")) {
4475 if (!strcmp(var,
"$ACADVER")) {
4478 if (!strcmp(var,
"$ANGBASE")) {
4481 if (!strcmp(var,
"$ANGDIR")) {
4484 if (!strcmp(var,
"$ATTDIA")) {
4487 if (!strcmp(var,
"$ATTMODE")) {
4490 if (!strcmp(var,
"$ATTREQ")) {
4493 if (!strcmp(var,
"$AUNITS")) {
4496 if (!strcmp(var,
"$AUPREC")) {
4499 if (!strcmp(var,
"$AXISMODE")) {
4502 if (!strcmp(var,
"$AXISUNIT")) {
4505 if (!strcmp(var,
"$BLIPMODE")) {
4508 if (!strcmp(var,
"$CECOLOR")) {
4511 if (!strcmp(var,
"$CELTYPE")) {
4514 if (!strcmp(var,
"$CHAMFERA")) {
4517 if (!strcmp(var,
"$CHAMFERB")) {
4520 if (!strcmp(var,
"$CLAYER")) {
4523 if (!strcmp(var,
"$COORDS")) {
4526 if (!strcmp(var,
"$DIMALT")) {
4529 if (!strcmp(var,
"$DIMALTD")) {
4532 if (!strcmp(var,
"$DIMALTF")) {
4535 if (!strcmp(var,
"$DIMAPOST")) {
4538 if (!strcmp(var,
"$DIMASO")) {
4541 if (!strcmp(var,
"$DIMASZ")) {
4544 if (!strcmp(var,
"$DIMBLK")) {
4547 if (!strcmp(var,
"$DIMBLK1")) {
4550 if (!strcmp(var,
"$DIMBLK2")) {
4553 if (!strcmp(var,
"$DIMCEN")) {
4556 if (!strcmp(var,
"$DIMCLRD")) {
4559 if (!strcmp(var,
"$DIMCLRE")) {
4562 if (!strcmp(var,
"$DIMCLRT")) {
4565 if (!strcmp(var,
"$DIMDLE")) {
4568 if (!strcmp(var,
"$DIMDLI")) {
4571 if (!strcmp(var,
"$DIMEXE")) {
4574 if (!strcmp(var,
"$DIMEXO")) {
4577 if (!strcmp(var,
"$DIMGAP")) {
4580 if (!strcmp(var,
"$DIMLFAC")) {
4583 if (!strcmp(var,
"$DIMLIM")) {
4586 if (!strcmp(var,
"$DIMPOST")) {
4589 if (!strcmp(var,
"$DIMRND")) {
4592 if (!strcmp(var,
"$DIMSAH")) {
4595 if (!strcmp(var,
"$DIMSCALE")) {
4598 if (!strcmp(var,
"$DIMSE1")) {
4601 if (!strcmp(var,
"$DIMSE2")) {
4604 if (!strcmp(var,
"$DIMSHO")) {
4607 if (!strcmp(var,
"$DIMSOXD")) {
4610 if (!strcmp(var,
"$DIMSTYLE")) {
4613 if (!strcmp(var,
"$DIMTAD")) {
4616 if (!strcmp(var,
"$DIMTFAC")) {
4619 if (!strcmp(var,
"$DIMTIH")) {
4622 if (!strcmp(var,
"$DIMTIX")) {
4625 if (!strcmp(var,
"$DIMTM")) {
4628 if (!strcmp(var,
"$DIMTOFL")) {
4631 if (!strcmp(var,
"$DIMTOH")) {
4634 if (!strcmp(var,
"$DIMTOL")) {
4637 if (!strcmp(var,
"$DIMTP")) {
4640 if (!strcmp(var,
"$DIMTSZ")) {
4643 if (!strcmp(var,
"$DIMTVP")) {
4646 if (!strcmp(var,
"$DIMTXT")) {
4649 if (!strcmp(var,
"$DIMZIN")) {
4652 if (!strcmp(var,
"$DWGCODEPAGE")) {
4655 if (!strcmp(var,
"$DRAGMODE")) {
4658 if (!strcmp(var,
"$ELEVATION")) {
4661 if (!strcmp(var,
"$EXTMAX")) {
4664 if (!strcmp(var,
"$EXTMIN")) {
4667 if (!strcmp(var,
"$FILLETRAD")) {
4670 if (!strcmp(var,
"$FILLMODE")) {
4673 if (!strcmp(var,
"$HANDLING")) {
4676 if (!strcmp(var,
"$HANDSEED")) {
4679 if (!strcmp(var,
"$INSBASE")) {
4682 if (!strcmp(var,
"$LIMCHECK")) {
4685 if (!strcmp(var,
"$LIMMAX")) {
4688 if (!strcmp(var,
"$LIMMIN")) {
4691 if (!strcmp(var,
"$LTSCALE")) {
4694 if (!strcmp(var,
"$LUNITS")) {
4697 if (!strcmp(var,
"$LUPREC")) {
4700 if (!strcmp(var,
"$MAXACTVP")) {
4703 if (!strcmp(var,
"$MENU")) {
4706 if (!strcmp(var,
"$MIRRTEXT")) {
4709 if (!strcmp(var,
"$ORTHOMODE")) {
4712 if (!strcmp(var,
"$OSMODE")) {
4715 if (!strcmp(var,
"$PDMODE")) {
4718 if (!strcmp(var,
"$PDSIZE")) {
4721 if (!strcmp(var,
"$PELEVATION")) {
4724 if (!strcmp(var,
"$PEXTMAX")) {
4727 if (!strcmp(var,
"$PEXTMIN")) {
4730 if (!strcmp(var,
"$PLIMCHECK")) {
4733 if (!strcmp(var,
"$PLIMMAX")) {
4736 if (!strcmp(var,
"$PLIMMIN")) {
4739 if (!strcmp(var,
"$PLINEGEN")) {
4742 if (!strcmp(var,
"$PLINEWID")) {
4745 if (!strcmp(var,
"$PSLTSCALE")) {
4748 if (!strcmp(var,
"$PUCSNAME")) {
4751 if (!strcmp(var,
"$PUCSORG")) {
4754 if (!strcmp(var,
"$PUCSXDIR")) {
4757 if (!strcmp(var,
"$PUCSYDIR")) {
4760 if (!strcmp(var,
"$QTEXTMODE")) {
4763 if (!strcmp(var,
"$REGENMODE")) {
4766 if (!strcmp(var,
"$SHADEDGE")) {
4769 if (!strcmp(var,
"$SHADEDIF")) {
4772 if (!strcmp(var,
"$SKETCHINC")) {
4775 if (!strcmp(var,
"$SKPOLY")) {
4778 if (!strcmp(var,
"$SPLFRAME")) {
4781 if (!strcmp(var,
"$SPLINESEGS")) {
4784 if (!strcmp(var,
"$SPLINETYPE")) {
4787 if (!strcmp(var,
"$SURFTAB1")) {
4790 if (!strcmp(var,
"$SURFTAB2")) {
4793 if (!strcmp(var,
"$SURFTYPE")) {
4796 if (!strcmp(var,
"$SURFU")) {
4799 if (!strcmp(var,
"$SURFV")) {
4802 if (!strcmp(var,
"$TDCREATE")) {
4805 if (!strcmp(var,
"$TDINDWG")) {
4808 if (!strcmp(var,
"$TDUPDATE")) {
4811 if (!strcmp(var,
"$TDUSRTIMER")) {
4814 if (!strcmp(var,
"$TEXTSIZE")) {
4817 if (!strcmp(var,
"$TEXTSTYLE")) {
4820 if (!strcmp(var,
"$THICKNESS")) {
4823 if (!strcmp(var,
"$TILEMODE")) {
4826 if (!strcmp(var,
"$TRACEWID")) {
4829 if (!strcmp(var,
"$UCSNAME")) {
4832 if (!strcmp(var,
"$UCSORG")) {
4835 if (!strcmp(var,
"$UCSXDIR")) {
4838 if (!strcmp(var,
"$UCSYDIR")) {
4841 if (!strcmp(var,
"$UNITMODE")) {
4844 if (!strcmp(var,
"$USERI1")) {
4847 if (!strcmp(var,
"$USERR1")) {
4850 if (!strcmp(var,
"$USRTIMER")) {
4853 if (!strcmp(var,
"$VISRETAIN")) {
4856 if (!strcmp(var,
"$WORLDVIEW")) {
4859 if (!strcmp(var,
"$FASTZOOM")) {
4862 if (!strcmp(var,
"$GRIDMODE")) {
4865 if (!strcmp(var,
"$GRIDUNIT")) {
4868 if (!strcmp(var,
"$SNAPANG")) {
4871 if (!strcmp(var,
"$SNAPBASE")) {
4874 if (!strcmp(var,
"$SNAPISOPAIR")) {
4877 if (!strcmp(var,
"$SNAPMODE")) {
4880 if (!strcmp(var,
"$SNAPSTYLE")) {
4883 if (!strcmp(var,
"$SNAPUNIT")) {
4886 if (!strcmp(var,
"$VIEWCTR")) {
4889 if (!strcmp(var,
"$VIEWDIR")) {
4892 if (!strcmp(var,
"$VIEWSIZE")) {
4912 for (
unsigned int i = 0; i < str.length() && idx < 3; ++i) {
4913 if (str[i] ==
'.') {
4920 d[3] =
static_cast<int>(str.length());
4922 v[0] = str.substr(0, d[0]);
4923 v[1] = str.substr(d[0] + 1, d[1] - d[0] - 1);
4924 v[2] = str.substr(d[1] + 1, d[2] - d[1] - 1);
4926 v[3] = str.substr(d[2] + 1, d[3] - d[2] - 1);
4931 ret = (atoi(v[0].c_str()) << (3 * 8)) +
4932 (atoi(v[1].c_str()) << (2 * 8)) +
4933 (atoi(v[2].c_str()) << (1 * 8)) + (atoi(v[3].c_str()) << (0 * 8));
4937 std::cerr <<
"DL_Dxf::getLibVersion: invalid version number: " << str
4982 buf1 =
new char[10];
4983 buf2 =
new char[10];
4984 buf3 =
new char[10];
4985 buf4 =
new char[10];
4986 buf5 =
new char[10];
4987 buf6 =
new char[10];
4989 strcpy(buf1,
" 10\n");
4991 strcpy(buf3,
"10\n");
4992 strcpy(buf4,
" 10 \n");
4993 strcpy(buf5,
" 10 \r");
4994 strcpy(buf6,
"\t10 \n");
4996 std::cout <<
"1 buf1: '" << buf1 <<
"'\n";
4998 std::cout <<
"2 buf1: '" << buf1 <<
"'\n";
5001 std::cout <<
"1 buf2: '" << buf2 <<
"'\n";
5003 std::cout <<
"2 buf2: '" << buf2 <<
"'\n";
5005 std::cout <<
"1 buf3: '" << buf3 <<
"'\n";
5007 std::cout <<
"2 buf3: '" << buf3 <<
"'\n";
5009 std::cout <<
"1 buf4: '" << buf4 <<
"'\n";
5011 std::cout <<
"2 buf4: '" << buf4 <<
"'\n";
5013 std::cout <<
"1 buf5: '" << buf5 <<
"'\n";
5015 std::cout <<
"2 buf5: '" << buf5 <<
"'\n";
5017 std::cout <<
"1 buf6: '" << buf6 <<
"'\n";
5019 std::cout <<
"2 buf6: '" << buf6 <<
"'\n";
std::string getLinetype() const
void setLinetype(const std::string &linetype)
void setInPaperSpace(bool on)
std::string getLayer() const
void setLinetypeScale(double linetypeScale)
virtual void addBlock(const DL_BlockData &data)=0
virtual void addHatchEdge(const DL_HatchEdgeData &data)=0
virtual void addDimAngular3P(const DL_DimensionData &data, const DL_DimAngular3PData &edata)=0
virtual void addEllipse(const DL_EllipseData &data)=0
virtual void add3dFace(const DL_3dFaceData &data)=0
virtual void addSolid(const DL_SolidData &data)=0
virtual void addVertex(const DL_VertexData &data)=0
virtual void addInsert(const DL_InsertData &data)=0
virtual void addDimRadial(const DL_DimensionData &data, const DL_DimRadialData &edata)=0
virtual void addDimAlign(const DL_DimensionData &data, const DL_DimAlignedData &edata)=0
void setAttributes(const DL_Attributes &attrib)
virtual void addDictionary(const DL_DictionaryData &data)=0
virtual void addComment(const std::string &comment)=0
virtual void addXDataString(int code, const std::string &value)=0
virtual void addXRecord(const std::string &handle)=0
virtual void addPoint(const DL_PointData &data)=0
virtual void setVariableVector(const std::string &key, double v1, double v2, double v3, int code)=0
virtual void addDimAngular(const DL_DimensionData &data, const DL_DimAngularData &edata)=0
virtual void linkImage(const DL_ImageDefData &data)=0
virtual void addArcAlignedText(const DL_ArcAlignedTextData &data)=0
virtual void addLinetype(const DL_LinetypeData &data)=0
virtual void addArc(const DL_ArcData &data)=0
virtual void addFitPoint(const DL_FitPointData &data)=0
virtual void addXRecordReal(int code, double value)=0
virtual void addText(const DL_TextData &data)=0
virtual void addDimOrdinate(const DL_DimensionData &data, const DL_DimOrdinateData &edata)=0
virtual void addRay(const DL_RayData &data)=0
virtual void addLeaderVertex(const DL_LeaderVertexData &data)=0
DL_Attributes getAttributes()
virtual void addMTextChunk(const std::string &text)=0
virtual void addLine(const DL_LineData &data)=0
virtual void endSection()=0
virtual void addXRecordString(int code, const std::string &value)=0
virtual void addAttribute(const DL_AttributeData &data)=0
virtual void addTextStyle(const DL_StyleData &data)=0
virtual void endSequence()=0
virtual void addDictionaryEntry(const DL_DictionaryEntryData &data)=0
virtual void addTrace(const DL_TraceData &data)=0
virtual void addHatchLoop(const DL_HatchLoopData &data)=0
virtual void addDimLinear(const DL_DimensionData &data, const DL_DimLinearData &edata)=0
virtual void addImage(const DL_ImageData &data)=0
virtual void addDimDiametric(const DL_DimensionData &data, const DL_DimDiametricData &edata)=0
virtual void addLayer(const DL_LayerData &data)=0
virtual void processCodeValuePair(unsigned int groupCode, const std::string &groupValue)=0
void setExtrusion(double dx, double dy, double dz, double elevation)
virtual void endBlock()=0
virtual void addXDataApp(const std::string &appId)=0
virtual void addMText(const DL_MTextData &data)=0
virtual void addXRecordInt(int code, int value)=0
virtual void setVariableString(const std::string &key, const std::string &value, int code)=0
virtual void addXDataInt(int code, int value)=0
virtual void addHatch(const DL_HatchData &data)=0
virtual void addLinetypeDash(double length)=0
virtual void setVariableDouble(const std::string &key, double value, int code)=0
virtual void addXRecordBool(int code, bool value)=0
virtual void addXDataReal(int code, double value)=0
virtual void addLeader(const DL_LeaderData &data)=0
virtual void addCircle(const DL_CircleData &data)=0
virtual void addSpline(const DL_SplineData &data)=0
virtual void endEntity()=0
virtual void addControlPoint(const DL_ControlPointData &data)=0
virtual void addXLine(const DL_XLineData &data)=0
virtual void setVariableInt(const std::string &key, int value, int code)=0
virtual void addKnot(const DL_KnotData &data)=0
virtual void addPolyline(const DL_PolylineData &data)=0
void addDictionary(DL_CreationInterface *creationInterface)
double toReal(const std::string &str)
void addComment(DL_CreationInterface *creationInterface, const std::string &comment)
void writeXLine(DL_WriterA &dw, const DL_XLineData &data, const DL_Attributes &attrib)
void writeView(DL_WriterA &dw)
void writeDimAligned(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimAlignedData &edata, const DL_Attributes &attrib)
void addMText(DL_CreationInterface *creationInterface)
void writeObjects(DL_WriterA &dw, const std::string &appDictionaryName="")
void addDictionaryEntry(DL_CreationInterface *creationInterface)
void writeTrace(DL_WriterA &dw, const DL_TraceData &data, const DL_Attributes &attrib)
void addPolyline(DL_CreationInterface *creationInterface)
void writeArc(DL_WriterA &dw, const DL_ArcData &data, const DL_Attributes &attrib)
void addSpline(DL_CreationInterface *creationInterface)
bool handleDictionaryData(DL_CreationInterface *creationInterface)
void write3dFace(DL_WriterA &dw, const DL_3dFaceData &data, const DL_Attributes &attrib)
void writeImageDef(DL_WriterA &dw, int handle, const DL_ImageData &data)
void writeLeaderVertex(DL_WriterA &dw, const DL_LeaderVertexData &data)
void writeHatchEdge(DL_WriterA &dw, const DL_HatchEdgeData &data)
void endBlock(DL_CreationInterface *creationInterface)
bool handleHatchData(DL_CreationInterface *creationInterface)
void writeStyle(DL_WriterA &dw, const DL_StyleData &style)
void addLinetype(DL_CreationInterface *creationInterface)
void writeObjectsEnd(DL_WriterA &dw)
void addEllipse(DL_CreationInterface *creationInterface)
void writePolyline(DL_WriterA &dw, const DL_PolylineData &data, const DL_Attributes &attrib)
void writeFitPoint(DL_WriterA &dw, const DL_FitPointData &data)
bool handleSplineData(DL_CreationInterface *creationInterface)
void writeDimStyle(DL_WriterA &dw, double dimasz, double dimexe, double dimexo, double dimgap, double dimtxt)
void addBlock(DL_CreationInterface *creationInterface)
void endSequence(DL_CreationInterface *creationInterface)
void writeRay(DL_WriterA &dw, const DL_RayData &data, const DL_Attributes &attrib)
void writeVPort(DL_WriterA &dw)
void writeAttribute(DL_WriterA &dw, const DL_AttributeData &data, const DL_Attributes &attrib)
void writeDimRadial(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimRadialData &edata, const DL_Attributes &attrib)
void writePoint(DL_WriterA &dw, const DL_PointData &data, const DL_Attributes &attrib)
void addArc(DL_CreationInterface *creationInterface)
void writeDimDiametric(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimDiametricData &edata, const DL_Attributes &attrib)
void addSetting(DL_CreationInterface *creationInterface)
void writeCircle(DL_WriterA &dw, const DL_CircleData &data, const DL_Attributes &attrib)
bool handleLWPolylineData(DL_CreationInterface *creationInterface)
void addVertex(DL_CreationInterface *creationInterface)
void addDimOrdinate(DL_CreationInterface *creationInterface)
int writeImage(DL_WriterA &dw, const DL_ImageData &data, const DL_Attributes &attrib)
void writeHeader(DL_WriterA &dw)
Writes a DXF header to the file currently opened by the given DXF writer object.
void addLeader(DL_CreationInterface *creationInterface)
void writeText(DL_WriterA &dw, const DL_TextData &data, const DL_Attributes &attrib)
void writeSpline(DL_WriterA &dw, const DL_SplineData &data, const DL_Attributes &attrib)
bool handleXData(DL_CreationInterface *creationInterface)
bool handleXRecordData(DL_CreationInterface *creationInterface)
bool readDxfGroups(FILE *fp, DL_CreationInterface *creationInterface)
Reads a group couplet from a DXF file. Calls another function to process it.
void writeEndBlock(DL_WriterA &dw, const std::string &name)
void addXLine(DL_CreationInterface *creationInterface)
void addTextStyle(DL_CreationInterface *creationInterface)
void addLine(DL_CreationInterface *creationInterface)
bool handleMTextData(DL_CreationInterface *creationInterface)
void writeVertex(DL_WriterA &dw, const DL_VertexData &data)
void addHatch(DL_CreationInterface *creationInterface)
int toInt(const std::string &str)
static bool getStrippedLine(std::string &s, unsigned int size, FILE *stream, bool stripSpace=true)
Reads line from file & strips whitespace at start and newline at end.
void writeSolid(DL_WriterA &dw, const DL_SolidData &data, const DL_Attributes &attrib)
void writeLayer(DL_WriterA &dw, const DL_LayerData &data, const DL_Attributes &attrib)
void writeDimOrdinate(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimOrdinateData &edata, const DL_Attributes &attrib)
int getInt16Value(int code, int def)
void addDimAligned(DL_CreationInterface *creationInterface)
void addSolid(DL_CreationInterface *creationInterface)
void addTrace(DL_CreationInterface *creationInterface)
void addRay(DL_CreationInterface *creationInterface)
void writeAppDictionary(DL_WriterA &dw)
void writeBlock(DL_WriterA &dw, const DL_BlockData &data)
void writeAppid(DL_WriterA &dw, const std::string &name)
void addImageDef(DL_CreationInterface *creationInterface)
DL_DimensionData getDimData()
void addDimDiametric(DL_CreationInterface *creationInterface)
void addDimRadial(DL_CreationInterface *creationInterface)
void writeControlPoint(DL_WriterA &dw, const DL_ControlPointData &data)
void writeLeader(DL_WriterA &dw, const DL_LeaderData &data, const DL_Attributes &attrib)
void writeHatchLoop1(DL_WriterA &dw, const DL_HatchLoopData &data)
void addLayer(DL_CreationInterface *creationInterface)
void addDimAngular(DL_CreationInterface *creationInterface)
void writeUcs(DL_WriterA &dw)
void endEntity(DL_CreationInterface *creationInterface)
void addImage(DL_CreationInterface *creationInterface)
void writeXRecord(DL_WriterA &dw, int handle, int value)
void addCircle(DL_CreationInterface *creationInterface)
static bool stripWhiteSpace(char **s, bool stripSpaces=true)
Strips leading whitespace and trailing Carriage Return (CR) and Line Feed (LF) from NULL terminated s...
bool handleLeaderData(DL_CreationInterface *creationInterface)
static bool checkVariable(const char *var, DL_Codes::version version)
int getIntValue(int code, int def)
void addPoint(DL_CreationInterface *creationInterface)
double getRealValue(int code, double def)
void writeDimLinear(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimLinearData &edata, const DL_Attributes &attrib)
void writeEllipse(DL_WriterA &dw, const DL_EllipseData &data, const DL_Attributes &attrib)
void writeHatch2(DL_WriterA &dw, const DL_HatchData &data, const DL_Attributes &attrib)
void writeLinetype(DL_WriterA &dw, const DL_LinetypeData &data)
void writeHatch1(DL_WriterA &dw, const DL_HatchData &data, const DL_Attributes &attrib)
void writeLine(DL_WriterA &dw, const DL_LineData &data, const DL_Attributes &attrib)
int getLibVersion(const std::string &str)
void writeDimStyleOverrides(DL_WriterA &dw, const DL_DimensionData &data)
bool processDXFGroup(DL_CreationInterface *creationInterface, int groupCode, const std::string &groupValue)
void addDimAngular3P(DL_CreationInterface *creationInterface)
void writeDimAngular3P(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimAngular3PData &edata, const DL_Attributes &attrib)
void addText(DL_CreationInterface *creationInterface)
void writePolylineEnd(DL_WriterA &dw)
void addDimLinear(DL_CreationInterface *creationInterface)
void writeDimAngular(DL_WriterA &dw, const DL_DimensionData &data, const DL_DimAngularData &edata, const DL_Attributes &attrib)
void writeInsert(DL_WriterA &dw, const DL_InsertData &data, const DL_Attributes &attrib)
void writeHatchLoop2(DL_WriterA &dw, const DL_HatchLoopData &data)
bool toBool(const std::string &str)
bool handleLinetypeData(DL_CreationInterface *creationInterface)
void writeBlockRecord(DL_WriterA &dw)
int writeDictionaryEntry(DL_WriterA &dw, const std::string &name)
bool in(const std::string &file, DL_CreationInterface *creationInterface)
Reads the given file and calls the appropriate functions in the given creation interface for every en...
DL_WriterA * out(const char *file, DL_Codes::version version=DL_Codes::AC1015)
Opens the given file for writing and returns a pointer to the dxf writer. This pointer needs to be pa...
void writeKnot(DL_WriterA &dw, const DL_KnotData &data)
void add3dFace(DL_CreationInterface *creationInterface)
void addInsert(DL_CreationInterface *creationInterface)
void writeMText(DL_WriterA &dw, const DL_MTextData &data, const DL_Attributes &attrib)
void writeComment(DL_WriterA &dw, const std::string &comment)
std::string getStringValue(int code, const std::string &def)
void addArcAlignedText(DL_CreationInterface *creationInterface)
void addAttribute(DL_CreationInterface *creationInterface)
void dxfReal(int gc, double value) const
void dxfInt(int gc, int value) const
void dxfString(int gc, const char *value) const
void dxfHex(int gc, int value) const
void tableLinetypeEntry(unsigned long int h=0) const
unsigned long getNextHandle() const
void comment(const char *text) const
void entity(const char *entTypeName) const
void sectionBlockEntry(unsigned long int h=0) const
unsigned long incHandle() const
void sectionBlockEntryEnd(unsigned long int h=0) const
void tableLayerEntry(unsigned long int h=0) const
unsigned long handle(int gc=5) const
virtual void dxfBool(int gc, bool value) const
void tableAppidEntry(unsigned long int h=0) const
void sectionHeader() const
void coord(int gc, double x, double y, double z=0) const
void entityAttributes(const DL_Attributes &attrib) const
#define DL_POINT_COORD_CODE
#define DL_LINE_START_CODE
#define DL_DXF_MAXGROUPCODE
#define DL_VERTEX_COORD_CODE
#define DL_ENTITY_ELLIPSE
#define DL_ENTITY_ARCALIGNEDTEXT
#define DL_ENTITY_DIMENSION
#define DL_ENTITY_POLYLINE
#define DL_ENTITY_IMAGEDEF
#define DL_ENTITY_LWPOLYLINE
bool reversedCharacterOrder
std::vector< double > knots
std::vector< std::vector< double > > controlPoints
std::vector< std::vector< double > > vertices
std::vector< double > weights
std::vector< std::vector< double > > fitPoints
std::string primaryFontFile