Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
yang.yongquan | 99d31f4db4 | |
yang.yongquan | fbfc5f2759 | |
yang.yongquan | c4281a444e | |
yang.yongquan | f5d487afec | |
yang.yongquan | 315794709e | |
wuyize | 2cf45455ba |
|
@ -7,6 +7,7 @@
|
||||||
using Renderer::Painting;
|
using Renderer::Painting;
|
||||||
using Renderer::BaseElement;
|
using Renderer::BaseElement;
|
||||||
using Renderer::ElementTransform;
|
using Renderer::ElementTransform;
|
||||||
|
using Renderer::BaseElement;
|
||||||
using glm::bvec2;
|
using glm::bvec2;
|
||||||
using std::max;
|
using std::max;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
|
@ -248,6 +248,14 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
if (auto file = QFileInfo(QString(path.c_str())); file.isFile())
|
if (auto file = QFileInfo(QString(path.c_str())); file.isFile())
|
||||||
painting = PaintingUtil::transfromToPainting(file.filePath());
|
painting = PaintingUtil::transfromToPainting(file.filePath());
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
qDebug() << path.c_str() << "Not Found, Using Default Painting";
|
||||||
|
vector<std::pair<std::shared_ptr<Contour>, float>> contours;
|
||||||
|
Painting painting;
|
||||||
|
//if (auto file = QFileInfo(QString(path.c_str())); file.isFile())
|
||||||
|
if (auto file = QFileInfo(QString("../test.json")); file.isFile())
|
||||||
|
painting = PaintingUtil::transfromToPainting("../test.json");
|
||||||
|
else
|
||||||
{
|
{
|
||||||
qDebug() << path.c_str() << "Not Found, Using Default Painting";
|
qDebug() << path.c_str() << "Not Found, Using Default Painting";
|
||||||
vector<std::pair<std::shared_ptr<Contour>, float>> contours;
|
vector<std::pair<std::shared_ptr<Contour>, float>> contours;
|
||||||
|
@ -368,6 +376,7 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
painting.generateBuffers(glFunc);
|
painting.generateBuffers(glFunc);
|
||||||
|
|
||||||
auto index = vtManager->createVirtualTexture(painting);
|
auto index = vtManager->createVirtualTexture(painting);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Line.h"
|
#include "Line.h"
|
||||||
#include <glm/detail/func_packing.hpp>
|
#include <glm/detail/func_packing.hpp>
|
||||||
|
#include <qDebug>
|
||||||
using namespace Renderer;
|
using namespace Renderer;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
@ -121,9 +122,10 @@ Point Line::getMinDistancePointOnSide(double xy, double l, double r, bool isY) {
|
||||||
swap(pMidr.x, pMidr.y);
|
swap(pMidr.x, pMidr.y);
|
||||||
}
|
}
|
||||||
double mid, midr;
|
double mid, midr;
|
||||||
|
//qDebug() << "Start" << xy << l << r << isY;
|
||||||
while (fabs(r - l) > eps) {
|
while (fabs(r - l) > eps) {
|
||||||
mid = (l + r) / 2;
|
mid = l + (r - l) / 3;
|
||||||
midr = (mid + r) / 2;
|
midr = r - (r - l) / 3;
|
||||||
if (isY) {
|
if (isY) {
|
||||||
pMid.x = mid;
|
pMid.x = mid;
|
||||||
pMidr.x = midr;
|
pMidr.x = midr;
|
||||||
|
@ -139,6 +141,7 @@ Point Line::getMinDistancePointOnSide(double xy, double l, double r, bool isY) {
|
||||||
r = midr;
|
r = midr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//qDebug() << " End" << xy << l << r << isY;
|
||||||
Point ans = { xy, l };
|
Point ans = { xy, l };
|
||||||
if (isY) swap(ans.x, ans.y);
|
if (isY) swap(ans.x, ans.y);
|
||||||
return ans;
|
return ans;
|
||||||
|
@ -155,9 +158,9 @@ int Line::getPointSideOfLine(Point p) {
|
||||||
|
|
||||||
bool Line::judgeOneSideIntersectionWithWidth(double xy, double l, double r, bool isY, double width, int type) {
|
bool Line::judgeOneSideIntersectionWithWidth(double xy, double l, double r, bool isY, double width, int type) {
|
||||||
Point p = getMinDistancePointOnSide(xy, l, r, isY);
|
Point p = getMinDistancePointOnSide(xy, l, r, isY);
|
||||||
if (type && getPointSideOfLine(p) != type) {
|
//if (type && getPointSideOfLine(p) != type) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
return getMinDistanceFromPoint(p) <= width;
|
return getMinDistanceFromPoint(p) <= width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <qDebug>
|
||||||
|
|
||||||
using namespace Renderer;
|
using namespace Renderer;
|
||||||
using std::set;
|
using std::set;
|
||||||
|
@ -96,6 +97,7 @@ void LineTree::monotonization(vector<PointVector>& inLines, vector<std::shared_p
|
||||||
}
|
}
|
||||||
// 防止在首尾直线在与 X 轴平行上
|
// 防止在首尾直线在与 X 轴平行上
|
||||||
int siz = outLines.size();
|
int siz = outLines.size();
|
||||||
|
qWarning() << outLines.size();
|
||||||
if (!(outLines[0]->getBegin() == outLines[siz - 1]->getEnd()))
|
if (!(outLines[0]->getBegin() == outLines[siz - 1]->getEnd()))
|
||||||
return;
|
return;
|
||||||
if (isOffset) {
|
if (isOffset) {
|
||||||
|
@ -141,8 +143,7 @@ bool LineTree::handleShortCutNode(LineTreeNode& fa, LineTreeNode& nowTreeNode, d
|
||||||
nowTreeNode.lineSet.push_back(lineIndex);
|
nowTreeNode.lineSet.push_back(lineIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nowTreeNode.lineSet.size() <= requiredLineMin
|
if (nowTreeNode.lineSet.size() <= requiredLineMin || (nowTreeNode.bound.z()-nowTreeNode.bound.x()) *sqrt(2) <= lineWidth) {
|
||||||
|| (nowTreeNode.bound.z()-nowTreeNode.bound.x())*sqrt(2) <= lineWidth) {
|
|
||||||
if (nowTreeNode.lineSet.empty())
|
if (nowTreeNode.lineSet.empty())
|
||||||
return false;
|
return false;
|
||||||
restOfTreeNodes.push_back(nowTreeNode);
|
restOfTreeNodes.push_back(nowTreeNode);
|
||||||
|
@ -269,7 +270,7 @@ vector<BvhTreeData> LineTree::getPointLineAndBvhTree(vector<float>& resPoints, v
|
||||||
oneData.leftSon = resLines.size();
|
oneData.leftSon = resLines.size();
|
||||||
oneData.rightSon = 0;
|
oneData.rightSon = 0;
|
||||||
oneData.bound = nowTreeNode.bound;
|
oneData.bound = nowTreeNode.bound;
|
||||||
//std::cout << nowTreeNode.lineSet.size() << ' ';
|
qDebug() << nowTreeNode.bound << nowTreeNode.lineSet.size() << ' ';
|
||||||
resLines.push_back(nowTreeNode.lineSet.size());
|
resLines.push_back(nowTreeNode.lineSet.size());
|
||||||
for (auto& lineIndex : nowTreeNode.lineSet) {
|
for (auto& lineIndex : nowTreeNode.lineSet) {
|
||||||
resLines.push_back(lineIndex);
|
resLines.push_back(lineIndex);
|
||||||
|
|
Loading…
Reference in New Issue