PolyTree outputs only memory adres of parent and childs
Polygon and line clipping and offsetting library (C++, C#, Delphi)
Brought to you by:
angusj
I have a problem to print certain members of the Polythree in C++.
For Parent and Childs, it prints only the memory adress. What can i do to solve this?
Could this be a Clipper bug?
Can anyone try this code for me please? Thanks !
The code is exact as the example at : http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/PolyTree/_Body.htm
For information : I have the same question at stackoverflow, but
maybe the knowledge here is better for this question.
The code example from the Clipper website in C++ :
#include <clipper/include/clipper.hpp>
#include <iterator>
#include <algorithm>
#include <iostream>
using namespace ClipperLib;
using namespace std;
test::test()
{
PolyTree array;
//Paths
Path one = {{10,10},{100,10},{100,100},{10,100}}; std::cout << "one : " << one << std::endl;
Path two = {{20,20},{20,90},{90,90},{90,20}}; std::cout << "two : " << two << std::endl;
Path three = {{30,30},{50,30},{50,50},{30,50}}; std::cout << "three : " << three << std::endl;
Path four = {{60,60},{80,60},{80,80},{60,80}}; std::cout << "four : " << four << std::endl;
Paths total;
total.push_back(one);
total.push_back(two);
total.push_back(three);
total.push_back(four);
std::cout << "total: " << total << std::endl;
ClipperLib::Clipper c;
c.AddPaths(total, ptSubject, true);
c.Execute(ctDifference,array);
c.Clear();
PolyNode* polynode = array.GetFirst();
while (polynode)
{
//do stuff with polynode here
qDebug()<< "qdebug parent : " << polynode->Parent;
std::cout << "std parent : " << polynode->Parent << std::endl;
qDebug()<< "qdebug childs : " << polynode->Childs;
qDebug()<< "qdebug isHole : " << polynode->IsHole();
qDebug()<< "qdebug childcount : " << polynode->ChildCount();
//qDebug()<< "qdebug contour : " << polynode->Contour; //error
std::cout << "std contour : " << polynode->Contour << std::endl;
polynode = polynode->GetNext();
}
}
Terminal output :
qdebug parent : 0x7fffaf129ae0
std parent : 0x7fffaf129ae0
qdebug childs : std::vector(0x55867fa62970)
qdebug isHole : false
qdebug childcount : 1
std contour : (100,100), (10,100), (10,10), (100,10)
Anonymous
I found a dirty solution over here . https://stackoverflow.com/questions/58905767/memory-adress-output-instead-of-value/58944947#58944947