mirror of https://github.com/vitalif/openscad
Merge remote-tracking branch 'origin/master' into examples-cleanup
commit
9fd3aa5f17
|
@ -23,7 +23,7 @@
|
|||
"selection-foreground" : "#ffffff",
|
||||
"selection-background" : "#4a90d9",
|
||||
"margin-background" : "#272822",
|
||||
"margin-foreground" : "#e0e0e0",
|
||||
"margin-foreground" : "Gray",
|
||||
"matched-brace-background" : "#505050",
|
||||
"matched-brace-foreground" : "#ffffff",
|
||||
"unmatched-brace-background" : "#dc322f",
|
||||
|
@ -33,4 +33,4 @@
|
|||
"error-indicator-outline" : "#ff000000",
|
||||
"edge" : "#ffffff"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
"selection-foreground" : "#ffffff",
|
||||
"selection-background" : "#4a90d9",
|
||||
"margin-background" : "#f8f8f8",
|
||||
"margin-foreground" : "#000000",
|
||||
"margin-foreground" : "Gray",
|
||||
"matched-brace-background" : "#c7f6cb",
|
||||
"matched-brace-foreground" : "Blue",
|
||||
"unmatched-brace-background" : "#ffcdcc",
|
||||
|
@ -33,4 +33,4 @@
|
|||
"error-indicator-outline" : "#ff000000",
|
||||
"edge" : "#ffffff"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
"selection-foreground" : "#272822",
|
||||
"selection-background" : "#f8f8f2",
|
||||
"margin-background" : "#3e3d32",
|
||||
"margin-foreground" : "#f8f8f2",
|
||||
"margin-foreground" : "DarkGray",
|
||||
"matched-brace-background" : "#606060",
|
||||
"matched-brace-foreground" : "#ffff00",
|
||||
"unmatched-brace-background" : "#b06060",
|
||||
|
@ -33,4 +33,4 @@
|
|||
"error-indicator-outline" : "#ff000000",
|
||||
"edge" : "#ffffff"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,7 +498,6 @@ SOURCES += src/cgalutils.cc \
|
|||
src/CGALCache.cc \
|
||||
src/CGALRenderer.cc \
|
||||
src/CGAL_Nef_polyhedron.cc \
|
||||
src/CGAL_Nef_polyhedron_DxfData.cc \
|
||||
src/cgalworker.cc \
|
||||
src/Polygon2d-CGAL.cc
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "cgalutils.h"
|
||||
#include "printutils.h"
|
||||
#include "polyset.h"
|
||||
#include "svg.h"
|
||||
|
||||
CGAL_Nef_polyhedron::CGAL_Nef_polyhedron(CGAL_Nef_polyhedron3 *p)
|
||||
{
|
||||
|
@ -135,3 +136,26 @@ void CGAL_Nef_polyhedron::resize(Vector3d newsize,
|
|||
|
||||
this->transform(Transform3d(t));
|
||||
}
|
||||
|
||||
std::string CGAL_Nef_polyhedron::dump() const
|
||||
{
|
||||
return OpenSCAD::dump_svg( *this->p3 );
|
||||
}
|
||||
|
||||
|
||||
void CGAL_Nef_polyhedron::transform( const Transform3d &matrix )
|
||||
{
|
||||
if (!this->isEmpty()) {
|
||||
if (matrix.matrix().determinant() == 0) {
|
||||
PRINT("WARNING: Scaling a 3D object with 0 - removing object");
|
||||
this->reset();
|
||||
}
|
||||
else {
|
||||
CGAL_Aff_transformation t(
|
||||
matrix(0,0), matrix(0,1), matrix(0,2), matrix(0,3),
|
||||
matrix(1,0), matrix(1,1), matrix(1,2), matrix(1,3),
|
||||
matrix(2,0), matrix(2,1), matrix(2,2), matrix(2,3), matrix(3,3));
|
||||
this->p3->transform(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* OpenSCAD (www.openscad.org)
|
||||
* Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and
|
||||
* Marius Kintel <marius@kintel.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* As a special exception, you have permission to link this program
|
||||
* with the CGAL library and distribute executables, as long as you
|
||||
* follow the requirements of the GNU GPL in regard to all of the
|
||||
* software in the executable aside from CGAL.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dxfdata.h"
|
||||
#include "Polygon2d.h"
|
||||
#include "grid.h"
|
||||
#include "CGAL_Nef_polyhedron.h"
|
||||
#include "cgal.h"
|
||||
#include "cgalutils.h"
|
||||
#include <boost/variant.hpp>
|
||||
#include "polyset.h"
|
||||
#include "Tree.h"
|
||||
|
||||
#ifdef ENABLE_CGAL
|
||||
|
||||
std::string CGAL_Nef_polyhedron::dump() const
|
||||
{
|
||||
return OpenSCAD::dump_svg( *this->p3 );
|
||||
}
|
||||
|
||||
|
||||
void CGAL_Nef_polyhedron::transform( const Transform3d &matrix )
|
||||
{
|
||||
if (!this->isEmpty()) {
|
||||
if (matrix.matrix().determinant() == 0) {
|
||||
PRINT("WARNING: Scaling a 3D object with 0 - removing object");
|
||||
this->reset();
|
||||
}
|
||||
else {
|
||||
CGAL_Aff_transformation t(
|
||||
matrix(0,0), matrix(0,1), matrix(0,2), matrix(0,3),
|
||||
matrix(1,0), matrix(1,1), matrix(1,2), matrix(1,3),
|
||||
matrix(2,0), matrix(2,1), matrix(2,2), matrix(2,3), matrix(3,3));
|
||||
this->p3->transform(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ENABLE_CGAL
|
|
@ -117,6 +117,54 @@ static CGAL_Nef_polyhedron *createNefPolyhedronFromPolygon2d(const Polygon2d &po
|
|||
return createNefPolyhedronFromPolySet(*ps);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
ZRemover
|
||||
|
||||
This class converts one or more Nef3 polyhedra into a Nef2 polyhedron by
|
||||
stripping off the 'z' coordinates from the vertices. The resulting Nef2
|
||||
poly is accumulated in the 'output_nefpoly2d' member variable.
|
||||
|
||||
The 'z' coordinates will either be all 0s, for an xy-plane intersected Nef3,
|
||||
or, they will be a mixture of -eps and +eps, for a thin-box intersected Nef3.
|
||||
|
||||
Notes on CGAL's Nef Polyhedron2:
|
||||
|
||||
1. The 'mark' on a 2d Nef face is important when doing unions/intersections.
|
||||
If the 'mark' of a face is wrong the resulting nef2 poly will be unexpected.
|
||||
2. The 'mark' can be dependent on the points fed to the Nef2 constructor.
|
||||
This is why we iterate through the 3d faces using the halfedge cycle
|
||||
source()->target() instead of the ordinary source()->source(). The
|
||||
the latter can generate sequences of points that will fail the
|
||||
the CGAL::is_simple_2() test, resulting in improperly marked nef2 polys.
|
||||
3. 3d facets have 'two sides'. we throw out the 'down' side to prevent dups.
|
||||
|
||||
The class uses the 'visitor' pattern from the CGAL manual. See also
|
||||
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html
|
||||
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron3.html
|
||||
OGL_helper.h
|
||||
*/
|
||||
|
||||
class ZRemover {
|
||||
public:
|
||||
CGAL_Nef_polyhedron2::Boundary boundary;
|
||||
boost::shared_ptr<CGAL_Nef_polyhedron2> tmpnef2d;
|
||||
boost::shared_ptr<CGAL_Nef_polyhedron2> output_nefpoly2d;
|
||||
CGAL::Direction_3<CGAL_Kernel3> up;
|
||||
ZRemover()
|
||||
{
|
||||
output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() );
|
||||
boundary = CGAL_Nef_polyhedron2::INCLUDED;
|
||||
up = CGAL::Direction_3<CGAL_Kernel3>(0,0,1);
|
||||
}
|
||||
void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet );
|
||||
};
|
||||
|
||||
namespace CGALUtils {
|
||||
|
||||
bool applyHull(const Geometry::ChildList &children, PolySet &result)
|
||||
|
|
|
@ -40,54 +40,3 @@ namespace CGALUtils {
|
|||
std::vector<CGAL_Polygon_3> &triangles,
|
||||
CGAL::Plane_3<CGAL_Kernel3> &plane);
|
||||
};
|
||||
|
||||
#include "svg.h"
|
||||
#include "printutils.h"
|
||||
|
||||
/*
|
||||
|
||||
ZRemover
|
||||
|
||||
This class converts one or more Nef3 polyhedra into a Nef2 polyhedron by
|
||||
stripping off the 'z' coordinates from the vertices. The resulting Nef2
|
||||
poly is accumulated in the 'output_nefpoly2d' member variable.
|
||||
|
||||
The 'z' coordinates will either be all 0s, for an xy-plane intersected Nef3,
|
||||
or, they will be a mixture of -eps and +eps, for a thin-box intersected Nef3.
|
||||
|
||||
Notes on CGAL's Nef Polyhedron2:
|
||||
|
||||
1. The 'mark' on a 2d Nef face is important when doing unions/intersections.
|
||||
If the 'mark' of a face is wrong the resulting nef2 poly will be unexpected.
|
||||
2. The 'mark' can be dependent on the points fed to the Nef2 constructor.
|
||||
This is why we iterate through the 3d faces using the halfedge cycle
|
||||
source()->target() instead of the ordinary source()->source(). The
|
||||
the latter can generate sequences of points that will fail the
|
||||
the CGAL::is_simple_2() test, resulting in improperly marked nef2 polys.
|
||||
3. 3d facets have 'two sides'. we throw out the 'down' side to prevent dups.
|
||||
|
||||
The class uses the 'visitor' pattern from the CGAL manual. See also
|
||||
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html
|
||||
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron3.html
|
||||
OGL_helper.h
|
||||
*/
|
||||
|
||||
class ZRemover {
|
||||
public:
|
||||
CGAL_Nef_polyhedron2::Boundary boundary;
|
||||
boost::shared_ptr<CGAL_Nef_polyhedron2> tmpnef2d;
|
||||
boost::shared_ptr<CGAL_Nef_polyhedron2> output_nefpoly2d;
|
||||
CGAL::Direction_3<CGAL_Kernel3> up;
|
||||
ZRemover()
|
||||
{
|
||||
output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() );
|
||||
boundary = CGAL_Nef_polyhedron2::INCLUDED;
|
||||
up = CGAL::Direction_3<CGAL_Kernel3>(0,0,1);
|
||||
}
|
||||
void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {}
|
||||
void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet );
|
||||
};
|
||||
|
|
|
@ -344,17 +344,15 @@ void ScintillaEditor::noColor()
|
|||
qsci->setIndicatorOutlineColor(QColor(0, 0, 0, 255), indicatorNumber); // only alpha part is used
|
||||
qsci->setCaretLineBackgroundColor(Qt::white);
|
||||
qsci->setWhitespaceForegroundColor(Qt::black);
|
||||
qsci->setMarginsBackgroundColor(Qt::white);
|
||||
qsci->setMarginsForegroundColor(Qt::black);
|
||||
qsci->setSelectionForegroundColor(Qt::white);
|
||||
qsci->setSelectionBackgroundColor(Qt::black);
|
||||
qsci->setMatchedBraceBackgroundColor(Qt::white);
|
||||
qsci->setSelectionForegroundColor(Qt::black);
|
||||
qsci->setSelectionBackgroundColor(QColor("LightSkyBlue"));
|
||||
qsci->setMatchedBraceBackgroundColor(QColor("LightBlue"));
|
||||
qsci->setMatchedBraceForegroundColor(Qt::black);
|
||||
qsci->setUnmatchedBraceBackgroundColor(Qt::white);
|
||||
qsci->setUnmatchedBraceBackgroundColor(QColor("pink"));
|
||||
qsci->setUnmatchedBraceForegroundColor(Qt::black);
|
||||
qsci->setMarginsBackgroundColor(Qt::lightGray);
|
||||
qsci->setMarginsForegroundColor(Qt::black);
|
||||
qsci->setFoldMarginColors(Qt::lightGray, Qt::lightGray);
|
||||
qsci->setMarginsBackgroundColor(QColor("whiteSmoke"));
|
||||
qsci->setMarginsForegroundColor(QColor("gray"));
|
||||
qsci->setFoldMarginColors(QColor("whiteSmoke"), QColor("whiteSmoke"));
|
||||
qsci->setEdgeColor(Qt::black);
|
||||
}
|
||||
|
||||
|
@ -471,10 +469,10 @@ void ScintillaEditor::zoomOut()
|
|||
|
||||
void ScintillaEditor::initFont(const QString& fontName, uint size)
|
||||
{
|
||||
QFont font(fontName, size);
|
||||
font.setFixedPitch(true);
|
||||
lexer->setFont(font);
|
||||
qsci->setMarginsFont(font);
|
||||
this->currentFont = QFont(fontName, size);
|
||||
this->currentFont.setFixedPitch(true);
|
||||
lexer->setFont(this->currentFont);
|
||||
qsci->setMarginsFont(this->currentFont);
|
||||
onTextChanged(); // Update margin width
|
||||
}
|
||||
|
||||
|
@ -486,8 +484,8 @@ void ScintillaEditor::initMargin()
|
|||
|
||||
void ScintillaEditor::onTextChanged()
|
||||
{
|
||||
QFontMetrics fontmetrics = qsci->fontMetrics();
|
||||
qsci->setMarginWidth(1, fontmetrics.width(QString::number(qsci->lines())) + 6);
|
||||
QFontMetrics fontmetrics(this->currentFont);
|
||||
qsci->setMarginWidth(1, QString(trunc(log10(qsci->lines())+2), '0'));
|
||||
}
|
||||
|
||||
bool ScintillaEditor::find(const QString &expr, bool findNext, bool findBackwards)
|
||||
|
|
|
@ -94,4 +94,5 @@ private:
|
|||
static const int indicatorNumber = 8; // first 8 are used by lexers
|
||||
static const int markerNumber = 2;
|
||||
ScadLexer *lexer;
|
||||
QFont currentFont;
|
||||
};
|
||||
|
|
|
@ -168,12 +168,16 @@ AbstractNode *TransformModule::instantiate(const Context *ctx, const ModuleInsta
|
|||
{
|
||||
ValuePtr v = c.lookup_variable("m");
|
||||
if (v->type() == Value::VECTOR) {
|
||||
Matrix4d rawmatrix = Matrix4d::Identity();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
size_t x = i / 4, y = i % 4;
|
||||
if (y < v->toVector().size() && v->toVector()[y].type() ==
|
||||
Value::VECTOR && x < v->toVector()[y].toVector().size())
|
||||
v->toVector()[y].toVector()[x].getDouble(node->matrix(y, x));
|
||||
v->toVector()[y].toVector()[x].getDouble(rawmatrix(y, x));
|
||||
}
|
||||
double w = rawmatrix(3,3);
|
||||
if (w != 1.0) node->matrix = rawmatrix / w;
|
||||
else node->matrix = rawmatrix;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,8 @@ multmatrix([[1,0.4,0.1,-25],
|
|||
[0.4,0.8,0,-25],
|
||||
[0.2,0.2,0.5,0],
|
||||
[0,0,0,1]]) mycyl();
|
||||
translate([-25,-40,0])
|
||||
multmatrix([[1,0,0,0],
|
||||
[0,1,0,0],
|
||||
[0,0,1,0],
|
||||
[0,0,0,2]]) mycyl();
|
||||
|
|
|
@ -694,7 +694,6 @@ set(CGAL_SOURCES
|
|||
../src/cgalutils-tess.cc
|
||||
../src/cgalutils-polyhedron.cc
|
||||
../src/CGALCache.cc
|
||||
../src/CGAL_Nef_polyhedron_DxfData.cc
|
||||
../src/Polygon2d-CGAL.cc
|
||||
../src/svg.cc
|
||||
../src/GeometryEvaluator.cc)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 16 KiB |
|
@ -42,4 +42,11 @@ group() {
|
|||
cylinder($fn = 0, $fa = 12, $fs = 2, h = 20, r1 = 10, r2 = 0, center = false);
|
||||
}
|
||||
}
|
||||
multmatrix([[1, 0, 0, -25], [0, 1, 0, -40], [0, 0, 1, 0], [0, 0, 0, 1]]) {
|
||||
multmatrix([[0.5, 0, 0, 0], [0, 0.5, 0, 0], [0, 0, 0.5, 0], [0, 0, 0, 1]]) {
|
||||
group() {
|
||||
cylinder($fn = 0, $fa = 12, $fs = 2, h = 20, r1 = 10, r2 = 0, center = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue