+ split file extension from descriptive text of file format to avoid that invalid translation breaks file dialog

+ add method to make image view unclosable for user
+ fix possible crash in MeshAlgorithm::GetMeshBorder
+ fix possible crash in MeshAlgorithm::ConnectLines
This commit is contained in:
wmayer 2015-10-06 17:28:52 +02:00
parent 72a260cc6e
commit 967eead27a
24 changed files with 278 additions and 253 deletions

View File

@ -25,6 +25,7 @@
#ifndef _PreComp_
# include <QDir>
# include <QFileInfo>
# include <QLibraryInfo>
# include <QMessageBox>
# include <QProcess>
@ -33,7 +34,6 @@
#include "Assistant.h"
#include <Base/Console.h>
#include <Base/FileInfo.h>
#include <App/Application.h>
using namespace Gui;
@ -100,7 +100,7 @@ bool Assistant::startAssistant()
QString doc = QString::fromUtf8(App::Application::getHelpDir().c_str());
QString qhc = doc + exe.toLower() + QLatin1String(".qhc");
Base::FileInfo fi ( (const char*)qhc.toUtf8() );
QFileInfo fi(qhc);
if (!fi.isReadable()) {
QMessageBox::critical(0, tr("%1 Help").arg(exe),
tr("%1 help files not found (%2). You might need to install the %1 documentation package.").arg(exe).arg(qhc));

View File

@ -14,7 +14,7 @@ if (FREECAD_USE_3DCONNEXION)
set(3DCONNEXION_LINKFLAGS "-F/Library/Frameworks -weak_framework 3DconnexionClient")
set(3DCONNEXION_INCLUDE_DIR ${3DCONNEXIONCLIENT_FRAMEWORK}/Headers )
endif(APPLE)
endif(FREECAD_USE_3DCONNEXION)
endif(FREECAD_USE_3DCONNEXION)
if (BUILD_VR)
add_definitions(-DBUILD_VR )

View File

@ -295,7 +295,7 @@ void StdCmdFreezeViews::onSaveViews()
{
// Save the views to an XML file
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save frozen views"),
QString(), QObject::tr("Frozen views (*.cam)"));
QString(), QString::fromLatin1("%1 (*.cam)").arg(QObject::tr("Frozen views")));
if (fn.isEmpty())
return;
QFile file(fn);
@ -345,7 +345,7 @@ void StdCmdFreezeViews::onRestoreViews()
// Restore the views from an XML file
QString fn = FileDialog::getOpenFileName(getMainWindow(), QObject::tr("Restore frozen views"),
QString(), QObject::tr("Frozen views (*.cam)"));
QString(), QString::fromLatin1("%1 (*.cam)").arg(QObject::tr("Frozen views")));
if (fn.isEmpty())
return;
QFile file(fn);

View File

@ -23,7 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMessageBox>
# include <QMessageBox>
# include <QDir>
#endif
@ -49,7 +49,7 @@ DlgOnlineHelpImp::DlgOnlineHelpImp( QWidget* parent )
{
this->setupUi(this);
prefStartPage->setFilter( tr("HTML files (*.html *.htm)") );
prefStartPage->setFilter(QString::fromLatin1("%1 (*.html *.htm)").arg(tr("HTML files")));
if (prefStartPage->fileName().isEmpty()) {
prefStartPage->setFileName(getStartpage());
}
@ -70,7 +70,7 @@ DlgOnlineHelpImp::~DlgOnlineHelpImp()
*/
QString DlgOnlineHelpImp::getStartpage()
{
QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str()));
QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str()));
return docdir.absoluteFilePath(QString::fromUtf8("Start_Page.html"));
}

View File

@ -442,7 +442,7 @@ void ParameterGroup::onCreateSubgroup()
void ParameterGroup::onExportToFile()
{
QString file = FileDialog::getSaveFileName( this, tr("Export parameter to file"),
QString::null, tr("XML (*.FCParam)"));
QString::null, QString::fromLatin1("XML (*.FCParam)"));
if ( !file.isEmpty() )
{
QTreeWidgetItem* item = currentItem();
@ -458,7 +458,7 @@ void ParameterGroup::onExportToFile()
void ParameterGroup::onImportFromFile()
{
QString file = FileDialog::getOpenFileName( this, tr("Import parameter from file"),
QString::null, tr("XML (*.FCParam)"));
QString::null, QString::fromLatin1("XML (*.FCParam)"));
if ( !file.isEmpty() )
{
QFileInfo fi(file);

View File

@ -112,6 +112,7 @@ DlgProjectUtility::DlgProjectUtility(QWidget* parent, Qt::WFlags fl)
: QDialog(parent, fl), ui(new Ui_DlgProjectUtility)
{
ui->setupUi(this);
ui->extractSource->setFilter(QString::fromLatin1("%1 (*.fcstd)").arg(tr("Project file")));
}
/**

View File

@ -32,7 +32,7 @@
<item row="0" column="1">
<widget class="Gui::FileChooser" name="extractSource">
<property name="filter">
<string>Project file (*.fcstd)</string>
<string notr="true">Project file (*.fcstd)</string>
</property>
</widget>
</item>
@ -82,7 +82,7 @@
<item row="0" column="1">
<widget class="Gui::FileChooser" name="createSource">
<property name="filter">
<string>Document.xml</string>
<string notr="true">Document.xml</string>
</property>
</widget>
</item>

View File

@ -629,7 +629,7 @@ bool Document::saveAs(void)
QString exe = qApp->applicationName();
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe),
QString(), QObject::tr("%1 document (*.FCStd)").arg(exe));
QString(), QString::fromLatin1("%1 %2 (*.FCStd)").arg(exe).arg(QObject::tr("Document")));
if (!fn.isEmpty()) {
QFileInfo fi;
fi.setFile(fn);

View File

@ -269,7 +269,7 @@ void EditorView::setDisplayName(EditorView::DisplayName type)
bool EditorView::saveAs(void)
{
QString fn = FileDialog::getSaveFileName(this, QObject::tr("Save Macro"),
QString::null, tr("FreeCAD macro (*.FCMacro);;Python (*.py)"));
QString::null, QString::fromLatin1("%1 (*.FCMacro);;Python (*.py)").arg(tr("FreeCAD macro")));
if (fn.isEmpty())
return false;
setCurrentFileName(fn);

View File

@ -288,12 +288,12 @@ bool GraphvizView::onMsg(const char* pMsg,const char** ppReturn)
{
if (strcmp("Save",pMsg) == 0 || strcmp("SaveAs",pMsg) == 0) {
QList< QPair<QString, QString> > formatMap;
formatMap << qMakePair(tr("PNG format (*.png)"), QString::fromLatin1("png"));
formatMap << qMakePair(tr("Bitmap format (*.bmp)"), QString::fromLatin1("bmp"));
formatMap << qMakePair(tr("GIF format (*.gif)"), QString::fromLatin1("gif"));
formatMap << qMakePair(tr("JPG format (*.jpg)"), QString::fromLatin1("jpg"));
formatMap << qMakePair(tr("SVG format (*.svg)"), QString::fromLatin1("svg"));
formatMap << qMakePair(tr("PDF format (*.pdf)"), QString::fromLatin1("pdf"));
formatMap << qMakePair(QString::fromLatin1("%1 (*.png)").arg(tr("PNG format")), QString::fromLatin1("png"));
formatMap << qMakePair(QString::fromLatin1("%1 (*.bmp)").arg(tr("Bitmap format")), QString::fromLatin1("bmp"));
formatMap << qMakePair(QString::fromLatin1("%1 (*.gif)").arg(tr("GIF format")), QString::fromLatin1("gif"));
formatMap << qMakePair(QString::fromLatin1("%1 (*.jpg)").arg(tr("JPG format")), QString::fromLatin1("jpg"));
formatMap << qMakePair(QString::fromLatin1("%1 (*.svg)").arg(tr("SVG format")), QString::fromLatin1("svg"));
formatMap << qMakePair(QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format")), QString::fromLatin1("pdf"));
//formatMap << qMakePair(tr("VRML format (*.vrml)"), QString::fromLatin1("vrml"));
QStringList filter;
@ -377,7 +377,7 @@ void GraphvizView::print()
void GraphvizView::printPdf()
{
QStringList filter;
filter << tr("PDF format (*.pdf)");
filter << QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format"));
QString selectedFilter;
QString fn = Gui::FileDialog::getSaveFileName(this, tr("Export graph"), QString(), filter.join(QLatin1String(";;")), &selectedFilter);

View File

@ -1197,7 +1197,7 @@ void PythonConsole::onSaveHistoryAs()
QString cMacroPath = QString::fromUtf8(getDefaultParameter()->GetGroup( "Macro" )->
GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str()).c_str());
QString fn = FileDialog::getSaveFileName(this, tr("Save History"), cMacroPath,
tr("Macro Files (*.FCMacro *.py)"));
QString::fromLatin1("%1 (*.FCMacro *.py)").arg(tr("Macro Files")));
if (!fn.isEmpty()) {
int dot = fn.indexOf(QLatin1Char('.'));
if (dot != -1) {
@ -1215,7 +1215,8 @@ void PythonConsole::onSaveHistoryAs()
void PythonConsole::onInsertFileName()
{
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), tr("Insert file name"), QString::null, tr("All Files (*.*)") );
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), tr("Insert file name"), QString::null,
QString::fromLatin1("%1 (*.*)").arg(tr("All Files")));
if ( fn.isEmpty() )
return;
insertPlainText(fn);

View File

@ -433,7 +433,8 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )
void ReportOutput::onSaveAs()
{
QString fn = QFileDialog::getSaveFileName(this, tr("Save Report Output"), QString(), tr("Plain Text Files (*.txt *.log)"));
QString fn = QFileDialog::getSaveFileName(this, tr("Save Report Output"), QString(),
QString::fromLatin1("%1 (*.txt *.log)").arg(tr("Plain Text Files")));
if (!fn.isEmpty()) {
QFileInfo fi(fn);
if (fi.completeSuffix().isEmpty())

View File

@ -196,7 +196,7 @@ SoAxisCrossKit::createAxes()
setPart("yAxis.shape", shape);
setPart("zAxis.shape", shape);
// Place the axes ând heads
// Place the axes and heads
set("yAxis.transform", "rotation 0 0 1 1.5707999");
set("zAxis.transform", "rotation 0 1 0 -1.5707999");

View File

@ -450,7 +450,8 @@ void View3DInventor::print()
void View3DInventor::printPdf()
{
QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(), tr("PDF file (*.pdf)"));
QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(),
QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file")));
if (!filename.isEmpty()) {
Gui::WaitCursor wc;
QPrinter printer(QPrinter::ScreenResolution);

View File

@ -38,7 +38,7 @@ using namespace ImageGui;
/* TRANSLATOR ImageGui::ImageView */
ImageView::ImageView(QWidget* parent)
: MDIView(0, parent)
: MDIView(0, parent), _ignoreCloseEvent(false)
{
// enable mouse tracking when moving even if no buttons are pressed
setMouseTracking(true);
@ -47,7 +47,7 @@ ImageView::ImageView(QWidget* parent)
_mouseEventsEnabled = true;
// Create the default status bar for displaying messages
EnableStatusBar(true);
enableStatusBar(true);
// Create an OpenGL widget for displaying images
_pGLImageBox = new GLImageBox(this);
@ -96,8 +96,13 @@ void ImageView::createActions()
_pStdToolBar->addAction(_pOneToOneAct);
}
QSize ImageView::minimumSizeHint () const
{
return QSize(40, 40);
}
// Enable or disable the status bar
void ImageView::EnableStatusBar(bool Enable)
void ImageView::enableStatusBar(bool Enable)
{
if (Enable == true)
{
@ -116,27 +121,27 @@ void ImageView::EnableStatusBar(bool Enable)
}
// Enable or disable the toolbar
void ImageView::EnableToolBar(bool Enable)
void ImageView::enableToolBar(bool Enable)
{
_pStdToolBar->setShown(Enable);
}
// Enable or disable the mouse events
void ImageView::EnableMouseEvents(bool Enable)
void ImageView::enableMouseEvents(bool Enable)
{
_mouseEventsEnabled = Enable;
_mouseEventsEnabled = Enable;
}
// Enable (show) or disable (hide) the '1:1' action
// Current state (zoom, position) is left unchanged
void ImageView::EnableOneToOneAction(bool Enable)
void ImageView::enableOneToOneAction(bool Enable)
{
_pOneToOneAct->setVisible(Enable);
}
// Enable (show) or disable (hide) the 'fit image' action
// Current state (zoom, position) is left unchanged
void ImageView::EnableFitImageAction(bool Enable)
void ImageView::enableFitImageAction(bool Enable)
{
_pFitAct->setVisible(Enable);
}
@ -243,7 +248,7 @@ void ImageView::clearImage()
{
_pGLImageBox->clearImage();
_pGLImageBox->redraw(); // clears view
updateStatusBar();
updateStatusBar();
}
// Load image by copying the pixel data
@ -262,7 +267,7 @@ int ImageView::createImageCopy(void* pSrcPixelData, unsigned long width, unsigne
{
int ret = _pGLImageBox->createImageCopy(pSrcPixelData, width, height, format, numSigBitsPerSample, displayMode);
showOriginalColors();
updateStatusBar();
updateStatusBar();
return ret;
}
@ -286,10 +291,25 @@ int ImageView::pointImageTo(void* pSrcPixelData, unsigned long width, unsigned l
{
int ret = _pGLImageBox->pointImageTo(pSrcPixelData, width, height, format, numSigBitsPerSample, takeOwnership, displayMode);
showOriginalColors();
updateStatusBar();
updateStatusBar();
return ret;
}
// called when user presses X
void ImageView::closeEvent(QCloseEvent *e)
{
if (_ignoreCloseEvent == true)
{
// ignore the close event
e->ignore();
closeEventIgnored(); // and emit a signal that we ignored it
}
else
{
Gui::MDIView::closeEvent(e); // if called the window will be closed anyway
}
}
// Mouse press event
void ImageView::mousePressEvent(QMouseEvent* cEvent)
{
@ -346,7 +366,7 @@ void ImageView::mouseDoubleClickEvent(QMouseEvent* cEvent)
//int pixY = (int)floor(icY + 0.5);
_pGLImageBox->setZoomFactor(_pGLImageBox->getZoomFactor(), true, (int)floor(icX + 0.5), (int)floor(icY + 0.5));
_pGLImageBox->redraw();
updateStatusBar();
updateStatusBar();
}
}
}
@ -446,13 +466,13 @@ void ImageView::showEvent (QShowEvent * e)
void ImageView::updateStatusBar()
{
if (_statusBarEnabled == true)
{
{
// Create the text string to display in the status bar
QString txt = createStatusBarText();
// Update status bar with new text
statusBar()->showMessage(txt);
}
}
}
// Create the text to display in the status bar.

View File

@ -48,11 +48,12 @@ public:
virtual int createImageCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, int displayMode = IV_DISPLAY_RESET);
virtual int pointImageTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership, int displayMode = IV_DISPLAY_RESET);
virtual void EnableStatusBar(bool Enable);
virtual void EnableToolBar(bool Enable);
virtual void EnableMouseEvents(bool Enable);
virtual void EnableOneToOneAction(bool Enable);
virtual void EnableFitImageAction(bool Enable);
virtual void enableStatusBar(bool Enable);
virtual void enableToolBar(bool Enable);
virtual void enableMouseEvents(bool Enable);
virtual void enableOneToOneAction(bool Enable);
virtual void enableFitImageAction(bool Enable);
virtual void ignoreCloseEvent(bool ignoreCloseEvent) { _ignoreCloseEvent = ignoreCloseEvent; }
virtual int createColorMap(int numEntriesReq = 0, bool Initialise = true);
virtual void clearColorMap();
virtual int getNumColorMapEntries() const;
@ -69,9 +70,14 @@ public Q_SLOTS:
protected Q_SLOTS:
virtual void drawGraphics();
Q_SIGNALS:
void closeEventIgnored();
protected:
virtual void createActions();
virtual QSize minimumSizeHint () const;
virtual void showOriginalColors();
virtual void closeEvent(QCloseEvent *e);
virtual void mousePressEvent(QMouseEvent* cEvent);
virtual void mouseDoubleClickEvent(QMouseEvent* cEvent);
virtual void mouseMoveEvent(QMouseEvent* cEvent);
@ -113,9 +119,10 @@ protected:
// Toolbars
QToolBar* _pStdToolBar;
// Flag for status bar enablement
// Flags
bool _statusBarEnabled;
bool _mouseEventsEnabled;
bool _mouseEventsEnabled;
bool _ignoreCloseEvent;
};
} // namespace ImageViewGui

View File

@ -532,13 +532,14 @@ void MeshAlgorithm::GetMeshBorder(unsigned long uFacet, std::list<unsigned long>
{
// find adjacent edge
std::list<std::pair<unsigned long, unsigned long> >::iterator pEI;
for (pEI = openEdges.begin(); pEI != openEdges.end(); pEI++)
for (pEI = openEdges.begin(); pEI != openEdges.end(); ++pEI)
{
if (pEI->first == ulLast)
{
ulLast = pEI->second;
rBorder.push_back(ulLast);
openEdges.erase(pEI);
pEI = openEdges.begin();
break;
}
else if (pEI->second == ulFirst)
@ -546,6 +547,7 @@ void MeshAlgorithm::GetMeshBorder(unsigned long uFacet, std::list<unsigned long>
ulFirst = pEI->first;
rBorder.push_front(ulFirst);
openEdges.erase(pEI);
pEI = openEdges.begin();
break;
}
}
@ -1454,125 +1456,117 @@ bool MeshAlgorithm::CutWithPlane (const Base::Vector3f &clBase, const Base::Vect
bool MeshAlgorithm::ConnectLines (std::list<std::pair<Base::Vector3f, Base::Vector3f> > &rclLines,
std::list<std::vector<Base::Vector3f> > &rclPolylines, float fMinEps) const
{
typedef std::list<std::pair<Base::Vector3f, Base::Vector3f> >::iterator TCIter;
typedef std::list<std::pair<Base::Vector3f, Base::Vector3f> >::iterator TCIter;
// square search radius
// const float fMinEps = 1.0e-2f; // := 10 mirometer distance
fMinEps = fMinEps * fMinEps;
// square search radius
// const float fMinEps = 1.0e-2f; // := 10 mirometer distance
fMinEps = fMinEps * fMinEps;
// remove all lines which distance is smaller than epsilon
std::list<TCIter> _clToDelete;
float fToDelDist = fMinEps / 10.0f;
for (TCIter pF = rclLines.begin(); pF != rclLines.end(); pF++)
{
// remove all lines whose distance is smaller than epsilon
std::list<TCIter> _clToDelete;
float fToDelDist = fMinEps / 10.0f;
for (TCIter pF = rclLines.begin(); pF != rclLines.end(); ++pF) {
if (Base::DistanceP2(pF->first, pF->second) < fToDelDist)
_clToDelete.push_back(pF);
}
for (std::list<TCIter>::iterator pI = _clToDelete.begin(); pI != _clToDelete.end(); pI++)
rclLines.erase(*pI);
while (rclLines.size() > 0)
{
TCIter pF;
// new polyline
std::list<Base::Vector3f> clPoly;
// add first line and delete from the list
Base::Vector3f clFront = rclLines.begin()->first; // current start point of the polyline
Base::Vector3f clEnd = rclLines.begin()->second; // current end point of the polyline
clPoly.push_back(clFront);
clPoly.push_back(clEnd);
rclLines.erase(rclLines.begin());
// search for the next line on the begin/end of the polyline and add it
TCIter pFront, pEnd;
do
{
float fFrontMin = fMinEps, fEndMin = fMinEps;
bool bFrontFirst=false, bEndFirst=false;
pFront = rclLines.end();
pEnd = rclLines.end();
for (pF = rclLines.begin(); pF != rclLines.end(); pF++)
{
if (Base::DistanceP2(clFront, pF->first) < fFrontMin)
{
fFrontMin = Base::DistanceP2(clFront, pF->first);
pFront = pF;
bFrontFirst = true;
}
else if (Base::DistanceP2(clEnd, pF->first) < fEndMin)
{
fEndMin = Base::DistanceP2(clEnd, pF->first);
pEnd = pF;
bEndFirst = true;
}
else if (Base::DistanceP2(clFront, pF->second) < fFrontMin)
{
fFrontMin = Base::DistanceP2(clFront, pF->second);
pFront = pF;
bFrontFirst = false;
}
else if (Base::DistanceP2(clEnd, pF->second) < fEndMin)
{
fEndMin = Base::DistanceP2(clEnd, pF->second);
pEnd = pF;
bEndFirst = false;
}
}
if (pFront != rclLines.end())
{
if (bFrontFirst == true)
{
clPoly.push_front(pFront->second);
clFront = pFront->second;
}
else
{
clPoly.push_front(pFront->first);
clFront = pFront->first;
}
rclLines.erase(pFront);
}
if (pEnd != rclLines.end())
{
if (bEndFirst == true)
{
clPoly.push_back(pEnd->second);
clEnd = pEnd->second;
}
else
{
clPoly.push_back(pEnd->first);
clEnd = pEnd->first;
}
rclLines.erase(pEnd);
}
_clToDelete.push_back(pF);
}
while ((pFront != rclLines.end()) || (pEnd != rclLines.end()));
rclPolylines.push_back(std::vector<Base::Vector3f>(clPoly.begin(), clPoly.end()));
}
// remove all polylines with too few length
typedef std::list<std::vector<Base::Vector3f> >::iterator TPIter;
std::list<TPIter> _clPolyToDelete;
for (TPIter pJ = rclPolylines.begin(); pJ != rclPolylines.end(); pJ++)
{
if (pJ->size() == 2) // only one line segment
{
if (Base::DistanceP2(*pJ->begin(), *(pJ->begin() + 1)) <= fMinEps)
_clPolyToDelete.push_back(pJ);
for (std::list<TCIter>::iterator pI = _clToDelete.begin(); pI != _clToDelete.end(); ++pI)
rclLines.erase(*pI);
while (!rclLines.empty()) {
TCIter pF;
// new polyline
std::list<Base::Vector3f> clPoly;
// add first line and delete from the list
Base::Vector3f clFront = rclLines.begin()->first; // current start point of the polyline
Base::Vector3f clEnd = rclLines.begin()->second; // current end point of the polyline
clPoly.push_back(clFront);
clPoly.push_back(clEnd);
rclLines.erase(rclLines.begin());
// search for the next line on the begin/end of the polyline and add it
TCIter pFront, pEnd;
bool bFoundLine;
do {
float fFrontMin = fMinEps, fEndMin = fMinEps;
bool bFrontFirst=false, bEndFirst=false;
pFront = rclLines.end();
pEnd = rclLines.end();
bFoundLine = false;
for (pF = rclLines.begin(); pF != rclLines.end(); ++pF) {
if (Base::DistanceP2(clFront, pF->first) < fFrontMin) {
fFrontMin = Base::DistanceP2(clFront, pF->first);
pFront = pF;
bFrontFirst = true;
}
else if (Base::DistanceP2(clEnd, pF->first) < fEndMin) {
fEndMin = Base::DistanceP2(clEnd, pF->first);
pEnd = pF;
bEndFirst = true;
}
else if (Base::DistanceP2(clFront, pF->second) < fFrontMin) {
fFrontMin = Base::DistanceP2(clFront, pF->second);
pFront = pF;
bFrontFirst = false;
}
else if (Base::DistanceP2(clEnd, pF->second) < fEndMin) {
fEndMin = Base::DistanceP2(clEnd, pF->second);
pEnd = pF;
bEndFirst = false;
}
}
if (pFront != rclLines.end()) {
bFoundLine = true;
if (bFrontFirst) {
clPoly.push_front(pFront->second);
clFront = pFront->second;
}
else {
clPoly.push_front(pFront->first);
clFront = pFront->first;
}
rclLines.erase(pFront);
}
if (pEnd != rclLines.end()) {
bFoundLine = true;
if (bEndFirst) {
clPoly.push_back(pEnd->second);
clEnd = pEnd->second;
}
else {
clPoly.push_back(pEnd->first);
clEnd = pEnd->first;
}
rclLines.erase(pEnd);
}
}
while (bFoundLine);
rclPolylines.push_back(std::vector<Base::Vector3f>(clPoly.begin(), clPoly.end()));
}
}
for (std::list<TPIter>::iterator pK = _clPolyToDelete.begin(); pK != _clPolyToDelete.end(); pK++)
rclPolylines.erase(*pK);
return true;
// remove all polylines with too few length
typedef std::list<std::vector<Base::Vector3f> >::iterator TPIter;
std::list<TPIter> _clPolyToDelete;
for (TPIter pJ = rclPolylines.begin(); pJ != rclPolylines.end(); ++pJ) {
if (pJ->size() == 2) { // only one line segment
if (Base::DistanceP2(*pJ->begin(), *(pJ->begin() + 1)) <= fMinEps)
_clPolyToDelete.push_back(pJ);
}
}
for (std::list<TPIter>::iterator pK = _clPolyToDelete.begin(); pK != _clPolyToDelete.end(); ++pK)
rclPolylines.erase(*pK);
return true;
}
bool MeshAlgorithm::ConnectPolygons(std::list<std::vector<Base::Vector3f> > &clPolyList,

View File

@ -260,35 +260,35 @@ public:
*/
virtual ~QuadraticFit(){};
/**
* Übertragen der Quadric-Koeffizienten
* @param ulIndex Nummer des Koeffizienten (0..9)
* @return double Wert des Koeffizienten
* Get the quadric coefficients
* @param ulIndex Number of coefficient (0..9)
* @return double value of coefficient
*/
double GetCoeff(unsigned long ulIndex) const;
/**
* Übertragen der Koeffizientan als Referenz
* auf das interne Array
* @return const double& Referenz auf das double-Array
* Get the quadric coefficients as reference to the
* internal array
* @return const double& Reference to the double array
*/
const double& GetCoeffArray() const;
/**
* Aufruf des Fit-Algorithmus
* @return float Qualität des Fits.
* Invocation of fitting algorithm
* @return float Quality of fit.
*/
float Fit();
void CalcZValues(double x, double y, double &dZ1, double &dZ2) const;
/**
* Berechnen der Krümmungswerte der Quadric in einem bestimmten Punkt.
* @param x X-Koordinate
* @param y Y-Koordinate
* @param z Z-Koordinate
* @param rfCurv0 1. Hauptkrümmung
* @param rfCurv1 2. Hauptkrümmung
* @param rkDir0 Richtung der 1. Hauptkrümmung
* @param rkDir1 Richtung der 2. Hauptkrümmung
* Calculate the curvatures of the quadric at a given point.
* @param x X-coordinate
* @param y Y-coordinate
* @param z Z-coordinate
* @param rfCurv0 1. principal curvature
* @param rfCurv1 2. principal curvature
* @param rkDir0 Direction of 1. principal curvature
* @param rkDir1 Direction of 2. principal curvature
* @param dDistance
* @return bool Fehlerfreie Ausfürhung = true, ansonsten false
* @return bool Success = true, otherwise false
*/
bool GetCurvatureInfo(double x, double y, double z,
double &rfCurv0, double &rfCurv1,
@ -297,32 +297,31 @@ public:
bool GetCurvatureInfo(double x, double y, double z,
double &rfCurv0, double &rfcurv1);
/**
* Aufstellen der Formanmatrix A und Berechnen der Eigenwerte.
* @param dLambda1 Eigenwert 1
* @param dLambda2 Eigenwert 2
* @param dLambda3 Eigenwert 3
* @param clEV1 Eigenvektor 1
* @param clEV2 Eigenvektor 2
* @param clEV3 Eigenvektor 3
* Compute form matrix A and calculate Eigenvalues.
* @param dLambda1 Eigenvalue 1
* @param dLambda2 Eigenvalue 2
* @param dLambda3 Eigenvalue 3
* @param clEV1 Eigenvector 1
* @param clEV2 Eigenvector 2
* @param clEV3 Eigenvector 3
*/
void CalcEigenValues(double &dLambda1, double &dLambda2, double &dLambda3,
Base::Vector3f &clEV1, Base::Vector3f &clEV2, Base::Vector3f &clEV3) const;
protected:
double _fCoeff[ 10 ]; /**< Ziel der Koeffizienten aus dem Fit */
double _fCoeff[ 10 ]; /**< Coefficients of the fit */
};
// -------------------------------------------------------------------------------
/**
* Dies ist ein 2,5D-Ansatz, bei dem zunächst die Ausgleichsebene der Punktmenge (P_i = (x,y,z), i=1,...,n)
* bestimmt wird. Danach wird eine Parametrisierung der Datenpunkte errechnet. Die Datenpunkte
* werden somit bzgl. des lokalen Systems der Ebene dargestellt (P_i = (u,v,w)).
* Durch diese transformierten Punkte wird nun eine quadratische Funktion
* This is an 2.5D approach which first determines the bestfit plane of the point set (P_i = (x,y,z), i=1,...,n)
* to get a parametrisation of the points afterwards. The coordinates of the points with respect to the local
* coordinate system of the plane are determined and then a quadratic polynomial function of the form:
* w = f(u,v) = a*u^2 + b*v^2 + c*u*v + d*u + e*v + f
* berechnet.
* Dieser Ansatz wurde als Alternative für den 3D-Ansatz mit Quadriken entwickelt, da bei
* Quadriken in (vor allem) ebenen Bereichen recht seltsame Artefakte auftreten.
* is deermined.
* This approach was developed as an alternative for the 3D approach with quadrics because
* the latter suffers from strange artifacts in planar areas.
*/
class MeshExport SurfaceFit : public PlaneFit
{
@ -350,22 +349,20 @@ protected:
// -------------------------------------------------------------------------------
/**
* Hilfs-Klasse für den Quadric-Fit. Beinhaltet die
* partiellen Ableitungen der Quadric und dient zur
* Berechnung der Quadrik-Eigenschaften.
* Helper class for the quadric fit. Includes the
* partial derivates of the quadric and serves for
* calculation of the quadric properties.
*/
class FunctionContainer
{
public:
/**
* Die MGC-Algorithmen arbeiten mit Funktionen dieses
* Types
* WildMagic library uses function with this interface
*/
typedef double (*Function)(double,double,double);
/**
* Der parametrisierte Konstruktor. Erwartet ein Array
* mit den Quadric-Koeffizienten.
* @param pKoef Zeiger auf die Quadric-Parameter
* The constructor expects an array of quadric coefficients.
* @param pKoef Pointer to the quadric coefficients
* (double [10])
*/
FunctionContainer(const double *pKoef)
@ -374,8 +371,8 @@ public:
pImplSurf = new Wm4::QuadricSurface<double>( dKoeff );
}
/**
* Übernehmen der Quadric-Parameter
* @param pKoef Zeiger auf die Quadric-Parameter
* Apply quadric coefficients
* @param pKoef Pointer to the quadric coefficients
* (double [10])
*/
void Assign( const double *pKoef )
@ -384,28 +381,28 @@ public:
dKoeff[ ct ] = pKoef[ ct ];
}
/**
* Destruktor. Löscht die ImpicitSurface Klasse
* der MGC-Bibliothek wieder
* Destruktor. Deletes the ImpicitSurface instance
* of the WildMagic library
*/
~FunctionContainer(){ delete pImplSurf; }
/**
* Zugriff auf die Koeffizienten der Quadric
* @param idx Index des Parameters
* @return double& Der Koeffizient
* Access to the quadric coefficients
* @param idx Index to coefficient
* @return double& coefficient
*/
double& operator[](int idx){ return dKoeff[ idx ]; }
/**
* Redirector auf eine Methode der MGC Bibliothek. Ermittelt
* die Hauptkrümmungen und ihre Richtungen im angegebenen Punkt.
* @param x X-Koordinate
* @param y Y-Koordinate
* @param z Z-Koordinate
* @param rfCurv0 1. Hauptkrümmung
* @param rfCurv1 2. Hauptkrümmung
* @param rkDir0 Richtung der 1. Hauptkrümmung
* @param rkDir1 Richtung der 2. Hauptkrümmung
* @param dDistance Ergebnis das die Entfernung des Punktes von der Quadrik angibt.
* @return bool Fehlerfreie Ausfürhung = true, ansonsten false
* Redirector to a method of the WildMagic library. Determines
* the principal curvatures and their directions at the given point.
* @param x X-coordinate
* @param y Y-coordinate
* @param z Z-coordinate
* @param rfCurv0 1. principal curvature
* @param rfCurv1 2. principal curvature
* @param rkDir0 direction of 1. principal curvature
* @param rkDir1 direction of 2. principal curvature
* @param dDistance Gives distances from the point to the quadric.
* @return bool Success = true, otherwise false
*/
bool CurvatureInfo(double x, double y, double z,
double &rfCurv0, double &rfCurv1,
@ -502,8 +499,8 @@ public:
}
protected:
double dKoeff[ 10 ]; /**< Koeffizienten der Quadric */
Wm4::ImplicitSurface<double> *pImplSurf; /**< Zugriff auf die MGC-Bibliothek */
double dKoeff[ 10 ]; /**< Coefficients of quadric */
Wm4::ImplicitSurface<double> *pImplSurf; /**< Access to the WildMagic library */
private:
/**

View File

@ -659,7 +659,7 @@ bool MeshFixDeformedFacets::Fixup()
fCosAngles[i] = fCosAngle;
}
// first check for angle > 120°: in this case we swap with the opposite edge
// first check for angle > 120 deg: in this case we swap with the opposite edge
for (int i=0; i<3; i++)
{
float fCosAngle = fCosAngles[i];
@ -678,7 +678,7 @@ bool MeshFixDeformedFacets::Fixup()
if (done)
continue;
// now check for angle < 30°: in this case we swap with one of the edges the corner is part of
// now check for angle < 30 deg: in this case we swap with one of the edges the corner is part of
for (int j=0; j<3; j++)
{
float fCosAngle = fCosAngles[j];

View File

@ -328,7 +328,8 @@ public:
};
/**
* The MeshEvalDeformedFacets class searches for deformed facets. A facet is regarded as deformed if an angle is < 30° or > 120°.
* The MeshEvalDeformedFacets class searches for deformed facets. A facet is regarded as deformed
* if an angle is < 30 deg or > 120 deg.
* @see MeshFixDegeneratedFacets
* @author Werner Mayer
*/

View File

@ -432,7 +432,7 @@ bool MeshGeomFacet::IsDeformed() const
fCosAngle = u * v;
// x < 30° => cos(x) > sqrt(3)/2 or x > 120° => cos(x) < -0.5
// x < 30 deg => cos(x) > sqrt(3)/2 or x > 120 deg => cos(x) < -0.5
if (fCosAngle > 0.86f || fCosAngle < -0.5f)
return true;
}
@ -748,7 +748,7 @@ void MeshGeomFacet::SubSample (float fStep, std::vector<Base::Vector3f> &rclPoin
}
/**
* Fast Triangle-Triangle Intersection Test by Tomas Möller
* Fast Triangle-Triangle Intersection Test by Tomas Moeller
* http://www.acm.org/jgt/papers/Moller97/tritri.html
* http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/
*/
@ -771,7 +771,7 @@ bool MeshGeomFacet::IntersectWithFacet(const MeshGeomFacet &rclFacet) const
}
/**
* Fast Triangle-Triangle Intersection Test by Tomas Möller
* Fast Triangle-Triangle Intersection Test by Tomas Moeller
* http://www.acm.org/jgt/papers/Moller97/tritri.html
* http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/
*/

View File

@ -361,8 +361,8 @@ public:
bool IsDegenerated() const;
/**
* Checks whether the triangle is deformed. The definition of a deformed triangles is not as strong
* as the definition of a degenerated triangle. A triangle is deformed if the maximum angle exceeds 120°
* or the minimum angle falls below 30°.
* as the definition of a degenerated triangle. A triangle is deformed if the maximum angle exceeds 120 deg
* or the minimum angle falls below 30 deg.
* A degenerated triangle is also a deformed triangle.
*/
bool IsDeformed() const;

View File

@ -385,16 +385,16 @@ void CmdMeshImport::activated(int iMsg)
{
// use current path as default
QStringList filter;
filter << QObject::tr("All Mesh Files (*.stl *.ast *.bms *.obj *.off *.ply)");
filter << QObject::tr("Binary STL (*.stl)");
filter << QObject::tr("ASCII STL (*.ast)");
filter << QObject::tr("Binary Mesh (*.bms)");
filter << QObject::tr("Alias Mesh (*.obj)");
filter << QObject::tr("Object File Format (*.off)");
filter << QObject::tr("Inventor V2.1 ascii (*.iv)");
filter << QObject::tr("Stanford Polygon (*.ply)");
filter << QString::fromLatin1("%1 (*.stl *.ast *.bms *.obj *.off *.ply)").arg(QObject::tr("All Mesh Files"));
filter << QString::fromLatin1("%1 (*.stl)").arg(QObject::tr("Binary STL"));
filter << QString::fromLatin1("%1 (*.ast)").arg(QObject::tr("ASCII STL"));
filter << QString::fromLatin1("%1 (*.bms)").arg(QObject::tr("Binary Mesh"));
filter << QString::fromLatin1("%1 (*.obj)").arg(QObject::tr("Alias Mesh"));
filter << QString::fromLatin1("%1 (*.off)").arg(QObject::tr("Object File Format"));
filter << QString::fromLatin1("%1 (*.iv)").arg(QObject::tr("Inventor V2.1 ascii"));
filter << QString::fromLatin1("%1 (*.ply)").arg(QObject::tr("Stanford Polygon"));
//filter << "Nastran (*.nas *.bdf)";
filter << QObject::tr("All Files (*.*)");
filter << QString::fromLatin1("%1 (*.*)").arg(QObject::tr("All Files"));
// Allow multi selection
QStringList fn = Gui::FileDialog::getOpenFileNames(Gui::getMainWindow(),
@ -445,20 +445,20 @@ void CmdMeshExport::activated(int iMsg)
QString dir = QString::fromUtf8(docObj->Label.getValue());
QList<QPair<QString, QByteArray> > ext;
ext << qMakePair<QString, QByteArray>(QObject::tr("Binary STL (*.stl)"), "STL");
ext << qMakePair<QString, QByteArray>(QObject::tr("ASCII STL (*.stl)"), "AST");
ext << qMakePair<QString, QByteArray>(QObject::tr("ASCII STL (*.ast)"), "AST");
ext << qMakePair<QString, QByteArray>(QObject::tr("Binary Mesh (*.bms)"), "BMS");
ext << qMakePair<QString, QByteArray>(QObject::tr("Alias Mesh (*.obj)"), "OBJ");
ext << qMakePair<QString, QByteArray>(QObject::tr("Object File Format (*.off)"), "OFF");
ext << qMakePair<QString, QByteArray>(QObject::tr("Inventor V2.1 ascii (*.iv)"), "IV");
ext << qMakePair<QString, QByteArray>(QObject::tr("X3D Extensible 3D (*.x3d)"), "X3D");
ext << qMakePair<QString, QByteArray>(QObject::tr("Stanford Polygon (*.ply)"), "PLY");
ext << qMakePair<QString, QByteArray>(QObject::tr("VRML V2.0 (*.wrl *.vrml)"), "VRML");
ext << qMakePair<QString, QByteArray>(QObject::tr("Compressed VRML 2.0 (*.wrz)"), "WRZ");
ext << qMakePair<QString, QByteArray>(QObject::tr("Nastran (*.nas *.bdf)"), "NAS");
ext << qMakePair<QString, QByteArray>(QObject::tr("Python module def (*.py)"), "PY");
ext << qMakePair<QString, QByteArray>(QObject::tr("All Files (*.*)"), ""); // Undefined
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.stl)").arg(QObject::tr("Binary STL")), "STL");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.stl)").arg(QObject::tr("ASCII STL")), "AST");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.ast)").arg(QObject::tr("ASCII STL")), "AST");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.bms)").arg(QObject::tr("Binary Mesh")), "BMS");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.obj)").arg(QObject::tr("Alias Mesh")), "OBJ");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.off)").arg(QObject::tr("Object File Format")), "OFF");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.iv)").arg(QObject::tr("Inventor V2.1 ascii")), "IV");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.x3d)").arg(QObject::tr("X3D Extensible 3D")), "X3D");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.ply)").arg(QObject::tr("Stanford Polygon")), "PLY");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.wrl *.vrml)").arg(QObject::tr("VRML V2.0")), "VRML");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.wrz)").arg(QObject::tr("Compressed VRML 2.0")), "WRZ");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.nas *.bdf)").arg(QObject::tr("Nastran")), "NAS");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.py)").arg(QObject::tr("Python module def")), "PY");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.*)").arg(QObject::tr("All Files")), ""); // Undefined
QStringList filter;
for (QList<QPair<QString, QByteArray> >::iterator it = ext.begin(); it != ext.end(); ++it)
filter << it->first;

View File

@ -69,7 +69,8 @@ CmdPointsImport::CmdPointsImport()
void CmdPointsImport::activated(int iMsg)
{
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
QString::null, QString(), QObject::tr("Ascii Points (*.asc);;All Files (*.*)"));
QString::null, QString(), QString::fromLatin1("%1 (*.asc);;%2 (*.*)")
.arg(QObject::tr("Ascii Points")).arg(QObject::tr("All Files")));
if ( fn.isEmpty() )
return;
@ -112,7 +113,8 @@ CmdPointsExport::CmdPointsExport()
void CmdPointsExport::activated(int iMsg)
{
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(),
QString::null, QString(), QObject::tr("Ascii Points (*.asc);;All Files (*.*)"));
QString::null, QString(), QString::fromLatin1("%1 (*.asc);;%2 (*.*)")
.arg(QObject::tr("Ascii Points")).arg(QObject::tr("All Files")));
if ( fn.isEmpty() )
return;