50 const QSharedPointer<DistanceMapGenerationTool::Map>& map,
53 unsigned angularStepCount,
63 if (!map || !
profile || angularStepCount == 0 || heightStep <= 0) {
70 profile->getAssociatedCloud()->getBoundingBox(profileBBMin, profileBBMax);
72 double yMin = std::max(map->yMin,
73 static_cast<double>(profileBBMin.
y) + heightShift);
74 double yMax = std::min(map->yMin + map->ySteps * map->yStep,
75 static_cast<double>(profileBBMax.
y) + heightShift);
76 const double ySpan = yMax - yMin;
78 const double xMin = profileBBMin.
x;
80 const double xSpan = profileBBMax.
x - profileBBMin.
x;
82 if (xSpan == 0.0 && ySpan == 0.0) {
93 app->
dispToConsole(QString(
"Failed to open '%1' file for writing!")
144 QStringList profileNames;
166 for (
unsigned i = 0; i < angularStepCount; ++i) {
179 profileNames << layerName;
252 }
else if (ySpan == 0) {
267 unsigned vertexCount =
profile->size();
274 for (
unsigned i = 0; i < vertexCount; ++i) {
277 y0 + (P->
y + heightShift -
293 DefaultLegendMaterial);
314 const double legendWidth_mm = 20.0;
320 DL_TextData(xLegend, yLegend, 0.0, xLegend, yLegend, 0.0,
322 qPrintable(QString(
"Deviation magnification "
328 DefaultLegendMaterial);
335 DL_TextData(xLegend, yLegend, 0.0, xLegend, yLegend,
337 qPrintable(QString(
"Deviation units: ") +
340 DefaultLegendMaterial);
348 xLegend + legendWidth_mm, yLegend, 0.0),
362 DefaultLegendMaterial);
370 xLegend + legendWidth_mm, yLegend, 0.0),
384 DefaultLegendMaterial);
388 for (
unsigned angleStep = 0; angleStep < angularStepCount;
390 std::vector<VertStepData> polySteps;
392 polySteps.reserve(map->ySteps);
393 }
catch (
const std::bad_alloc&) {
401 unsigned iMap =
static_cast<unsigned>(
402 static_cast<double>(angleStep * map->xSteps) /
403 static_cast<double>(angularStepCount));
404 for (
unsigned jMap = 0; jMap < map->ySteps; ++jMap) {
406 map->at(iMap + jMap * map->xSteps);
410 map->yMin +
static_cast<double>(jMap) * map->yStep;
415 for (
unsigned i = 1; i <
profile->size(); ++i) {
419 double alpha =
static_cast<double>(
420 (step.
height - A->
y - heightShift) /
422 if (alpha >= 0.0 && alpha <= 1.0) {
433 polySteps.push_back(step);
447 if (
static_cast<int>(angleStep) < params.
profileTitles.size()) {
458 qPrintable(title),
"STANDARD",
472 for (
size_t i = 0; i < polySteps.size(); ++i) {
480 y0 + (step.
height - yMin) * scale,
488 CCVector3d pageShift(x0 - xMin * scale, y0 - yMin * scale, 0.0);
491 for (
size_t i = 0; i < polySteps.size(); ++i) {
493 bool displayIt = (i == 0 || i + 1 == polySteps.size());
495 double dh = polySteps[i].
height -
496 polySteps[lastStep].height;
497 double next_dh = polySteps[i + 1].height -
498 polySteps[lastStep].height;
499 if (dh >= heightStep ||
500 (next_dh > heightStep &&
501 fabs(dh - heightStep) <
502 fabs(next_dh - heightStep))) {
515 Pheight = pageShift + Pheight * scale;
516 Pdev = pageShift + Pdev * scale;
522 Pdev.
x, Pdev.
y, Pdev.
z),
529 int hJustification = 0;
532 int vJustification = 2;
549 QString::number(polySteps[i].deviation *
556 1.0, 0, hJustification,
557 vJustification, qPrintable(devText),
564 QString heightText = QString::number(
569 Pheight.
x, Pheight.
y, Pheight.
z,
571 2 - hJustification, vJustification,
572 qPrintable(heightText),
"STANDARD",
608 const QSharedPointer<DistanceMapGenerationTool::Map>& map,
611 unsigned heightStepCount,
613 double angularStep_rad,
614 double radToUnitConvFactor,
618 #ifdef CV_DXF_SUPPORT
623 if (!map || !
profile || heightStepCount == 0 || angularStep_rad <= 0) {
630 profile->getAssociatedCloud()->getBoundingBox(profileBBMin, profileBBMax);
632 double yMin = std::max(
633 map->yMin + 0.5 * map->xStep,
634 static_cast<double>(profileBBMin.
y) + heightShift);
635 double yMax = std::min(
636 map->yMin + (
static_cast<double>(map->ySteps) - 0.5) *
638 static_cast<double>(profileBBMax.
y) + heightShift);
639 const double ySpan = yMax - yMin;
643 const double xMax = profileBBMax.
x;
645 const double& maxRadius = xMax;
649 app->
dispToConsole(QString(
"Internal error: null profile?!"),
658 app->
dispToConsole(QString(
"Failed to open '%1' file for writing!")
709 QStringList profileNames;
726 for (
unsigned i = 0; i < heightStepCount; ++i) {
741 profileNames << layerName;
808 double scale = std::min(
828 DefaultLegendMaterial);
849 const double legendWidth_mm = 20.0;
852 double axisTip = maxRadius * scale + 5.0;
854 DefaultLegendMaterial);
858 double axisTipSize = 3.0;
862 DefaultLegendMaterial);
874 DL_TextData(xc, yc - (axisTip + 2.0 * axisTipSize), 0.0,
875 xc, yc - (axisTip + 2.0 * axisTipSize), 0.0,
878 DefaultLegendMaterial);
885 DL_TextData(xLegend, yLegend, 0.0, xLegend, yLegend, 0.0,
887 qPrintable(QString(
"Deviation magnification "
893 DefaultLegendMaterial);
901 DL_TextData(xLegend, yLegend, 0.0, xLegend, yLegend, 0.0,
903 qPrintable(QString(
"Deviation units: ") +
908 DefaultLegendMaterial);
916 xLegend + legendWidth_mm, yLegend, 0.0),
928 DefaultLegendMaterial);
936 xLegend + legendWidth_mm, yLegend, 0.0),
948 DefaultLegendMaterial);
952 std::vector<HorizStepData> polySteps;
954 polySteps.resize(map->xSteps);
955 }
catch (
const std::bad_alloc&) {
964 for (
unsigned heightStep = 0; heightStep < heightStepCount;
968 yMin +
static_cast<double>(heightStep) /
969 static_cast<double>(heightStepCount - 1) *
973 if (height < map->yMin ||
974 height >= map->yMin +
static_cast<double>(map->ySteps) *
982 static_cast<unsigned>((
height - map->yMin) / map->yStep);
983 assert(jMap < map->ySteps);
986 double currentRadius = 0.0;
989 for (
unsigned i = 1; i <
profile->size(); ++i) {
993 double alpha =
static_cast<double>(
994 (
height - A->
y - heightShift) / (B->
y - A->
y));
995 if (alpha >= 0.0 && alpha <= 1.0) {
997 currentRadius = A->
x + alpha * (B->
x - A->
x);
1011 const QString& currentLayer = profileNames[heightStep];
1033 qPrintable(title),
"STANDARD",
1044 -1,
"BYLAYER", 1.0));
1047 assert(polySteps.size() == map->xSteps);
1050 &map->at(jMap * map->xSteps);
1051 for (
unsigned iMap = 0; iMap < map->xSteps; ++iMap, ++cell) {
1054 static_cast<double>(map->xSteps);
1056 polySteps[iMap] = step;
1061 double cwSign = map->counterclockwise ? -1.0 : 1.0;
1073 for (
size_t i = 0; i < polySteps.size(); ++i) {
1075 double radius = currentRadius +
1082 pageShift.
y - (radius *
1093 size_t lastStep = 0;
1094 for (
size_t i = 0; i < polySteps.size(); ++i) {
1101 double dAngle = polySteps[i].
angle_rad -
1102 polySteps[lastStep].angle_rad;
1103 double next_dAngle =
1104 (i + 1 == polySteps.size()
1105 ? polySteps[0].angle_rad + 2.0 *
M_PI
1106 : polySteps[i + 1].angle_rad) -
1107 polySteps[lastStep].angle_rad;
1108 if (dAngle >= angularStep_rad ||
1109 (next_dAngle > angularStep_rad &&
1110 fabs(dAngle - angularStep_rad) <
1111 fabs(next_dAngle - angularStep_rad))) {
1116 if (displayIt && i != 0)
1121 CCVector3d Pangle = relativePos * currentRadius;
1128 Pangle = pageShift + Pangle * scale;
1129 Pdev = pageShift + Pdev * scale;
1134 Pdev.
x, Pdev.
y, Pdev.
z),
1140 const double c_angleMargin_rad =
1142 const double c_margin = sin(c_angleMargin_rad);
1146 int hJustification = 1;
1155 int vJustification = 2;
1159 else if (relativePos.
y >
1163 int hJustificationDev = hJustification;
1164 int hJustificationAng = hJustification;
1165 int vJustificationDev = vJustification;
1166 int vJustificationAng = vJustification;
1175 if (hJustificationDev != 1)
1177 2 - hJustificationDev;
1178 if (vJustificationDev != 2)
1180 4 - vJustificationDev;
1185 if (hJustificationAng != 1)
1187 2 - hJustificationAng;
1188 if (vJustificationAng != 2)
1190 4 - vJustificationAng;
1194 QString::number(polySteps[i].deviation *
1200 Pdev.
x, Pdev.
y, Pdev.
z, Pdev.
x, Pdev.
y,
1202 hJustificationDev, vJustificationDev,
1203 qPrintable(devText),
"STANDARD", 0.0),
1207 QString::number(polySteps[i].angle_rad *
1208 radToUnitConvFactor,
1213 Pangle.
x, Pangle.
y, Pangle.
z,
1217 qPrintable(angleText),
CloudViewerScene::LightingProfile profile
void writeView(DL_WriterA &dw)
void writeObjects(DL_WriterA &dw, const std::string &appDictionaryName="")
void writeStyle(DL_WriterA &dw, const DL_StyleData &style)
void writeObjectsEnd(DL_WriterA &dw)
void writePolyline(DL_WriterA &dw, const DL_PolylineData &data, const DL_Attributes &attrib)
void writeDimStyle(DL_WriterA &dw, double dimasz, double dimexe, double dimexo, double dimgap, double dimtxt)
void writeVPort(DL_WriterA &dw)
void writeCircle(DL_WriterA &dw, const DL_CircleData &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 writeText(DL_WriterA &dw, const DL_TextData &data, const DL_Attributes &attrib)
void writeEndBlock(DL_WriterA &dw, const std::string &name)
void writeVertex(DL_WriterA &dw, const DL_VertexData &data)
void writeLayer(DL_WriterA &dw, const DL_LayerData &data, const DL_Attributes &attrib)
void writeBlock(DL_WriterA &dw, const DL_BlockData &data)
void writeUcs(DL_WriterA &dw)
void writeLinetype(DL_WriterA &dw, const DL_LinetypeData &data)
void writeLine(DL_WriterA &dw, const DL_LineData &data, const DL_Attributes &attrib)
void writePolylineEnd(DL_WriterA &dw)
void writeBlockRecord(DL_WriterA &dw)
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 dxfReal(int gc, double value) const
void dxfInt(int gc, int value) const
void dxfString(int gc, const char *value) const
void sectionTables() const
void tableLinetypes(int num) const
void tableStyle(int num) const
void tableLayers(int num) const
void sectionBlocks() const
void tableAppid(int num) const
void tableAppidEntry(unsigned long int h=0) const
void sectionEntities() const
static bool SaveHorizontalProfiles(const QSharedPointer< DistanceMapGenerationTool::Map > &map, ccPolyline *profile, QString filename, unsigned heightStepCount, double heightShift, double angularStep_rad, double radToUnitConvFactor, QString angleUnit, const Parameters ¶ms, ecvMainAppInterface *app=0)
static bool SaveVerticalProfiles(const QSharedPointer< DistanceMapGenerationTool::Map > &map, ccPolyline *profile, QString filename, unsigned angularStepCount, double heightStep, double heightShift, const Parameters ¶ms, ecvMainAppInterface *app=0)
static bool IsEnabled()
Returns whether DXF support is enabled or not.
Main application interface (for plugins)
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
static const double c_textHeight_mm
static const double c_textMargin_mm
static const double c_profileMargin_mm
static const char HORIZ_PROFILE_LAYER[]
static const char LEGEND_LAYER[]
static const double c_pageHeight_mm
static const double c_pageWidth_mm
static const double c_pageMargin_mm
static const char PROFILE_LAYER[]
static const char VERT_PROFILE_LAYER[]
static const int s_lineWidth
static const int c_margin
QString legendRealProfileTitle
QStringList profileTitles
QString legendTheoProfileTitle