11 #include "ui_saveMascaretFileDlg.h"
41 QStringList(),
"georef", QStringList(),
42 QStringList{
"(Geo-)Mascaret profile (*.georef)"},
Export}) {
47 bool& exclusive)
const {
60 name.replace(
' ',
'_');
71 localP.
x = (P - C).
dot(U);
72 localP.
y = P.
u[upDir];
83 std::vector<ccPolyline*> profiles;
86 std::vector<ccPolyline*> candidates;
88 candidates.push_back(
static_cast<ccPolyline*
>(entity));
98 for (
size_t i = 0; i < candidates.size(); ++i) {
112 "valid profile (missing meta-data)")
116 profiles.push_back(poly);
119 }
catch (
const std::bad_alloc&) {
127 if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
130 QTextStream outFile(&file);
131 outFile.setRealNumberNotation(QTextStream::FixedNotation);
132 outFile.setRealNumberPrecision(12);
138 QString biefName = smfDlg.biefNameLineEdit->text();
140 switch (smfDlg.typeComboBox->currentIndex()) {
155 if (profiles.size() > 1) {
156 for (
size_t i = 0; i < profiles.size() - 1; ++i) {
157 size_t smallestIndex = i;
158 double smallestAbscissa =
162 for (
size_t j = i + 1; j < profiles.size(); ++j) {
163 double a = profiles[j]
166 if (a < smallestAbscissa) {
167 smallestAbscissa = a;
172 if (i != smallestIndex) {
173 std::swap(profiles[i], profiles[smallestIndex]);
181 for (
size_t i = 0; i < profiles.size(); ++i) {
183 unsigned vertCount = poly ? poly->
size() : 0;
189 : QStringLiteral(
"unnamed")));
229 CVLog::Warning(QString(
"[Mascaret] At least one of the meta-data "
230 "entry of polyline '%1' is invalid?!")
235 QString profileName = poly->
getName();
243 outFile <<
"PROFIL " << biefName <<
" " << profileName <<
" " << absc;
244 #define SAVE_AS_GEO_MASCARET
245 #ifdef SAVE_AS_GEO_MASCARET
246 int xDir = upDir == 2 ? 0 : upDir + 1;
247 int yDir = xDir == 2 ? 0 : xDir + 1;
254 outFile << firstPg.
u[xDir] <<
" " << firstPg.
u[yDir];
261 outFile << lastPg.
u[xDir] <<
" " << lastPg.
u[yDir];
267 outFile << Cdg.
u[xDir] <<
" " << Cdg.
u[yDir];
273 bool inverted =
false;
285 inverted = (Q1.
x < Q0.
x);
288 for (
unsigned j = 0; j < vertCount; ++j) {
290 poly->
getPoint(inverted ? vertCount - 1 - j : j);
296 outFile << Q.
x <<
" " << Q.
y <<
" " <<
type;
297 #ifdef SAVE_AS_GEO_MASCARET
303 outFile << Pg.
u[xDir] <<
" " << Pg.
u[yDir];
317 #include "MascaretFilter.moc"
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
CC_FILE_ERROR
Typical I/O filter errors.
@ CC_FERR_CANCELED_BY_USER
@ CC_FERR_NOT_ENOUGH_MEMORY
QString MakeMascaretName(QString name)
void ToLocalAbscissa(const CCVector3 &P, const CCVector3 &C, const CCVector3 &U, unsigned char upDir, CCVector2 &localP)
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static constexpr float DEFAULT_PRIORITY
virtual CC_FILE_ERROR saveToFile(ccHObject *entity, const QString &filename, const SaveParameters ¶meters) override
Saves an entity (or a group of) to a file.
virtual bool canSave(CV_CLASS_ENUM type, bool &multiple, bool &exclusive) const override
Returns whether this I/O filter can save the specified type of entity.
Mascaret File Save dialog.
SaveMascaretFileDlg(QWidget *parent=nullptr)
Default constructor.
void normalize()
Sets vector norm to unity.
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Hierarchical CLOUDVIEWER Object.
unsigned getChildrenNumber() const
Returns the number of children.
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
virtual QString getName() const
Returns object name.
bool isA(CV_CLASS_ENUM type) const
QVariant getMetaData(const QString &key) const
Returns a given associated meta data.
bool hasMetaData(const QString &key) const
Returns whether a meta-data element with the given key exists or not.
static QString MetaKeyPrefixDirection()
static QString MetaKeyUpDir()
static QString MetaKeyAbscissa()
Meta data key: profile abscissa along generatrix.
static QString MetaKeyPrefixCenter()
CCVector3d toGlobal3d(const Vector3Tpl< T > &Plocal) const
Returns the point back-projected into the original coordinates system.
unsigned size() const override
Returns the number of points.
const CCVector3 * getPoint(unsigned index) const override
Returns the ith point.
__host__ __device__ float dot(float2 a, float2 b)
QTextStream & endl(QTextStream &stream)
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Generic saving parameters.