Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 12, 2014
2 parents 0f6ccf1 + 3cbc877 commit 99d10a6
Show file tree
Hide file tree
Showing 24 changed files with 3,839 additions and 2,932 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Drawing/App/FeatureViewPart.cpp
Expand Up @@ -194,7 +194,7 @@ App::DocumentObjectExecReturn *FeatureViewPart::execute(void)
bool smooth = ShowSmoothLines.getValue();

try {
ProjectionAlgos Alg(ProjectionAlgos::invertY(shape),Dir);
ProjectionAlgos Alg(shape,Dir);
result << "<g"
<< " id=\"" << ViewName << "\"" << endl
<< " transform=\"rotate("<< Rotation.getValue() << ","<< X.getValue()<<","<<Y.getValue()<<") translate("<< X.getValue()<<","<<Y.getValue()<<") scale("<< Scale.getValue()<<","<<Scale.getValue()<<")\"" << endl
Expand Down
66 changes: 40 additions & 26 deletions src/Mod/Drawing/App/ProjectionAlgos.cpp
Expand Up @@ -90,7 +90,7 @@ using namespace std;



ProjectionAlgos::ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3d &Dir)
ProjectionAlgos::ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3d &Dir)
: Input(Input), Direction(Dir)
{
execute();
Expand All @@ -99,6 +99,13 @@ ProjectionAlgos::ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3d
ProjectionAlgos::~ProjectionAlgos()
{
}

/*
// no longer used, replaced invertY by adding
// << " transform=\"scale(1,-1)\"" << endl
// to getSVG(...) below.
// invertY, as here, wasn't right for intended purpose - always reflected in model Y direction rather
// than SVG projection Y direction. Also better to reflect about (0,0,0) rather than bbox centre
TopoDS_Shape ProjectionAlgos::invertY(const TopoDS_Shape& shape)
{
Expand All @@ -113,6 +120,7 @@ TopoDS_Shape ProjectionAlgos::invertY(const TopoDS_Shape& shape)
BRepBuilderAPI_Transform mkTrf(shape, mat);
return mkTrf.Shape();
}
*/

void ProjectionAlgos::execute(void)
{
Expand Down Expand Up @@ -154,86 +162,92 @@ std::string ProjectionAlgos::getSVG(ExtractionType type, double scale, double to
if (!H.IsNull() && (type & WithHidden)) {
double width = hiddenscale;
BRepMesh::Mesh(H,tolerance);
result << "<g"
result << "<g"
//<< " id=\"" << ViewName << "\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
<< " stroke-dasharray=\"0.2,0.1\"" << endl
<< " fill=\"none\"" << endl
<< " transform=\"scale(1,-1)\"" << endl
<< " >" << endl
<< output.exportEdges(H)
<< "</g>" << endl;
}
if (!HO.IsNull() && (type & WithHidden)) {
double width = hiddenscale;
BRepMesh::Mesh(HO,tolerance);
result << "<g"
result << "<g"
//<< " id=\"" << ViewName << "\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
<< " stroke-dasharray=\"0.02,0.1\"" << endl
<< " fill=\"none\"" << endl
<< " transform=\"scale(1,-1)\"" << endl
<< " >" << endl
<< output.exportEdges(HO)
<< "</g>" << endl;
}
if (!VO.IsNull()) {
double width = scale;
BRepMesh::Mesh(VO,tolerance);
result << "<g"
result << "<g"
//<< " id=\"" << ViewName << "\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
<< " fill=\"none\"" << endl
<< " transform=\"scale(1,-1)\"" << endl
<< " >" << endl
<< output.exportEdges(VO)
<< "</g>" << endl;
}
if (!V.IsNull()) {
double width = scale;
BRepMesh::Mesh(V,tolerance);
result << "<g"
result << "<g"
//<< " id=\"" << ViewName << "\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
<< " fill=\"none\"" << endl
<< " transform=\"scale(1,-1)\"" << endl
<< " >" << endl
<< output.exportEdges(V)
<< "</g>" << endl;
}
if (!V1.IsNull() && (type & WithSmooth)) {
double width = scale;
BRepMesh::Mesh(V1,tolerance);
result << "<g"
result << "<g"
//<< " id=\"" << ViewName << "\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
<< " fill=\"none\"" << endl
<< " transform=\"scale(1,-1)\"" << endl
<< " >" << endl
<< output.exportEdges(V1)
<< "</g>" << endl;
}
if (!H1.IsNull() && (type & WithSmooth) && (type & WithHidden)) {
double width = hiddenscale;
BRepMesh::Mesh(H1,tolerance);
result << "<g"
result << "<g"
//<< " id=\"" << ViewName << "\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
<< " stroke-dasharray=\"0.09,0.05\"" << endl
<< " fill=\"none\"" << endl
<< " transform=\"scale(1,-1)\"" << endl
<< " >" << endl
<< output.exportEdges(H1)
<< "</g>" << endl;
Expand All @@ -247,7 +261,7 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
{
std::stringstream result;
DXFOutput output;

result << "0" << endl
<< "SECTION" << endl

Expand All @@ -257,9 +271,9 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
if (!H.IsNull() && (type & WithHidden)) {
//float width = 0.15f/scale;
BRepMesh::Mesh(H,tolerance);
result //<< "<g"
result //<< "<g"
//<< " id=\"" << ViewName << "\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
Expand All @@ -272,9 +286,9 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
if (!HO.IsNull() && (type & WithHidden)) {
//float width = 0.15f/scale;
BRepMesh::Mesh(HO,tolerance);
result //<< "<g"
result //<< "<g"
//<< " id=\"" << ViewName << "\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
Expand All @@ -287,10 +301,10 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
if (!VO.IsNull()) {
//float width = 0.35f/scale;
BRepMesh::Mesh(VO,tolerance);
result //<< "<g"
result //<< "<g"
//<< " id=\"" << ViewName << "\"" << endl

/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
Expand All @@ -303,9 +317,9 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
if (!V.IsNull()) {
//float width = 0.35f/scale;
BRepMesh::Mesh(V,tolerance);
result //<< "<g"
result //<< "<g"
//<< " id=\"" << ViewName << "\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
Expand All @@ -319,10 +333,10 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
if (!V1.IsNull() && (type & WithSmooth)) {
//float width = 0.35f/scale;
BRepMesh::Mesh(V1,tolerance);
result //<< "<g"
result //<< "<g"

//<< " id=\"" << ViewName << "\"" << endl
/* << " stroke=\"rgb(0, 0, 0)\"" << endl
/* << " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
<< " stroke-linejoin=\"miter\"" << endl
Expand All @@ -335,9 +349,9 @@ std::string ProjectionAlgos::getDXF(ExtractionType type, double scale, double to
if (!H1.IsNull() && (type & WithSmooth) && (type & WithHidden)) {
//float width = 0.15f/scale;
BRepMesh::Mesh(H1,tolerance);
result //<< "<g"
result //<< "<g"
//<< " id=\"" << ViewName << "\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
<< " stroke-width=\"" << width << "\"" << endl
<< " stroke-linecap=\"butt\"" << endl
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Drawing/App/ProjectionAlgos.h
Expand Up @@ -43,9 +43,9 @@ class DrawingExport ProjectionAlgos
virtual ~ProjectionAlgos();

void execute(void);
static TopoDS_Shape invertY(const TopoDS_Shape&);
// static TopoDS_Shape invertY(const TopoDS_Shape&);

enum ExtractionType {
enum ExtractionType {
Plain = 0,
WithHidden = 1,
WithSmooth = 2
Expand Down

0 comments on commit 99d10a6

Please sign in to comment.