本文整理汇总了C++中DL_Dxf::writeObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ DL_Dxf::writeObjects方法的具体用法?C++ DL_Dxf::writeObjects怎么用?C++ DL_Dxf::writeObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DL_Dxf
的用法示例。
在下文中一共展示了DL_Dxf::writeObjects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveVerticalProfiles
//.........这里部分代码省略.........
const VertStepData& step = polySteps[i];
dxf.writeVertex(*dw, DL_VertexData( x0 + (step.radius_th + step.deviation * params.devMagnifyCoef - xMin) * scale,
y0 + (step.height - yMin) * scale, 0.0));
}
dxf.writePolylineEnd(*dw);
}
//write corresponding 'deviation bars' and labels
CCVector3d pageShift(x0 - xMin * scale, y0 - yMin * scale, 0.0);
{
size_t lastStep = 0;
for (size_t i=0; i<polySteps.size(); ++i)
{
const VertStepData& step = polySteps[i];
bool displayIt = (i == 0 || i+1 == polySteps.size());
if (!displayIt)
{
double dh = polySteps[i].height - polySteps[lastStep].height;
double next_dh = polySteps[i+1].height - polySteps[lastStep].height;
if (dh >= heightStep || (next_dh > heightStep && fabs(dh - heightStep) < fabs(next_dh - heightStep)))
{
displayIt = true;
}
}
if (displayIt)
{
CCVector3d Pheight(step.radius_th,step.height,0.0);
CCVector3d Pdev(step.radius_th + step.deviation * params.devMagnifyCoef,step.height,0.0);
//page scaling
Pheight = pageShift + Pheight * scale;
Pdev = pageShift + Pdev * scale;
//deviation bar
dxf.writeLine(*dw,
DL_LineData(Pheight.x,Pheight.y,Pheight.z,Pdev.x,Pdev.y,Pdev.z),
GrayMaterial);
//labels
//Horizontal justification: 0 = Left , 1 = Center, 2 = Right
int hJustification = 0;
//Vertical justification: 0 = Baseline, 1 = Bottom, 2 = Middle, 3 = Top
int vJustification = 2;
if (step.deviation < 0.0)
{
//deviation label on the left
Pdev.x -= 2.0*c_textMargin_mm;
//opposite for the height label
Pheight.x += c_textMargin_mm;
hJustification = 2; //Right
}
else
{
//deviation label on the right
Pdev.x += 2.0*c_textMargin_mm;
//opposite for the height label
Pheight.x -= c_textMargin_mm;
hJustification = 0; //Left
}
QString devText = QString::number(polySteps[i].deviation * params.devLabelMultCoef,'f',params.precision);
dxf.writeText( *dw,
DL_TextData(Pdev.x,Pdev.y,Pdev.z,Pdev.x,Pdev.y,Pdev.z,c_textHeight_mm,1.0,0,hJustification,vJustification,devText.toStdString(),"STANDARD",0.0),
DefaultMaterial);
QString heightText = QString::number(polySteps[i].height,'f',params.precision);
dxf.writeText( *dw,
DL_TextData(Pheight.x,Pheight.y,Pheight.z,Pheight.x,Pheight.y,Pheight.z,c_textHeight_mm,1.0,0,2-hJustification,vJustification,heightText.toStdString(),"STANDARD",0.0),
GrayMaterial);
lastStep = i;
}
}
}
}
dw->sectionEnd();
}
//Writing the Objects Section
dxf.writeObjects(*dw);
dxf.writeObjectsEnd(*dw);
//Ending and Closing the File
dw->dxfEOF();
dw->close();
delete dw;
dw = 0;
return true;
#else
return false;
#endif
}
示例2: SaveHorizontalProfiles
//.........这里部分代码省略.........
CCVector3d relativePos( -cwSign * sin(step.angle_rad),
-cos(step.angle_rad),
0.0);
CCVector3d Pangle = relativePos * currentRadius;
CCVector3d Pdev = relativePos * (currentRadius + step.deviation * params.devMagnifyCoef);
//page scaling
Pangle = pageShift + Pangle * scale;
Pdev = pageShift + Pdev * scale;
//deviation bar
dxf.writeLine(*dw,
DL_LineData(Pangle.x,Pangle.y,Pangle.z,Pdev.x,Pdev.y,Pdev.z),
GrayMaterial);
//labels
//justification depends on the current angle
const double c_angleMargin_rad = 5.0 / 180.0 * M_PI; //margin: 5 degrees
const double c_margin = sin(c_angleMargin_rad);
//Horizontal justification: 0 = Left , 1 = Center, 2 = Right
int hJustification = 1;
if (relativePos.x < -c_margin) //point on the left
hJustification = 2; //Right
else if (relativePos.x > c_margin) //point on the right
hJustification = 0; //Left
//Vertical justification: 0 = Baseline, 1 = Bottom, 2 = Middle, 3 = Top
int vJustification = 2;
if (relativePos.y < -c_margin) //point in the lower part
vJustification = 3; //Top
else if (relativePos.y > c_margin) //point in the upper part
vJustification = 1; //Bottom
int hJustificationDev = hJustification;
int hJustificationAng = hJustification;
int vJustificationDev = vJustification;
int vJustificationAng = vJustification;
//negative deviation: profile is inside the circle
// - deviation is displayed insde
// - angle is displayed outside
if (step.deviation < 0.0)
{
Pdev -= relativePos * 2.0*c_textMargin_mm;
Pangle += relativePos * c_textMargin_mm;
//invert dev. text justification
if (hJustificationDev != 1)
hJustificationDev = 2-hJustificationDev; // 0 <-> 2
if (vJustificationDev != 2)
vJustificationDev = 4-vJustificationDev; // 1 <-> 3
}
else
{
Pdev += relativePos * 2.0*c_textMargin_mm;
Pangle -= relativePos * c_textMargin_mm;
//invert ang. text justification
if (hJustificationAng != 1)
hJustificationAng = 2-hJustificationAng; // 0 <-> 2
if (vJustificationAng != 2)
vJustificationAng = 4-vJustificationAng; // 1 <-> 3
}
QString devText = QString::number(polySteps[i].deviation * params.devLabelMultCoef,'f',params.precision);
dxf.writeText( *dw,
DL_TextData(Pdev.x,Pdev.y,Pdev.z,Pdev.x,Pdev.y,Pdev.z,c_textHeight_mm,1.0,0,hJustificationDev,vJustificationDev,devText.toStdString(),"STANDARD",0.0),
DefaultMaterial);
QString angleText = QString::number(polySteps[i].angle_rad *radToUnitConvFactor,'f',params.precision)+angleUnit;
dxf.writeText( *dw,
DL_TextData(Pangle.x,Pangle.y,Pangle.z,Pangle.x,Pangle.y,Pangle.z,c_textHeight_mm,1.0,0,hJustificationAng,vJustificationAng,angleText.toStdString(),"STANDARD",0.0),
GrayMaterial);
lastStep = i;
}
}
}
}
dw->sectionEnd();
}
//Writing the Objects Section
dxf.writeObjects(*dw);
dxf.writeObjectsEnd(*dw);
//Ending and Closing the File
dw->dxfEOF();
dw->close();
delete dw;
dw = 0;
return true;
#else
return false;
#endif
}
示例3: main
//.........这里部分代码省略.........
// LTYPE:
dw->tableLinetypes(1);
dxf.writeLinetype(*dw, DL_LinetypeData("CONTINUOUS", "Continuous", 0, 0, 0.0));
dxf.writeLinetype(*dw, DL_LinetypeData("BYLAYER", "", 0, 0, 0.0));
dxf.writeLinetype(*dw, DL_LinetypeData("BYBLOCK", "", 0, 0, 0.0));
dw->tableEnd();
// LAYER:
dw->tableLayers(1);
dxf.writeLayer(
*dw,
DL_LayerData("0", 0),
DL_Attributes("", 1, 0x00ff0000, 15, "CONTINUOUS")
);
dw->tableEnd();
// STYLE:
dw->tableStyle(1);
DL_StyleData style("Standard", 0, 0.0, 1.0, 0.0, 0, 2.5, "txt", "");
style.bold = false;
style.italic = false;
dxf.writeStyle(*dw, style);
dw->tableEnd();
// VIEW:
dxf.writeView(*dw);
// UCS:
dxf.writeUcs(*dw);
// APPID:
dw->tableAppid(1);
dxf.writeAppid(*dw, "ACAD");
dw->tableEnd();
// DIMSTYLE:
dxf.writeDimStyle(*dw, 2.5, 0.625, 0.625, 0.625, 2.5);
// BLOCK_RECORD:
dxf.writeBlockRecord(*dw);
dw->tableEnd();
dw->sectionEnd();
// BLOCK:
dw->sectionBlocks();
dxf.writeBlock(*dw, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Model_Space");
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Paper_Space");
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Paper_Space0");
dw->sectionEnd();
// ENTITIES:
dw->sectionEntities();
DL_Attributes attributes("0", 256, -1, -1, "BYLAYER");
// LINE:
DL_LineData lineData(10, 5, 0, 30, 5, 0);
dxf.writeLine(*dw, lineData, attributes);
// DIMENSION:
DL_DimensionData dimData(10.0, // def point (dimension line pos)
50.0,
0.0,
0, // text pos (irrelevant if flag 0x80 (128) set for type
0,
0.0,
0x1, // type: aligned with auto text pos (0x80 NOT set)
8, // attachment point: bottom center
2, // line spacing: exact
1.0, // line spacing factor
"", // text
"Standard", // style
0.0, // text angle
1.0, // linear factor
1.0); // dim scale
DL_DimAlignedData dimAlignedData(10.0, // extension point 1
5.0,
0.0,
30.0, // extension point 2
5.0,
0.0);
dxf.writeDimAligned(*dw, dimData, dimAlignedData, attributes);
// end section ENTITIES:
dw->sectionEnd();
dxf.writeObjects(*dw, "MY_OBJECTS");
dxf.writeObjectsEnd(*dw);
dw->dxfEOF();
dw->close();
delete dw;
return 0;
}
示例4: saveToFile
//.........这里部分代码省略.........
layerNames << layerName;
dxf.writeLayer(*dw,
DL_LayerData(layerName.toStdString(), 0),
DL_Attributes(
std::string(""),
i == 0 ? DL_Codes::green : /*-*/DL_Codes::green, //invisible if negative!
lineWidth,
"CONTINUOUS"));
}
}
dw->tableEnd();
//Writing Various Other Tables
dxf.writeStyle(*dw);
dxf.writeView(*dw);
dxf.writeUcs(*dw);
dw->tableAppid(1);
dw->tableAppidEntry(0x12);
dw->dxfString(2, "ACAD");
dw->dxfInt(70, 0);
dw->tableEnd();
//Writing Dimension Styles
dxf.writeDimStyle( *dw,
/*arrowSize*/1,
/*extensionLineExtension*/1,
/*extensionLineOffset*/1,
/*dimensionGap*/1,
/*dimensionTextSize*/1);
//Writing Block Records
dxf.writeBlockRecord(*dw);
dw->tableEnd();
//Ending the Tables Section
dw->sectionEnd();
//Writing the Blocks Section
{
dw->sectionBlocks();
dxf.writeBlock(*dw, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Model_Space");
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Paper_Space");
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Paper_Space0");
dw->sectionEnd();
}
//Writing the Entities Section
{
dw->sectionEntities();
//write polylines
for (unsigned i=0; i<polyCount; ++i)
{
const ccPolyline* poly = static_cast<ccPolyline*>(polylines[i]);
unsigned vertexCount = poly->size();
int flags = poly->isClosed() ? 1 : 0;
if (!poly->is2DMode())
flags |= 8; //3D polyline
dxf.writePolyline( *dw,
DL_PolylineData(static_cast<int>(vertexCount),0,0,flags),
DL_Attributes(layerNames[i].toStdString(), DL_Codes::bylayer, -1, "BYLAYER") );
for (unsigned i=0; i<vertexCount; ++i)
{
CCVector3 P;
poly->getPoint(i,P);
dxf.writeVertex(*dw, DL_VertexData( P.x, P.y, P.y ) );
}
dxf.writePolylineEnd(*dw);
}
dw->sectionEnd();
}
//Writing the Objects Section
dxf.writeObjects(*dw);
dxf.writeObjectsEnd(*dw);
//Ending and Closing the File
dw->dxfEOF();
dw->close();
delete dw;
dw = 0;
ccLog::Print("[DXF] File %s saved successfully",filename);
return CC_FERR_NO_ERROR;
#endif
}
示例5: main
int main(int argc, char **argv)
{
if (argc < 5) {
std::cerr << "Usage: dxf-import <main input file> <overlay input file> <overlay layer name prefix> <output file>\n";
return 1;
}
std::string mainInput = argv[1];
std::string overlayInput = argv[2];
std::string layerPrefix = argv[3];
LayerCounter mainLayerCounter(layerPrefix, false);
mainLayerCounter.input(mainInput);
LayerCounter overlayLayerCounter(layerPrefix, true);
overlayLayerCounter.input(overlayInput);
DL_Dxf output;
DL_WriterA *writer = output.out(argv[4]);
if (!writer) {
std::cerr << "Unable to open output file '" << argv[4] << "'\n";
return 1;
}
output.writeHeader(*writer);
VariableWriter(&output, writer).input(mainInput);
writer->sectionEnd();
writer->sectionTables();
output.writeVPort(*writer);
writeLineTypes(output, writer);
writer->tableLayers(mainLayerCounter.layers() + overlayLayerCounter.layers());
LayerWriter(layerPrefix, false, &output, writer).input(mainInput);
LayerWriter(layerPrefix, true, &output, writer).input(overlayInput);
writer->tableEnd();
output.writeStyle(*writer);
output.writeView(*writer);
output.writeUcs(*writer);
writer->tableAppid(1);
writer->tableAppidEntry(0x12);
writer->dxfString(2, "ACAD");
writer->dxfInt(70, 0);
writer->tableEnd();
output.writeDimStyle(*writer, 3.0, 3.0, 1.5, 2.0, 3.0);
output.writeBlockRecord(*writer);
BlockRecordWriter(layerPrefix, false, &output, writer).input(mainInput);
BlockRecordWriter(layerPrefix, true, &output, writer).input(overlayInput);
writer->tableEnd();
writer->sectionEnd();
std::map<std::string, ImageHandle> images;
writer->sectionBlocks();
output.writeBlock(*writer, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0));
output.writeEndBlock(*writer, "*Model_Space");
output.writeBlock(*writer, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0));
output.writeEndBlock(*writer, "*Paper_Space");
output.writeBlock(*writer, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0));
output.writeEndBlock(*writer, "*Paper_Space0");
EntityWriter(layerPrefix, false, &output, writer, true, &images).input(mainInput);
EntityWriter(layerPrefix, true, &output, writer, true, &images).input(overlayInput);
writer->sectionEnd();
writer->sectionEntities();
EntityWriter(layerPrefix, false, &output, writer, false, &images).input(mainInput);
EntityWriter(layerPrefix, true, &output, writer, false, &images).input(overlayInput);
writer->sectionEnd();
output.writeObjects(*writer);
ObjectWriter(&output, writer, &images).input(mainInput);
ObjectWriter(&output, writer, &images).input(overlayInput);
output.writeObjectsEnd(*writer);
writer->dxfEOF();
writer->close();
delete writer;
return 0;
}
示例6: main
//.........这里部分代码省略.........
dw->sectionTables();
// VPORT:
dxf.writeVPort(*dw);
// LTYPE:
dw->tableLinetypes(1);
dxf.writeLinetype(*dw, DL_LinetypeData("CONTINUOUS", "Continuous", 0, 0, 0.0));
dxf.writeLinetype(*dw, DL_LinetypeData("BYLAYER", "", 0, 0, 0.0));
dxf.writeLinetype(*dw, DL_LinetypeData("BYBLOCK", "", 0, 0, 0.0));
dw->tableEnd();
// LAYER:
dw->tableLayers(1);
dxf.writeLayer(
*dw,
DL_LayerData("0", 0),
DL_Attributes("", 2, 0, 100, "CONTINUOUS")
);
dw->tableEnd();
// STYLE:
dw->tableStyle(1);
DL_StyleData style("Standard", 0, 0.0, 1.0, 0.0, 0, 2.5, "txt", "");
style.bold = false;
style.italic = false;
dxf.writeStyle(*dw, style);
dw->tableEnd();
// VIEW:
dxf.writeView(*dw);
// UCS:
dxf.writeUcs(*dw);
// APPID:
dw->tableAppid(1);
dxf.writeAppid(*dw, "ACAD");
dw->tableEnd();
// DIMSTYLE:
dxf.writeDimStyle(*dw, 2.5, 0.625, 0.625, 0.625, 2.5);
// BLOCK_RECORD:
dxf.writeBlockRecord(*dw);
dw->tableEnd();
dw->sectionEnd();
// BLOCK:
dw->sectionBlocks();
dxf.writeBlock(*dw, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Model_Space");
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Paper_Space");
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0));
dxf.writeEndBlock(*dw, "*Paper_Space0");
dw->sectionEnd();
// ENTITIES:
dw->sectionEntities();
DL_Attributes attributes("0", 2, 0, -1, "BYLAYER");
// start hatch with one loop:
DL_HatchData data(1, false, 100.0, 0.0, "ESCHER", 0.0, 0.0);
dxf.writeHatch1(*dw, data, attributes);
// start loop:
DL_HatchLoopData lData(1);
dxf.writeHatchLoop1(*dw, lData);
// write edge:
DL_HatchEdgeData eData(
0.0,
0.0,
100.0,
0.0,
M_PI*2,
true
);
dxf.writeHatchEdge(*dw, eData);
// end loop:
dxf.writeHatchLoop2(*dw, lData);
// end hatch:
dxf.writeHatch2(*dw, data, attributes);
// end section ENTITIES:
dw->sectionEnd();
dxf.writeObjects(*dw, "MY_OBJECTS");
dxf.writeObjectsEnd(*dw);
dw->dxfEOF();
dw->close();
delete dw;
return 0;
}