本文整理汇总了C++中DL_Dxf::writeVPort方法的典型用法代码示例。如果您正苦于以下问题:C++ DL_Dxf::writeVPort方法的具体用法?C++ DL_Dxf::writeVPort怎么用?C++ DL_Dxf::writeVPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DL_Dxf
的用法示例。
在下文中一共展示了DL_Dxf::writeVPort方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveVerticalProfiles
bool DxfProfilesExporter::SaveVerticalProfiles( const QSharedPointer<DistanceMapGenerationTool::Map>& map,
ccPolyline* profile,
QString filename,
unsigned angularStepCount,
double heightStep,
const Parameters& params,
ccMainAppInterface* app/*=0*/)
{
#ifdef CC_DXF_SUPPORT
assert(c_pageMargin_mm < c_profileMargin_mm);
assert(2.0*c_profileMargin_mm < std::min(c_pageWidth_mm,c_pageHeight_mm));
if (!map || !profile || angularStepCount == 0 || heightStep <= 0)
{
//invalid parameters
return false;
}
//Theoretical profile bounding box
PointCoordinateType profileBBMin[3],profileBBMax[3];
profile->getAssociatedCloud()->getBoundingBox(profileBBMin,profileBBMax);
//Mix with the map's boundaries along 'Y'
double yMin = std::max(map->yMin,static_cast<double>(profileBBMin[1]));
double yMax = std::min(map->yMin + static_cast<double>(map->ySteps) * map->yStep, static_cast<double>(profileBBMax[1]));
const double ySpan = yMax - yMin;
//For the 'X' dimension, it's easier to stick with the th. profile
const double xMin = profileBBMin[0];
// const double xMax = profileBBMax[0];
const double xSpan = profileBBMax[0] - profileBBMin[0];
if (xSpan == 0.0 || ySpan == 0.0)
{
if (app)
app->dispToConsole(QString("Internal error: null profile?!"),ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return false;
}
DL_Dxf dxf;
DL_WriterA* dw = dxf.out(qPrintable(filename), DL_VERSION_R12);
if (!dw)
{
if (app)
app->dispToConsole(QString("Failed to open '%1' file for writing!").arg(filename),ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return false;
}
//write header
dxf.writeHeader(*dw);
//add dimensions
dw->dxfString(9, "$INSBASE");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$EXTMIN");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$EXTMAX");
dw->dxfReal(10,c_pageWidth_mm);
dw->dxfReal(20,c_pageHeight_mm);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$LIMMIN");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfString(9, "$LIMMAX");
dw->dxfReal(10,c_pageWidth_mm);
dw->dxfReal(20,c_pageHeight_mm);
//close header
dw->sectionEnd();
//Opening the Tables Section
dw->sectionTables();
//Writing the Viewports
dxf.writeVPort(*dw);
//Writing the Linetypes (all by default)
{
dw->tableLineTypes(25);
dxf.writeLineType(*dw, DL_LineTypeData("BYBLOCK", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BYLAYER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CONTINUOUS", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO02W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO03W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO04W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO05W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDER2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDERX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTER2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTERX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHDOT", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHDOT2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHDOTX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHED", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHED2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHEDX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DIVIDE", 0));
//.........这里部分代码省略.........
示例2: SaveHorizontalProfiles
bool DxfProfilesExporter::SaveHorizontalProfiles( const QSharedPointer<DistanceMapGenerationTool::Map>& map,
ccPolyline* profile,
QString filename,
unsigned heightStepCount,
double angularStep_rad,
double radToUnitConvFactor,
QString angleUnit,
const Parameters& params,
ccMainAppInterface* app/*= 0*/)
{
#ifdef CC_DXF_SUPPORT
assert(c_pageMargin_mm < c_profileMargin_mm);
assert(2.0*c_profileMargin_mm < std::min(c_pageWidth_mm,c_pageHeight_mm));
if (!map || !profile || heightStepCount == 0 || angularStep_rad <= 0)
{
//invalid parameters
return false;
}
//Theoretical profile bounding box
PointCoordinateType profileBBMin[3],profileBBMax[3];
profile->getAssociatedCloud()->getBoundingBox(profileBBMin,profileBBMax);
//Mix with the map's boundaries along 'Y'
double yMin = std::max( map->yMin + 0.5 * map->xStep, //central height of first row
static_cast<double>(profileBBMin[1]));
double yMax = std::min( map->yMin + (static_cast<double>(map->ySteps)-0.5) * map->yStep, //central height of last row
static_cast<double>(profileBBMax[1]));
const double ySpan = yMax - yMin;
//For the 'X' dimension, it's easier to stick with the th. profile
// const double xMin = profileBBMin[0];
const double xMax = profileBBMax[0];
const double xSpan = profileBBMax[0] - profileBBMin[0];
//shortcut for clarity
const double& maxRadius = xMax;
if (xSpan == 0.0 || ySpan == 0.0)
{
if (app)
app->dispToConsole(QString("Internal error: null profile?!"),ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return false;
}
DL_Dxf dxf;
DL_WriterA* dw = dxf.out(qPrintable(filename), DL_VERSION_R12);
if (!dw)
{
if (app)
app->dispToConsole(QString("Failed to open '%1' file for writing!").arg(filename),ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return false;
}
//write header
dxf.writeHeader(*dw);
//add dimensions
dw->dxfString(9, "$INSBASE");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$EXTMIN");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$EXTMAX");
dw->dxfReal(10,c_pageWidth_mm);
dw->dxfReal(20,c_pageHeight_mm);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$LIMMIN");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfString(9, "$LIMMAX");
dw->dxfReal(10,c_pageWidth_mm);
dw->dxfReal(20,c_pageHeight_mm);
//close header
dw->sectionEnd();
//Opening the Tables Section
dw->sectionTables();
//Writing the Viewports
dxf.writeVPort(*dw);
//Writing the Linetypes (all by default)
{
dw->tableLineTypes(25);
dxf.writeLineType(*dw, DL_LineTypeData("BYBLOCK", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BYLAYER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CONTINUOUS", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO02W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO03W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO04W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO05W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDER2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDERX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTER2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTERX2", 0));
//.........这里部分代码省略.........
示例3: main
int main() {
DL_Dxf dxf;
DL_WriterA* dw = dxf.out("dimension.dxf", DL_Codes::AC1015);
// section header:
dxf.writeHeader(*dw);
dw->sectionEnd();
// section tables:
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("", 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);
//.........这里部分代码省略.........
示例4: saveToFile
CC_FILE_ERROR DxfFilter::saveToFile(ccHObject* root, const char* filename)
{
#ifndef CC_DXF_SUPPORT
ccLog::Error("[DXF] DXF format not supported! Check compilation parameters!");
return CC_FERR_CONSOLE_ERROR;
#else
if (!root || !filename)
return CC_FERR_BAD_ARGUMENT;
ccHObject::Container polylines;
root->filterChildren(polylines,true,CC_POLY_LINE);
//only polylines are handled for now
size_t polyCount = polylines.size();
if (!polyCount)
return CC_FERR_NO_SAVE;
//get global bounding box
ccBBox box;
for (size_t i=0; i<polyCount; ++i)
{
ccBBox polyBox = polylines[i]->getBB();
if (i)
{
box += polyBox;
}
else
{
box = polyBox;
}
}
CCVector3 diag = box.getDiagVec();
double baseSize = static_cast<double>(std::max(diag.x,diag.y));
double lineWidth = baseSize / 40.0;
double pageMargin = baseSize / 20.0;
DL_Dxf dxf;
DL_WriterA* dw = dxf.out(qPrintable(filename), DL_VERSION_R12);
if (!dw)
{
return CC_FERR_WRITING;
}
//write header
dxf.writeHeader(*dw);
//add dimensions
dw->dxfString(9, "$INSBASE");
dw->dxfReal(10,0.0);
dw->dxfReal(20,0.0);
dw->dxfReal(30,0.0);
dw->dxfString(9, "$EXTMIN");
dw->dxfReal(10,static_cast<double>(box.minCorner().x)-pageMargin);
dw->dxfReal(20,static_cast<double>(box.minCorner().y)-pageMargin);
dw->dxfReal(30,static_cast<double>(box.minCorner().z)-pageMargin);
dw->dxfString(9, "$EXTMAX");
dw->dxfReal(10,static_cast<double>(box.maxCorner().x)+pageMargin);
dw->dxfReal(20,static_cast<double>(box.maxCorner().y)+pageMargin);
dw->dxfReal(30,static_cast<double>(box.maxCorner().z)+pageMargin);
dw->dxfString(9, "$LIMMIN");
dw->dxfReal(10,static_cast<double>(box.minCorner().x)-pageMargin);
dw->dxfReal(20,static_cast<double>(box.minCorner().y)-pageMargin);
dw->dxfString(9, "$LIMMAX");
dw->dxfReal(10,static_cast<double>(box.maxCorner().x)+pageMargin);
dw->dxfReal(20,static_cast<double>(box.maxCorner().y)+pageMargin);
//close header
dw->sectionEnd();
//Opening the Tables Section
dw->sectionTables();
//Writing the Viewports
dxf.writeVPort(*dw);
//Writing the Linetypes (all by default)
{
dw->tableLineTypes(25);
dxf.writeLineType(*dw, DL_LineTypeData("BYBLOCK", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BYLAYER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CONTINUOUS", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO02W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO03W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO04W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("ACAD_ISO05W100", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDER2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("BORDERX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTER", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTER2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("CENTERX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHDOT", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHDOT2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHDOTX2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHED", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHED2", 0));
dxf.writeLineType(*dw, DL_LineTypeData("DASHEDX2", 0));
//.........这里部分代码省略.........
示例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
int main() {
DL_Dxf dxf;
DL_WriterA* dw = dxf.out("hatch.dxf", DL_Codes::AC1015);
// section header:
dxf.writeHeader(*dw);
dw->sectionEnd();
// section tables:
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();
//.........这里部分代码省略.........