Skip to content

Commit 12a6dc5

Browse files
committed
NURBS debugging code
Rebased onto trunk from ruevs/wip-intersection
1 parent 925a527 commit 12a6dc5

8 files changed

Lines changed: 254 additions & 16 deletions

File tree

src/dsc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ class List {
236236

237237
public:
238238
int n = 0;
239+
uint32_t cc = 0;
239240

240-
bool IsEmpty() const { return n == 0; }
241+
bool IsEmpty() const { return 0 >= n; } // A negative number of list elements?!
241242

242243
void ReserveMore(int howMuch) {
243244
if(n + howMuch > elemsAllocated) {

src/platform/guiwin.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,16 @@ std::vector<std::string> InitGui(int argc, char **argv) {
17011701
SetLocale("en_US");
17021702
}
17031703

1704+
#ifndef NDEBUG
1705+
// create a debug console
1706+
if(AllocConsole()) {
1707+
(void)freopen("CONOUT$", "w", stdout/*stderr*/);
1708+
SetConsoleTitle(L"Debug Console");
1709+
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
1710+
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
1711+
}
1712+
#endif
1713+
17041714
return args;
17051715
}
17061716

src/polygon.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,14 @@ void SEdgeList::Clear() {
215215
l.Clear();
216216
}
217217

218-
void SEdgeList::AddEdge(Vector a, Vector b, int auxA, int auxB, int tag) {
218+
void SEdgeList::AddEdge(Vector a, Vector b, int auxA, int auxB, int tag, uint32_t cc) {
219219
SEdge e = {};
220220
e.tag = tag;
221221
e.a = a;
222222
e.b = b;
223223
e.auxA = auxA;
224224
e.auxB = auxB;
225+
e.cc = cc;
225226
l.Add(&e);
226227
}
227228

src/polygon.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum class EdgeKind : uint32_t {
4949
class SEdge {
5050
public:
5151
int tag;
52+
uint32_t cc;
5253
int auxA, auxB;
5354
Vector a, b;
5455

@@ -61,7 +62,7 @@ class SEdgeList {
6162
List<SEdge> l;
6263

6364
void Clear();
64-
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0, int tag=0);
65+
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0, int tag=0, uint32_t cc=0);
6566
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir=false) const;
6667
bool AssembleContour(Vector first, Vector last, SContour *dest,
6768
SEdge *errorAt, bool keepDir, int start) const;

src/render/rendergl1.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,28 @@ void OpenGl1Renderer::DrawLine(const Vector &a, const Vector &b, hStroke hcs) {
476476

477477
void OpenGl1Renderer::DrawEdges(const SEdgeList &el, hStroke hcs) {
478478
double phase = 0.0;
479+
unsigned n = 0;
479480
for(const SEdge *e = el.l.First(); e; e = el.l.NextAfter(e)) {
480481
DoStippledLine(e->a, e->b, hcs, phase);
481482
phase += e->a.Minus(e->b).Magnitude();
483+
484+
/*debug*/
485+
if(0 != e->cc) {
486+
std::shared_ptr<SolveSpace::ViewportCanvas> canvas = SS.GW.canvas;
487+
488+
const Camera &camera = canvas->GetCamera();
489+
490+
Canvas::Stroke strokeError = Style::Stroke(Style::DRAW_ERROR);
491+
strokeError.layer = Canvas::Layer::FRONT;
492+
strokeError.width = 1.0f;
493+
Canvas::hStroke hcsError = canvas->GetStroke(strokeError);
494+
495+
double textHeight = Style::DefaultTextHeight()*8 / camera.scale;
496+
497+
DrawVectorText(ssprintf(" %03u-%lu-%i-%i", n, e->cc, e->auxA, e->auxB ), textHeight + textHeight*n/1000, e->a,
498+
camera.projRight, camera.projUp, hcsError);
499+
++n;
500+
}
482501
}
483502
}
484503

0 commit comments

Comments
 (0)