Commit 24e9b1e1 by jonas

SVG writing: the input polygon and the resulting cube skeleton are now written…

SVG writing: the input polygon and the resulting cube skeleton are now written as different SVG groups
parent 1752f3fe
......@@ -64,7 +64,7 @@ then
echo "* Computing cube skeleton..."
./2Dskeleton -i $inputToUse -f $SCALE 1>/dev/null
echo "* Computing union of rectangles..."
arch=`getconf LONG_BIT`
arch=`getconf LONG_BIT`
./bin/2DContourDC_$arch boxes.txt > boxes.vl # BoxUnion3D software
rm boxes.txt
python toBrep2D/tobrep.py boxes.vl > "$input.brep" # Orto-brep software
......
......@@ -96,11 +96,12 @@ int Skeleton2DGraph::getNumEdges(){
void Skeleton2DGraph::outputSvg(string path, Number xmax, Number ymax, bool close, double s) {
ofstream fileSvg;
fileSvg.open(path.c_str());
int stroke_width = 1 + max(xmax, ymax)/1000;
fileSvg << "<?xml version=\"1.0\" standalone=\"no\"?>" << endl
<< "<svg width=\""<< xmax << "\" height=\"" << ymax << "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">" << endl;
fileSvg << "<g id=\"cubeskeleton\">"<<std::endl;
boost::graph_traits<Graph>::edge_iterator ei, ei_end;
for (boost::tie(ei, ei_end) = boost::edges(graph); ei != ei_end; ++ei){
VertexId vid1 = boost::source(*ei, graph);
......@@ -111,6 +112,7 @@ void Skeleton2DGraph::outputSvg(string path, Number xmax, Number ymax, bool clos
fileSvg << "<line x1=\"" << p1.x/s << "\" y1=\"" << ymax - p1.y/s <<"\" x2=\"" << p2.x/s <<"\" y2=\"" << ymax - p2.y/s
<< "\" style=\"stroke:rgb(255,0,0);stroke-width:" << stroke_width << "\" />" << endl;
}
fileSvg <<"</g>"<<std::endl;
if(close)
fileSvg << "</svg>" << endl;
fileSvg.close();
......
......@@ -245,6 +245,7 @@ void Skeleton2DPolygon::addToRaster(Skeleton2DRaster* raster) {
void Skeleton2DPolygon::appendToSvg(string path, int xmax, int ymax) {
fstream fileSvg;
fileSvg.open(path.c_str(), fstream::out | fstream::app);
fileSvg << "<g id=\"polygon\">"<<std::endl;
int stroke_width = 1 + max(xmax, ymax)/1000;
double s = shift;
for (Skeleton2DEdge * e : edges) {
......@@ -255,6 +256,7 @@ void Skeleton2DPolygon::appendToSvg(string path, int xmax, int ymax) {
fileSvg << "<line x1=\"" << x1 << "\" y1=\"" << ymax - y1 <<"\" x2=\"" << x2 <<"\" y2=\"" << ymax - y2
<< "\" style=\"stroke:rgb(0,0,0);stroke-width:" << stroke_width << "\" />" << endl;
}
fileSvg << "</g>" <<std::endl;
fileSvg << "</svg>" << endl;
fileSvg.close();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment