mirror of https://github.com/vitalif/openscad
Added support for aligned, ordinate, radius and diameter DIMENSION entities
git-svn-id: http://svn.clifford.at/openscad/trunk@326 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
16de893907
commit
135370d418
2
TODO.txt
2
TODO.txt
|
@ -64,8 +64,8 @@ o Language Frontend
|
|||
o DXF Import
|
||||
- Support for POLYLINE entity
|
||||
- Support for SPLINE entity
|
||||
- Support for Aligned, Radius, Diameter and Ordinate DIMENSION
|
||||
- Support for LEADER entity
|
||||
- Support for MTEXT entity ?
|
||||
- Test INSERT with rotation. code looks wrong
|
||||
- idea: DXF inline - convert from dxf to OpenSCAD syntax -> parametrize dxf content
|
||||
o Mesh optimization on STL export
|
||||
|
|
|
@ -79,7 +79,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
|
|||
|
||||
QString mode, layer, name, iddata;
|
||||
int dimtype = 0;
|
||||
double coords[7][2];
|
||||
double coords[7][2]; // Used by DIMENSION entities
|
||||
QVector<double> xverts;
|
||||
QVector<double> yverts;
|
||||
double radius = 0, start_angle = 0, stop_angle = 0;
|
||||
|
@ -237,6 +237,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
|
|||
for (int j = 0; j < 2; j++)
|
||||
this->dims.last().coords[i][j] = coords[i][j];
|
||||
this->dims.last().angle = start_angle;
|
||||
this->dims.last().length = radius;
|
||||
this->dims.last().name = name;
|
||||
}
|
||||
else if (mode == "BLOCK") {
|
||||
|
@ -287,6 +288,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
|
|||
case 40:
|
||||
// CIRCLE, ARC: radius
|
||||
// ELLIPSE: minor to major ratio
|
||||
// DIMENSION (radial, diameter): Leader length
|
||||
radius = data.toDouble() * scale;
|
||||
break;
|
||||
case 41: // for ELLIPSE
|
||||
|
|
23
dxfdim.cc
23
dxfdim.cc
|
@ -78,24 +78,31 @@ Value builtin_dxf_dim(const QVector<QString> &argnames, const QVector<Value> &ar
|
|||
double distance_projected_on_line = fabs(x * cos(angle*M_PI/180) + y * sin(angle*M_PI/180));
|
||||
return dxf_dim_cache[key] = Value(distance_projected_on_line);
|
||||
}
|
||||
if (type == 1) {
|
||||
else if (type == 1) {
|
||||
// Aligned
|
||||
double x = d->coords[4][0] - d->coords[3][0];
|
||||
double y = d->coords[4][1] - d->coords[3][1];
|
||||
return dxf_dim_cache[key] = Value(sqrt(x*x + y*y));
|
||||
}
|
||||
if (type == 2) {
|
||||
else if (type == 2) {
|
||||
// Angular
|
||||
double a1 = atan2(d->coords[0][0] - d->coords[5][0], d->coords[0][1] - d->coords[5][1]);
|
||||
double a2 = atan2(d->coords[4][0] - d->coords[3][0], d->coords[4][1] - d->coords[3][1]);
|
||||
return dxf_dim_cache[key] = Value(fabs(a1 - a2) * 180 / M_PI);
|
||||
}
|
||||
if (type == 3) {
|
||||
// Diameter
|
||||
else if (type == 3 || type == 4) {
|
||||
// Diameter or Radius
|
||||
double x = d->coords[5][0] - d->coords[0][0];
|
||||
double y = d->coords[5][1] - d->coords[0][1];
|
||||
return dxf_dim_cache[key] = Value(sqrt(x*x + y*y));
|
||||
}
|
||||
if (type == 4) {
|
||||
// Radius
|
||||
}
|
||||
if (type == 5) {
|
||||
else if (type == 5) {
|
||||
// Angular 3 Point
|
||||
}
|
||||
else if (type == 6) {
|
||||
// Ordinate
|
||||
return dxf_dim_cache[key] = Value((d->type & 64) ? d->coords[3][0] : d->coords[3][1]);
|
||||
}
|
||||
|
||||
PRINTA("WARNING: Dimension `%1' in `%2', layer `%3' has unsupported type!", name, filename, layername);
|
||||
return Value();
|
||||
|
|
|
@ -440,12 +440,15 @@ public:
|
|||
unsigned int type;
|
||||
double coords[7][2];
|
||||
double angle;
|
||||
double length;
|
||||
QString name;
|
||||
Dim() {
|
||||
for (int i = 0; i < 7; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
coords[i][j] = 0;
|
||||
type = 0;
|
||||
angle = 0;
|
||||
length = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,10 @@
|
|||
dxf="testdata/dim-all.dxf";
|
||||
echo(linearX=dxf_dim(file=dxf, name="linearX"));
|
||||
echo(linearY=dxf_dim(file=dxf, name="linearY"));
|
||||
echo(aligned=dxf_dim(file=dxf, name="aligned"));
|
||||
echo(ordinateX=dxf_dim(file=dxf, name="ordinateX"));
|
||||
echo(ordinateY=dxf_dim(file=dxf, name="ordinateY"));
|
||||
echo(radius=dxf_dim(file=dxf, name="radius"));
|
||||
echo(diameter=dxf_dim(file=dxf, name="diameter"));
|
||||
echo(arc=dxf_dim(file=dxf, name="arc"));
|
||||
|
Loading…
Reference in New Issue