mirror of https://github.com/vitalif/openscad
Merge remote-tracking branch 'origin/epec-kernel'
commit
1c719371cc
|
@ -8,6 +8,7 @@
|
||||||
#
|
#
|
||||||
# Usage: macosx-build-dependencies.sh [-6lcd]
|
# Usage: macosx-build-dependencies.sh [-6lcd]
|
||||||
# -6 Build only 64-bit binaries
|
# -6 Build only 64-bit binaries
|
||||||
|
# -c Force use of LLVM compiler
|
||||||
# -l Force use of LLVM compiler
|
# -l Force use of LLVM compiler
|
||||||
# -c Force use of clang compiler
|
# -c Force use of clang compiler
|
||||||
# -d Build for deployment (if not specified, e.g. Sparkle won't be built)
|
# -d Build for deployment (if not specified, e.g. Sparkle won't be built)
|
||||||
|
@ -17,14 +18,15 @@
|
||||||
#
|
#
|
||||||
# FIXME:
|
# FIXME:
|
||||||
# o Verbose option
|
# o Verbose option
|
||||||
|
# o Force rebuild vs. only rebuild changes
|
||||||
#
|
#
|
||||||
|
|
||||||
BASEDIR=$PWD/../libraries
|
BASEDIR=$PWD/../libraries
|
||||||
OPENSCADDIR=$PWD
|
OPENSCADDIR=$PWD
|
||||||
SRCDIR=$BASEDIR/src
|
SRCDIR=$BASEDIR/src
|
||||||
DEPLOYDIR=$BASEDIR/install
|
DEPLOYDIR=$BASEDIR/install
|
||||||
MAC_OSX_VERSION_MIN=10.5
|
MAC_OSX_VERSION_MIN=10.6
|
||||||
OPTION_32BIT=true
|
OPTION_32BIT=false
|
||||||
OPTION_LLVM=false
|
OPTION_LLVM=false
|
||||||
OPTION_CLANG=false
|
OPTION_CLANG=false
|
||||||
OPTION_GCC=false
|
OPTION_GCC=false
|
||||||
|
@ -53,14 +55,15 @@ build_qt()
|
||||||
fi
|
fi
|
||||||
tar xzf qt-everywhere-opensource-src-$version.tar.gz
|
tar xzf qt-everywhere-opensource-src-$version.tar.gz
|
||||||
cd qt-everywhere-opensource-src-$version
|
cd qt-everywhere-opensource-src-$version
|
||||||
if $OPTION_CLANG; then
|
if $USING_CLANG; then
|
||||||
# FIX for clang
|
# FIX for clang
|
||||||
sed -i "" -e "s/::TabletProximityRec/TabletProximityRec/g" src/gui/kernel/qt_cocoa_helpers_mac_p.h
|
sed -i "" -e "s/::TabletProximityRec/TabletProximityRec/g" src/gui/kernel/qt_cocoa_helpers_mac_p.h
|
||||||
|
PLATFORM="-platform unsupported/macx-clang"
|
||||||
fi
|
fi
|
||||||
if $OPTION_32BIT; then
|
if $OPTION_32BIT; then
|
||||||
QT_32BIT="-arch x86"
|
QT_32BIT="-arch x86"
|
||||||
fi
|
fi
|
||||||
./configure -prefix $DEPLOYDIR -release $QT_32BIT -arch x86_64 -opensource -confirm-license -fast -no-qt3support -no-svg -no-phonon -no-audio-backend -no-multimedia -no-javascript-jit -no-script -no-scripttools -no-declarative -no-xmlpatterns -nomake demos -nomake examples -nomake docs -nomake translations -no-webkit
|
./configure -prefix $DEPLOYDIR -release $QT_32BIT -arch x86_64 -opensource -confirm-license $PLATFORM -fast -no-qt3support -no-svg -no-phonon -no-audio-backend -no-multimedia -no-javascript-jit -no-script -no-scripttools -no-declarative -no-xmlpatterns -nomake demos -nomake examples -nomake docs -nomake translations -no-webkit
|
||||||
make -j6 install
|
make -j6 install
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,10 +214,10 @@ build_boost()
|
||||||
if $OPTION_32BIT; then
|
if $OPTION_32BIT; then
|
||||||
BOOST_EXTRA_FLAGS="-arch i386"
|
BOOST_EXTRA_FLAGS="-arch i386"
|
||||||
fi
|
fi
|
||||||
if $OPTION_LLVM; then
|
if $USING_LLVM; then
|
||||||
BOOST_TOOLSET="toolset=darwin-llvm"
|
BOOST_TOOLSET="toolset=darwin-llvm"
|
||||||
echo "using darwin : llvm : llvm-g++ ;" >> tools/build/v2/user-config.jam
|
echo "using darwin : llvm : llvm-g++ ;" >> tools/build/v2/user-config.jam
|
||||||
elif $OPTION_CLANG; then
|
elif $USING_CLANG; then
|
||||||
BOOST_TOOLSET="toolset=clang"
|
BOOST_TOOLSET="toolset=clang"
|
||||||
echo "using clang ;" >> tools/build/v2/user-config.jam
|
echo "using clang ;" >> tools/build/v2/user-config.jam
|
||||||
fi
|
fi
|
||||||
|
@ -377,7 +380,7 @@ OSX_VERSION=`sw_vers -productVersion | cut -d. -f2`
|
||||||
if (( $OSX_VERSION >= 8 )); then
|
if (( $OSX_VERSION >= 8 )); then
|
||||||
echo "Detected Mountain Lion (10.8) or later"
|
echo "Detected Mountain Lion (10.8) or later"
|
||||||
elif (( $OSX_VERSION >= 7 )); then
|
elif (( $OSX_VERSION >= 7 )); then
|
||||||
echo "Detected Lion (10.7) or later"
|
echo "Detected Lion (10.7)"
|
||||||
else
|
else
|
||||||
echo "Detected Snow Leopard (10.6) or earlier"
|
echo "Detected Snow Leopard (10.6) or earlier"
|
||||||
fi
|
fi
|
||||||
|
@ -392,7 +395,7 @@ elif $OPTION_GCC; then
|
||||||
elif $OPTION_CLANG; then
|
elif $OPTION_CLANG; then
|
||||||
USING_CLANG=true
|
USING_CLANG=true
|
||||||
elif (( $OSX_VERSION >= 7 )); then
|
elif (( $OSX_VERSION >= 7 )); then
|
||||||
USING_GCC=true
|
USING_CLANG=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $USING_LLVM; then
|
if $USING_LLVM; then
|
||||||
|
@ -415,16 +418,11 @@ elif $USING_CLANG; then
|
||||||
export QMAKESPEC=unsupported/macx-clang
|
export QMAKESPEC=unsupported/macx-clang
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( $OSX_VERSION >= 8 )); then
|
echo "Building for $MAC_OSX_VERSION_MIN or later"
|
||||||
echo "Setting build target to 10.6 or later"
|
|
||||||
MAC_OSX_VERSION_MIN=10.6
|
|
||||||
else
|
|
||||||
echo "Setting build target to 10.5 or later"
|
|
||||||
MAC_OSX_VERSION_MIN=10.5
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $OPTION_DEPLOY; then
|
if $OPTION_DEPLOY; then
|
||||||
echo "Building deployment version of libraries"
|
echo "Building deployment version of libraries"
|
||||||
|
OPTION_32BIT=true
|
||||||
else
|
else
|
||||||
OPTION_32BIT=false
|
OPTION_32BIT=false
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export OPENSCAD_LIBRARIES=$PWD/../libraries/install
|
export OPENSCAD_LIBRARIES=$PWD/../libraries/install
|
||||||
export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib
|
export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib
|
||||||
export DYLD_FRAMEWORK_PATH=$OPENSCAD_LIBRARIES/lib
|
export DYLD_FRAMEWORK_PATH=$OPENSCAD_LIBRARIES/lib
|
||||||
export QMAKESPEC=macx-g++
|
#export QMAKESPEC=macx-g++
|
||||||
|
|
||||||
#export OPENCSGDIR=$PWD/../OpenCSG-1.3.0
|
#export OPENCSGDIR=$PWD/../OpenCSG-1.3.0
|
||||||
#export CGALDIR=$PWD/../install/CGAL-3.6
|
#export CGALDIR=$PWD/../install/CGAL-3.6
|
||||||
|
|
|
@ -15,7 +15,7 @@ OSErr eventHandler(const AppleEvent *, AppleEvent *, SRefCon )
|
||||||
if (mainwin) break;
|
if (mainwin) break;
|
||||||
}
|
}
|
||||||
if (mainwin) {
|
if (mainwin) {
|
||||||
mainwin->actionReloadCompile();
|
mainwin->actionReloadRenderCSG();
|
||||||
}
|
}
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,30 +202,31 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node)
|
||||||
if ( N.dim == 2 ) {
|
if ( N.dim == 2 ) {
|
||||||
CGAL_Iso_rectangle_2e bbox = bounding_box( *N.p2 );
|
CGAL_Iso_rectangle_2e bbox = bounding_box( *N.p2 );
|
||||||
CGAL_Point_2e min2(bbox.min()), max2(bbox.max());
|
CGAL_Point_2e min2(bbox.min()), max2(bbox.max());
|
||||||
CGAL_Point_3 min3(min2.x(),min2.y(),0), max3(max2.x(),max2.y(),0);
|
CGAL_Point_3 min3(CGAL::to_double(min2.x()), CGAL::to_double(min2.y()), 0),
|
||||||
|
max3(CGAL::to_double(max2.x()), CGAL::to_double(max2.y()), 0);
|
||||||
bb = CGAL_Iso_cuboid_3( min3, max3 );
|
bb = CGAL_Iso_cuboid_3( min3, max3 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bb = bounding_box( *N.p3 );
|
bb = bounding_box( *N.p3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<NT> scale, bbox_size;
|
std::vector<NT3> scale, bbox_size;
|
||||||
for (int i=0;i<3;i++) scale.push_back( NT(1) );
|
for (int i=0;i<3;i++) scale.push_back( NT3(1) );
|
||||||
bbox_size.push_back( bb.xmax()-bb.xmin() );
|
bbox_size.push_back( bb.xmax()-bb.xmin() );
|
||||||
bbox_size.push_back( bb.ymax()-bb.ymin() );
|
bbox_size.push_back( bb.ymax()-bb.ymin() );
|
||||||
bbox_size.push_back( bb.zmax()-bb.zmin() );
|
bbox_size.push_back( bb.zmax()-bb.zmin() );
|
||||||
for (int i=0;i<3;i++) {
|
for (int i=0;i<3;i++) {
|
||||||
if (node.newsize[i]) {
|
if (node.newsize[i]) {
|
||||||
if (bbox_size[i]==NT(0)) {
|
if (bbox_size[i]==NT3(0)) {
|
||||||
PRINT("WARNING: Cannot resize in direction normal to flat object");
|
PRINT("WARNING: Cannot resize in direction normal to flat object");
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scale[i] = NT(node.newsize[i]) / bbox_size[i];
|
scale[i] = NT3(node.newsize[i]) / bbox_size[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NT autoscale = std::max( scale[0], std::max( scale[1], scale[2] ));
|
NT3 autoscale = std::max( scale[0], std::max( scale[1], scale[2] ));
|
||||||
for (int i=0;i<3;i++) {
|
for (int i=0;i<3;i++) {
|
||||||
if (node.autosize[i]) scale[i] = autoscale;
|
if (node.autosize[i]) scale[i] = autoscale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CGAL_NEF_POLYHEDRON_H_
|
#ifndef CGAL_NEF_POLYHEDRON_H_
|
||||||
#define CGAL_NEF_POLYHEDRON_H_
|
#define CGAL_NEF_POLYHEDRON_H_
|
||||||
|
|
||||||
#include "cgalfwd.h"
|
#include "cgal.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "linalg.h"
|
#include "linalg.h"
|
||||||
|
|
|
@ -115,6 +115,7 @@ Response CSGTermEvaluator::visit(State &state, const AbstractPolyNode &node)
|
||||||
if (ps) {
|
if (ps) {
|
||||||
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
|
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
|
||||||
ps, node.modinst, node);
|
ps, node.modinst, node);
|
||||||
|
node.progress_report();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->stored_term[node.index()] = t1;
|
this->stored_term[node.index()] = t1;
|
||||||
|
@ -178,6 +179,7 @@ Response CSGTermEvaluator::visit(State &state, const RenderNode &node)
|
||||||
shared_ptr<PolySet> ps;
|
shared_ptr<PolySet> ps;
|
||||||
if (this->psevaluator) {
|
if (this->psevaluator) {
|
||||||
ps = this->psevaluator->getPolySet(node, true);
|
ps = this->psevaluator->getPolySet(node, true);
|
||||||
|
node.progress_report();
|
||||||
}
|
}
|
||||||
if (ps) {
|
if (ps) {
|
||||||
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
|
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
|
||||||
|
@ -201,6 +203,7 @@ Response CSGTermEvaluator::visit(State &state, const CgaladvNode &node)
|
||||||
if (ps) {
|
if (ps) {
|
||||||
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
|
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
|
||||||
ps, node.modinst, node);
|
ps, node.modinst, node);
|
||||||
|
node.progress_report();
|
||||||
}
|
}
|
||||||
this->stored_term[node.index()] = t1;
|
this->stored_term[node.index()] = t1;
|
||||||
addToParent(state, node);
|
addToParent(state, node);
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
|
|
||||||
QTimer *autoReloadTimer;
|
QTimer *autoReloadTimer;
|
||||||
std::string autoReloadId;
|
std::string autoReloadId;
|
||||||
|
QTimer *waitAfterReloadTimer;
|
||||||
|
|
||||||
ModuleContext top_ctx;
|
ModuleContext top_ctx;
|
||||||
FileModule *root_module; // Result of parsing
|
FileModule *root_module; // Result of parsing
|
||||||
|
@ -76,8 +77,8 @@ private:
|
||||||
void refreshDocument();
|
void refreshDocument();
|
||||||
void updateTemporalVariables();
|
void updateTemporalVariables();
|
||||||
bool fileChangedOnDisk();
|
bool fileChangedOnDisk();
|
||||||
bool compileTopLevelDocument(bool reload);
|
void compileTopLevelDocument();
|
||||||
bool compile(bool reload, bool procevents);
|
void compile(bool reload, bool forcedone = false);
|
||||||
void compileCSG(bool procevents);
|
void compileCSG(bool procevents);
|
||||||
bool maybeSave();
|
bool maybeSave();
|
||||||
bool checkEditorModified();
|
bool checkEditorModified();
|
||||||
|
@ -102,6 +103,10 @@ private slots:
|
||||||
void actionReload();
|
void actionReload();
|
||||||
void actionShowLibraryFolder();
|
void actionShowLibraryFolder();
|
||||||
|
|
||||||
|
void instantiateRoot();
|
||||||
|
void compileDone(bool didchange);
|
||||||
|
void compileEnded();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void pasteViewportTranslation();
|
void pasteViewportTranslation();
|
||||||
void pasteViewportRotation();
|
void pasteViewportRotation();
|
||||||
|
@ -109,10 +114,13 @@ private slots:
|
||||||
void preferences();
|
void preferences();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void actionCompile();
|
void actionRenderCSG();
|
||||||
|
void csgRender();
|
||||||
|
void csgReloadRender();
|
||||||
#ifdef ENABLE_CGAL
|
#ifdef ENABLE_CGAL
|
||||||
void actionRenderCGAL();
|
void actionRenderCGAL();
|
||||||
void actionRenderCGALDone(class CGAL_Nef_polyhedron *);
|
void actionRenderCGALDone(class CGAL_Nef_polyhedron *);
|
||||||
|
void cgalRender();
|
||||||
#endif
|
#endif
|
||||||
void actionDisplayAST();
|
void actionDisplayAST();
|
||||||
void actionDisplayCSGTree();
|
void actionDisplayCSGTree();
|
||||||
|
@ -131,6 +139,7 @@ public:
|
||||||
void clearCurrentOutput();
|
void clearCurrentOutput();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void actionReloadRenderCSG();
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
void viewModeOpenCSG();
|
void viewModeOpenCSG();
|
||||||
#endif
|
#endif
|
||||||
|
@ -163,13 +172,16 @@ public slots:
|
||||||
void helpManual();
|
void helpManual();
|
||||||
void helpLibrary();
|
void helpLibrary();
|
||||||
void quit();
|
void quit();
|
||||||
void actionReloadCompile();
|
|
||||||
void checkAutoReload();
|
void checkAutoReload();
|
||||||
|
void waitAfterReload();
|
||||||
void autoReloadSet(bool);
|
void autoReloadSet(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void report_func(const class AbstractNode*, void *vp, int mark);
|
static void report_func(const class AbstractNode*, void *vp, int mark);
|
||||||
|
|
||||||
|
char const * afterCompileSlot;
|
||||||
|
bool procevents;
|
||||||
|
|
||||||
class ProgressWidget *progresswidget;
|
class ProgressWidget *progresswidget;
|
||||||
class CGALWorker *cgalworker;
|
class CGALWorker *cgalworker;
|
||||||
QMutex consolemutex;
|
QMutex consolemutex;
|
||||||
|
|
|
@ -53,7 +53,6 @@ FileModule *ModuleCache::evaluate(const std::string &filename)
|
||||||
if (lib_mod) {
|
if (lib_mod) {
|
||||||
if (this->entries[filename].cache_id == cache_id) {
|
if (this->entries[filename].cache_id == cache_id) {
|
||||||
shouldCompile = false;
|
shouldCompile = false;
|
||||||
|
|
||||||
if (lib_mod->includesChanged()) {
|
if (lib_mod->includesChanged()) {
|
||||||
lib_mod = NULL;
|
lib_mod = NULL;
|
||||||
shouldCompile = true;
|
shouldCompile = true;
|
||||||
|
|
10
src/cgal.h
10
src/cgal.h
|
@ -39,8 +39,8 @@ using boost::uintmax_t;
|
||||||
#include <CGAL/assertions_behaviour.h>
|
#include <CGAL/assertions_behaviour.h>
|
||||||
#include <CGAL/exceptions.h>
|
#include <CGAL/exceptions.h>
|
||||||
|
|
||||||
typedef CGAL::Gmpq NT;
|
typedef CGAL::Gmpq NT2;
|
||||||
typedef CGAL::Extended_cartesian<NT> CGAL_Kernel2;
|
typedef CGAL::Extended_cartesian<NT2> CGAL_Kernel2;
|
||||||
typedef CGAL::Nef_polyhedron_2<CGAL_Kernel2> CGAL_Nef_polyhedron2;
|
typedef CGAL::Nef_polyhedron_2<CGAL_Kernel2> CGAL_Nef_polyhedron2;
|
||||||
typedef CGAL_Kernel2::Aff_transformation_2 CGAL_Aff_transformation2;
|
typedef CGAL_Kernel2::Aff_transformation_2 CGAL_Aff_transformation2;
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_ExactKernel2;
|
||||||
typedef CGAL::Polygon_2<CGAL_ExactKernel2> CGAL_Poly2;
|
typedef CGAL::Polygon_2<CGAL_ExactKernel2> CGAL_Poly2;
|
||||||
typedef CGAL::Polygon_with_holes_2<CGAL_ExactKernel2> CGAL_Poly2h;
|
typedef CGAL::Polygon_with_holes_2<CGAL_ExactKernel2> CGAL_Poly2h;
|
||||||
|
|
||||||
typedef CGAL::Cartesian<NT> CGAL_Kernel3;
|
//typedef CGAL::Cartesian<NT> CGAL_Kernel3;
|
||||||
|
typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_Kernel3;
|
||||||
|
typedef CGAL::Exact_predicates_exact_constructions_kernel::FT NT3;
|
||||||
typedef CGAL::Nef_polyhedron_3<CGAL_Kernel3> CGAL_Nef_polyhedron3;
|
typedef CGAL::Nef_polyhedron_3<CGAL_Kernel3> CGAL_Nef_polyhedron3;
|
||||||
typedef CGAL_Nef_polyhedron3::Aff_transformation_3 CGAL_Aff_transformation;
|
typedef CGAL_Nef_polyhedron3::Aff_transformation_3 CGAL_Aff_transformation;
|
||||||
|
|
||||||
|
@ -63,7 +65,7 @@ typedef CGAL::Iso_cuboid_3<CGAL_Kernel3> CGAL_Iso_cuboid_3;
|
||||||
// CGAL_Nef_polyhedron2::Explorer::Point which is different than
|
// CGAL_Nef_polyhedron2::Explorer::Point which is different than
|
||||||
// CGAL_Kernel2::Point. Hence the suffix 'e'
|
// CGAL_Kernel2::Point. Hence the suffix 'e'
|
||||||
typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2e;
|
typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2e;
|
||||||
typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian<NT> > CGAL_Iso_rectangle_2e;
|
typedef CGAL::Iso_rectangle_2<CGAL::Simple_cartesian<NT2> > CGAL_Iso_rectangle_2e;
|
||||||
|
|
||||||
|
|
||||||
#ifdef PREV_NDEBUG
|
#ifdef PREV_NDEBUG
|
||||||
|
|
|
@ -193,7 +193,8 @@ void ZRemover::visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet )
|
||||||
std::vector<CGAL_Nef_polyhedron2::Explorer::Point> contour;
|
std::vector<CGAL_Nef_polyhedron2::Explorer::Point> contour;
|
||||||
CGAL_For_all( c1, cend ) {
|
CGAL_For_all( c1, cend ) {
|
||||||
CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point();
|
CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point();
|
||||||
CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() );
|
CGAL_Nef_polyhedron2::Explorer::Point point2d(CGAL::to_double(point3d.x()),
|
||||||
|
CGAL::to_double(point3d.y()));
|
||||||
contour.push_back( point2d );
|
contour.push_back( point2d );
|
||||||
}
|
}
|
||||||
if (contour.size()==0) continue;
|
if (contour.size()==0) continue;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CGALUTILS_H_
|
#ifndef CGALUTILS_H_
|
||||||
#define CGALUTILS_H_
|
#define CGALUTILS_H_
|
||||||
|
|
||||||
#include <cgalfwd.h>
|
#include <cgal.h>
|
||||||
class PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p);
|
class PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p);
|
||||||
CGAL_Polyhedron *createPolyhedronFromPolySet(const class PolySet &ps);
|
CGAL_Polyhedron *createPolyhedronFromPolySet(const class PolySet &ps);
|
||||||
CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N );
|
CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N );
|
||||||
|
|
|
@ -100,7 +100,7 @@ E [Ee][+-]?{D}+
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
include[ \t\r\n>]*"<" { BEGIN(cond_include); filepath = filename = "";}
|
include[ \t\r\n>]*"<" { BEGIN(cond_include); filepath = filename = ""; }
|
||||||
<cond_include>{
|
<cond_include>{
|
||||||
[^\t\r\n>]*"/" { filepath = yytext; }
|
[^\t\r\n>]*"/" { filepath = yytext; }
|
||||||
[^\t\r\n>/]+ { filename = yytext; }
|
[^\t\r\n>/]+ { filename = yytext; }
|
||||||
|
|
252
src/mainwin.cc
252
src/mainwin.cc
|
@ -206,9 +206,15 @@ MainWindow::MainWindow(const QString &filename)
|
||||||
|
|
||||||
autoReloadTimer = new QTimer(this);
|
autoReloadTimer = new QTimer(this);
|
||||||
autoReloadTimer->setSingleShot(false);
|
autoReloadTimer->setSingleShot(false);
|
||||||
|
autoReloadTimer->setInterval(200);
|
||||||
connect(autoReloadTimer, SIGNAL(timeout()), this, SLOT(checkAutoReload()));
|
connect(autoReloadTimer, SIGNAL(timeout()), this, SLOT(checkAutoReload()));
|
||||||
|
|
||||||
connect(this->e_tval, SIGNAL(textChanged(QString)), this, SLOT(actionCompile()));
|
waitAfterReloadTimer = new QTimer(this);
|
||||||
|
waitAfterReloadTimer->setSingleShot(true);
|
||||||
|
waitAfterReloadTimer->setInterval(200);
|
||||||
|
connect(waitAfterReloadTimer, SIGNAL(timeout()), this, SLOT(waitAfterReload()));
|
||||||
|
|
||||||
|
connect(this->e_tval, SIGNAL(textChanged(QString)), this, SLOT(actionRenderCSG()));
|
||||||
connect(this->e_fps, SIGNAL(textChanged(QString)), this, SLOT(updatedFps()));
|
connect(this->e_fps, SIGNAL(textChanged(QString)), this, SLOT(updatedFps()));
|
||||||
|
|
||||||
animate_panel->hide();
|
animate_panel->hide();
|
||||||
|
@ -288,8 +294,8 @@ MainWindow::MainWindow(const QString &filename)
|
||||||
|
|
||||||
// Design menu
|
// Design menu
|
||||||
connect(this->designActionAutoReload, SIGNAL(toggled(bool)), this, SLOT(autoReloadSet(bool)));
|
connect(this->designActionAutoReload, SIGNAL(toggled(bool)), this, SLOT(autoReloadSet(bool)));
|
||||||
connect(this->designActionReloadAndCompile, SIGNAL(triggered()), this, SLOT(actionReloadCompile()));
|
connect(this->designActionReloadAndCompile, SIGNAL(triggered()), this, SLOT(actionReloadRenderCSG()));
|
||||||
connect(this->designActionCompile, SIGNAL(triggered()), this, SLOT(actionCompile()));
|
connect(this->designActionCompile, SIGNAL(triggered()), this, SLOT(actionRenderCSG()));
|
||||||
#ifdef ENABLE_CGAL
|
#ifdef ENABLE_CGAL
|
||||||
connect(this->designActionCompileAndRender, SIGNAL(triggered()), this, SLOT(actionRenderCGAL()));
|
connect(this->designActionCompileAndRender, SIGNAL(triggered()), this, SLOT(actionRenderCGAL()));
|
||||||
#else
|
#else
|
||||||
|
@ -580,7 +586,7 @@ void MainWindow::updateTVal()
|
||||||
double fps = this->e_fps->text().toDouble(&fps_ok);
|
double fps = this->e_fps->text().toDouble(&fps_ok);
|
||||||
if (fps_ok) {
|
if (fps_ok) {
|
||||||
if (fps <= 0) {
|
if (fps <= 0) {
|
||||||
actionCompile();
|
actionRenderCSG();
|
||||||
} else {
|
} else {
|
||||||
double s = this->e_fsteps->text().toDouble();
|
double s = this->e_fsteps->text().toDouble();
|
||||||
double t = this->e_tval->text().toDouble() + 1/s;
|
double t = this->e_tval->text().toDouble() + 1/s;
|
||||||
|
@ -612,14 +618,96 @@ void MainWindow::refreshDocument()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Parse and evaluate the design => this->root_node
|
compiles the design. Calls compileDone() if anything was compiled
|
||||||
|
|
||||||
Returns true if something was compiled, false if nothing was changed
|
|
||||||
and the root_node was left untouched.
|
|
||||||
*/
|
*/
|
||||||
bool MainWindow::compile(bool reload, bool procevents)
|
void MainWindow::compile(bool reload, bool forcedone)
|
||||||
{
|
{
|
||||||
if (!compileTopLevelDocument(reload)) return false;
|
bool shouldcompiletoplevel = false;
|
||||||
|
bool didcompile = false;
|
||||||
|
|
||||||
|
// Reload checks the timestamp of the toplevel file and refreshes if necessary,
|
||||||
|
if (reload) {
|
||||||
|
// Refresh files if it has changed on disk
|
||||||
|
if (fileChangedOnDisk() && checkEditorModified()) {
|
||||||
|
shouldcompiletoplevel = true;
|
||||||
|
refreshDocument();
|
||||||
|
}
|
||||||
|
// If the file hasn't changed, we might still need to compile it
|
||||||
|
// if we haven't yet compiled the current text.
|
||||||
|
else {
|
||||||
|
QString current_doc = editor->toPlainText();
|
||||||
|
if (current_doc != last_compiled_doc) shouldcompiletoplevel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
shouldcompiletoplevel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldcompiletoplevel && this->root_module && this->root_module->includesChanged()) {
|
||||||
|
shouldcompiletoplevel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldcompiletoplevel) {
|
||||||
|
console->clear();
|
||||||
|
compileTopLevelDocument();
|
||||||
|
didcompile = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->root_module) {
|
||||||
|
if (this->root_module->handleDependencies()) {
|
||||||
|
PRINTB("Module cache size: %d modules", ModuleCache::instance()->size());
|
||||||
|
didcompile = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're auto-reloading, listen for a cascade of changes by starting a timer
|
||||||
|
// if something changed _and_ there are any external dependencies
|
||||||
|
if (reload && didcompile && this->root_module) {
|
||||||
|
if (this->root_module->hasIncludes() ||
|
||||||
|
this->root_module->usesLibraries()) {
|
||||||
|
this->waitAfterReloadTimer->start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileDone(didcompile | forcedone);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::waitAfterReload()
|
||||||
|
{
|
||||||
|
if (this->root_module->handleDependencies()) {
|
||||||
|
this->waitAfterReloadTimer->start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
compile(true, true); // In case file itself or top-level includes changed during dependency updates
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::compileDone(bool didchange)
|
||||||
|
{
|
||||||
|
const char *callslot;
|
||||||
|
if (didchange) {
|
||||||
|
instantiateRoot();
|
||||||
|
callslot = afterCompileSlot;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
callslot = "compileEnded";
|
||||||
|
}
|
||||||
|
|
||||||
|
this->procevents = false;
|
||||||
|
QMetaObject::invokeMethod(this, callslot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::compileEnded()
|
||||||
|
{
|
||||||
|
clearCurrentOutput();
|
||||||
|
GuiLocker::unlock();
|
||||||
|
if (designActionAutoReload->isChecked()) autoReloadTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::instantiateRoot()
|
||||||
|
{
|
||||||
|
// Go on and instantiate root_node, then call the continuation slot
|
||||||
|
|
||||||
// Invalidate renderers before we kill the CSG tree
|
// Invalidate renderers before we kill the CSG tree
|
||||||
this->qglview->setRenderer(NULL);
|
this->qglview->setRenderer(NULL);
|
||||||
|
@ -652,7 +740,7 @@ bool MainWindow::compile(bool reload, bool procevents)
|
||||||
if (this->root_module) {
|
if (this->root_module) {
|
||||||
// Evaluate CSG tree
|
// Evaluate CSG tree
|
||||||
PRINT("Compiling design (CSG Tree generation)...");
|
PRINT("Compiling design (CSG Tree generation)...");
|
||||||
if (procevents) QApplication::processEvents();
|
if (this->procevents) QApplication::processEvents();
|
||||||
|
|
||||||
AbstractNode::resetIndexCounter();
|
AbstractNode::resetIndexCounter();
|
||||||
|
|
||||||
|
@ -681,10 +769,8 @@ bool MainWindow::compile(bool reload, bool procevents)
|
||||||
} else {
|
} else {
|
||||||
PRINT("ERROR: Compilation failed!");
|
PRINT("ERROR: Compilation failed!");
|
||||||
}
|
}
|
||||||
if (procevents) QApplication::processEvents();
|
if (this->procevents) QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1043,77 +1129,42 @@ bool MainWindow::fileChangedOnDisk()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
If reload is true, does a timestamp check on the document and tries to reload it.
|
|
||||||
Otherwise, just reparses the current document and any dependencies, updates the
|
|
||||||
GUI accordingly and populates this->root_module.
|
|
||||||
|
|
||||||
Returns true if anything was compiled.
|
Returns true if anything was compiled.
|
||||||
*/
|
*/
|
||||||
bool MainWindow::compileTopLevelDocument(bool reload)
|
void MainWindow::compileTopLevelDocument()
|
||||||
{
|
{
|
||||||
bool shouldcompiletoplevel = !reload;
|
updateTemporalVariables();
|
||||||
|
|
||||||
if (this->root_module && this->root_module->includesChanged()) {
|
|
||||||
shouldcompiletoplevel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reload) {
|
|
||||||
// Refresh file if it has changed on disk
|
|
||||||
if (fileChangedOnDisk() && checkEditorModified()) {
|
|
||||||
shouldcompiletoplevel = true;
|
|
||||||
refreshDocument();
|
|
||||||
}
|
|
||||||
// If the file hasn't changed, we might still need to compile it
|
|
||||||
// if we haven't yet compiled the current text.
|
|
||||||
else if (!editor->isContentModified()) {
|
|
||||||
QString current_doc = editor->toPlainText();
|
|
||||||
if (current_doc != last_compiled_doc) shouldcompiletoplevel = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldcompiletoplevel) {
|
this->last_compiled_doc = editor->toPlainText();
|
||||||
console->clear();
|
std::string fulltext =
|
||||||
|
std::string(this->last_compiled_doc.toLocal8Bit().constData()) +
|
||||||
updateTemporalVariables();
|
"\n" + commandline_commands;
|
||||||
|
|
||||||
this->last_compiled_doc = editor->toPlainText();
|
delete this->root_module;
|
||||||
std::string fulltext =
|
this->root_module = NULL;
|
||||||
std::string(this->last_compiled_doc.toLocal8Bit().constData()) +
|
|
||||||
"\n" + commandline_commands;
|
this->root_module = parse(fulltext.c_str(),
|
||||||
|
this->fileName.isEmpty() ?
|
||||||
delete this->root_module;
|
"" :
|
||||||
this->root_module = NULL;
|
QFileInfo(this->fileName).absolutePath().toLocal8Bit(),
|
||||||
|
false);
|
||||||
this->root_module = parse(fulltext.c_str(),
|
|
||||||
this->fileName.isEmpty() ?
|
if (!animate_panel->isVisible()) {
|
||||||
"" :
|
highlighter->unhighlightLastError();
|
||||||
QFileInfo(this->fileName).absolutePath().toLocal8Bit(),
|
if (!this->root_module) {
|
||||||
false);
|
QTextCursor cursor = editor->textCursor();
|
||||||
|
cursor.setPosition(parser_error_pos);
|
||||||
if (!animate_panel->isVisible()) {
|
editor->setTextCursor(cursor);
|
||||||
highlighter->unhighlightLastError();
|
highlighter->highlightError( parser_error_pos );
|
||||||
if (!this->root_module) {
|
|
||||||
QTextCursor cursor = editor->textCursor();
|
|
||||||
cursor.setPosition(parser_error_pos);
|
|
||||||
editor->setTextCursor(cursor);
|
|
||||||
highlighter->highlightError( parser_error_pos );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = shouldcompiletoplevel;
|
|
||||||
if (this->root_module) {
|
|
||||||
changed |= this->root_module->handleDependencies();
|
|
||||||
if (changed) PRINTB("Module cache size: %d modules", ModuleCache::instance()->size());
|
|
||||||
}
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::checkAutoReload()
|
void MainWindow::checkAutoReload()
|
||||||
{
|
{
|
||||||
if (!this->fileName.isEmpty()) actionReloadCompile();
|
if (!this->fileName.isEmpty()) {
|
||||||
|
actionReloadRenderCSG();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::autoReloadSet(bool on)
|
void MainWindow::autoReloadSet(bool on)
|
||||||
|
@ -1143,15 +1194,22 @@ bool MainWindow::checkEditorModified()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::actionReloadCompile()
|
void MainWindow::actionReloadRenderCSG()
|
||||||
{
|
{
|
||||||
if (GuiLocker::isLocked()) return;
|
if (GuiLocker::isLocked()) return;
|
||||||
GuiLocker lock;
|
GuiLocker::lock();
|
||||||
|
autoReloadTimer->stop();
|
||||||
setCurrentOutput();
|
setCurrentOutput();
|
||||||
|
|
||||||
// PRINT("Parsing design (AST generation)...");
|
// PRINT("Parsing design (AST generation)...");
|
||||||
// QApplication::processEvents();
|
// QApplication::processEvents();
|
||||||
if (!compile(true, true)) return;
|
this->afterCompileSlot = "csgReloadRender";
|
||||||
|
this->procevents = true;
|
||||||
|
compile(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::csgReloadRender()
|
||||||
|
{
|
||||||
if (this->root_node) compileCSG(true);
|
if (this->root_node) compileCSG(true);
|
||||||
|
|
||||||
// Go to non-CGAL view mode
|
// Go to non-CGAL view mode
|
||||||
|
@ -1165,20 +1223,25 @@ void MainWindow::actionReloadCompile()
|
||||||
viewModeThrownTogether();
|
viewModeThrownTogether();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
compileEnded();
|
||||||
clearCurrentOutput();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::actionCompile()
|
void MainWindow::actionRenderCSG()
|
||||||
{
|
{
|
||||||
if (GuiLocker::isLocked()) return;
|
if (GuiLocker::isLocked()) return;
|
||||||
GuiLocker lock;
|
GuiLocker::lock();
|
||||||
|
autoReloadTimer->stop();
|
||||||
setCurrentOutput();
|
setCurrentOutput();
|
||||||
console->clear();
|
|
||||||
|
|
||||||
PRINT("Parsing design (AST generation)...");
|
PRINT("Parsing design (AST generation)...");
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
compile(false, !viewActionAnimate->isChecked());
|
this->afterCompileSlot = "csgRender";
|
||||||
|
this->procevents = !viewActionAnimate->isChecked();
|
||||||
|
compile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::csgRender()
|
||||||
|
{
|
||||||
if (this->root_node) compileCSG(!viewActionAnimate->isChecked());
|
if (this->root_node) compileCSG(!viewActionAnimate->isChecked());
|
||||||
|
|
||||||
// Go to non-CGAL view mode
|
// Go to non-CGAL view mode
|
||||||
|
@ -1202,7 +1265,7 @@ void MainWindow::actionCompile()
|
||||||
img.save(filename, "PNG");
|
img.save(filename, "PNG");
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCurrentOutput();
|
compileEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_CGAL
|
#ifdef ENABLE_CGAL
|
||||||
|
@ -1210,15 +1273,19 @@ void MainWindow::actionCompile()
|
||||||
void MainWindow::actionRenderCGAL()
|
void MainWindow::actionRenderCGAL()
|
||||||
{
|
{
|
||||||
if (GuiLocker::isLocked()) return;
|
if (GuiLocker::isLocked()) return;
|
||||||
GuiLocker lock;
|
GuiLocker::lock();
|
||||||
|
autoReloadTimer->stop();
|
||||||
setCurrentOutput();
|
setCurrentOutput();
|
||||||
console->clear();
|
|
||||||
|
|
||||||
PRINT("Parsing design (AST generation)...");
|
PRINT("Parsing design (AST generation)...");
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
compile(false, true);
|
this->afterCompileSlot = "cgalRender";
|
||||||
|
this->procevents = true;
|
||||||
|
compile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::cgalRender()
|
||||||
|
{
|
||||||
if (!this->root_module || !this->root_node) {
|
if (!this->root_module || !this->root_node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1305,6 @@ void MainWindow::actionRenderCGAL()
|
||||||
|
|
||||||
progress_report_prep(this->root_node, report_func, this);
|
progress_report_prep(this->root_node, report_func, this);
|
||||||
|
|
||||||
GuiLocker::lock(); // Will be unlocked in actionRenderCGALDone()
|
|
||||||
this->cgalworker->start(this->tree);
|
this->cgalworker->start(this->tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1301,9 +1367,7 @@ void MainWindow::actionRenderCGALDone(CGAL_Nef_polyhedron *root_N)
|
||||||
this->statusBar()->removeWidget(this->progresswidget);
|
this->statusBar()->removeWidget(this->progresswidget);
|
||||||
delete this->progresswidget;
|
delete this->progresswidget;
|
||||||
this->progresswidget = NULL;
|
this->progresswidget = NULL;
|
||||||
clearCurrentOutput();
|
compileEnded();
|
||||||
|
|
||||||
GuiLocker::unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ENABLE_CGAL */
|
#endif /* ENABLE_CGAL */
|
||||||
|
@ -1616,7 +1680,7 @@ void MainWindow::viewModeAnimate()
|
||||||
{
|
{
|
||||||
if (viewActionAnimate->isChecked()) {
|
if (viewActionAnimate->isChecked()) {
|
||||||
animate_panel->show();
|
animate_panel->show();
|
||||||
actionCompile();
|
actionRenderCSG();
|
||||||
updatedFps();
|
updatedFps();
|
||||||
} else {
|
} else {
|
||||||
animate_panel->hide();
|
animate_panel->hide();
|
||||||
|
|
|
@ -107,6 +107,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
bool include_modified(const IncludeFile &inc) const;
|
bool include_modified(const IncludeFile &inc) const;
|
||||||
|
|
||||||
typedef boost::unordered_map<std::string, struct IncludeFile> IncludeContainer;
|
typedef boost::unordered_map<std::string, struct IncludeFile> IncludeContainer;
|
||||||
IncludeContainer includes;
|
IncludeContainer includes;
|
||||||
bool is_handling_dependencies;
|
bool is_handling_dependencies;
|
||||||
|
|
|
@ -35,19 +35,19 @@ fs::path search_libs(const fs::path &localpath)
|
||||||
static bool check_valid(const fs::path &p, const std::vector<std::string> *openfilenames)
|
static bool check_valid(const fs::path &p, const std::vector<std::string> *openfilenames)
|
||||||
{
|
{
|
||||||
if (p.empty()) {
|
if (p.empty()) {
|
||||||
// PRINTB("WARNING: File path is blank: %s",p);
|
//PRINTB("WARNING: File path is blank: %s",p);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!p.has_parent_path()) {
|
if (!p.has_parent_path()) {
|
||||||
// PRINTB("WARNING: No parent path: %s",p);
|
//PRINTB("WARNING: No parent path: %s",p);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!fs::exists(p)) {
|
if (!fs::exists(p)) {
|
||||||
// PRINTB("WARNING: File not found: %s",p);
|
//PRINTB("WARNING: File not found: %s",p);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (fs::is_directory(p)) {
|
if (fs::is_directory(p)) {
|
||||||
// PRINTB("WARNING: %s invalid - points to a directory",p);
|
//PRINTB("WARNING: %s invalid - points to a directory",p);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string fullname = boosty::stringy(p);
|
std::string fullname = boosty::stringy(p);
|
||||||
|
|
40
src/svg.cc
40
src/svg.cc
|
@ -70,29 +70,29 @@ std::string svg_axes()
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox )
|
CGAL_Nef_polyhedron2::Explorer::Point project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox )
|
||||||
{
|
{
|
||||||
NT screenw(svg_px_width);
|
CGAL_Kernel3::FT screenw(svg_px_width);
|
||||||
NT screenh(svg_px_height);
|
CGAL_Kernel3::FT screenh(svg_px_height);
|
||||||
NT screenxc = screenw / 2;
|
CGAL_Kernel3::FT screenxc = screenw / 2;
|
||||||
NT screenyc = screenh / 2;
|
CGAL_Kernel3::FT screenyc = screenh / 2;
|
||||||
NT bboxx = ( bbox.xmax() - bbox.xmin() );
|
CGAL_Kernel3::FT bboxx = ( bbox.xmax() - bbox.xmin() );
|
||||||
NT bboxy = ( bbox.ymax() - bbox.ymin() );
|
CGAL_Kernel3::FT bboxy = ( bbox.ymax() - bbox.ymin() );
|
||||||
NT bboxz = ( bbox.zmax() - bbox.zmin() );
|
CGAL_Kernel3::FT bboxz = ( bbox.zmax() - bbox.zmin() );
|
||||||
NT largest_dim = CGAL::max( CGAL::max( bboxx, bboxy ), bboxz );
|
CGAL_Kernel3::FT largest_dim = CGAL::max( CGAL::max( bboxx, bboxy ), bboxz );
|
||||||
NT bboxxc = bboxx / 2 + bbox.xmin();
|
CGAL_Kernel3::FT bboxxc = bboxx / 2 + bbox.xmin();
|
||||||
NT bboxyc = bboxy / 2 + bbox.ymin();
|
CGAL_Kernel3::FT bboxyc = bboxy / 2 + bbox.ymin();
|
||||||
NT bboxzc = bboxz / 2 + bbox.zmin();
|
CGAL_Kernel3::FT bboxzc = bboxz / 2 + bbox.zmin();
|
||||||
NT xinbox = ( p.x() - bboxxc ) / largest_dim;
|
CGAL_Kernel3::FT xinbox = ( p.x() - bboxxc ) / largest_dim;
|
||||||
NT yinbox = ( p.y() - bboxyc ) / largest_dim;
|
CGAL_Kernel3::FT yinbox = ( p.y() - bboxyc ) / largest_dim;
|
||||||
NT zinbox = ( p.z() - bboxzc ) / largest_dim;
|
CGAL_Kernel3::FT zinbox = ( p.z() - bboxzc ) / largest_dim;
|
||||||
// do simple fake paralell projection
|
// do simple fake paralell projection
|
||||||
NT tx = screenxc + xinbox * screenw / 1.618 + yinbox * screenh / 3.2;
|
CGAL_Kernel3::FT tx = screenxc + xinbox * screenw / 1.618 + yinbox * screenh / 3.2;
|
||||||
NT ty = screenyc - zinbox * screenh / 1.618 - yinbox * screenh / 3.2;
|
CGAL_Kernel3::FT ty = screenyc - zinbox * screenh / 1.618 - yinbox * screenh / 3.2;
|
||||||
return CGAL_Point_2e( tx, ty );
|
return CGAL_Point_2e(CGAL::to_double(tx), CGAL::to_double(ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox )
|
CGAL_Point_2e project_svg_2to2(const CGAL_Point_2e &p, const CGAL_Iso_rectangle_2e &bbox)
|
||||||
{
|
{
|
||||||
double screenw = svg_px_width;
|
double screenw = svg_px_width;
|
||||||
double screenh = svg_px_height;
|
double screenh = svg_px_height;
|
||||||
|
@ -122,7 +122,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg(
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
CGAL_For_all(c1, c2) {
|
CGAL_For_all(c1, c2) {
|
||||||
if ( explorer.is_standard( explorer.target(c1) ) ) {
|
if ( explorer.is_standard( explorer.target(c1) ) ) {
|
||||||
CGAL_Point_2e source = explorer.point( explorer.source( c1 ) );
|
CGAL_Nef_polyhedron2::Explorer::Point source = explorer.point( explorer.source( c1 ) );
|
||||||
CGAL_Point_2e target = explorer.point( explorer.target( c1 ) );
|
CGAL_Point_2e target = explorer.point( explorer.target( c1 ) );
|
||||||
out << " <!-- Halfedge. Mark: " << c1->mark() << " -->\n";
|
out << " <!-- Halfedge. Mark: " << c1->mark() << " -->\n";
|
||||||
std::string he_mark = boost::lexical_cast<std::string>(c1->mark());
|
std::string he_mark = boost::lexical_cast<std::string>(c1->mark());
|
||||||
|
|
Loading…
Reference in New Issue