⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geomview_stream.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 2 页
字号:
// Copyright (c) 1997,1998,1999,2000,2001  Utrecht University (The Netherlands),// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),// and Tel-Aviv University (Israel).  All rights reserved.//// This file is part of CGAL (www.cgal.org); you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License as// published by the Free Software Foundation; version 2.1 of the License.// See the file LICENSE.LGPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Geomview/include/CGAL/IO/Geomview_stream.h $// $Id: Geomview_stream.h 28567 2006-02-16 14:30:13Z lsaboret $// //// Author(s)     : Andreas Fabri, Sylvain Pion#ifndef CGAL_GEOMVIEW_STREAM_H#define CGAL_GEOMVIEW_STREAM_H#include <CGAL/basic.h>#include <CGAL/Bbox_2.h>#include <CGAL/Bbox_3.h>#include <CGAL/IO/Color.h>#include <CGAL/IO/Ostream_iterator.h>#include <map>#include <vector>#include <utility>#include <string>#include <iterator>#include <algorithm>CGAL_BEGIN_NAMESPACEclass Geomview_stream {public:    Geomview_stream(const Bbox_3 &bbox = Bbox_3(0,0,0, 1,1,1),		    const char *machine = NULL,		    const char *login = NULL);    ~Geomview_stream();    Geomview_stream &operator<<(const Color &c);    Geomview_stream &operator<<(const std::string & s);    Geomview_stream &operator<<(int i);    Geomview_stream &operator<<(unsigned int i);    Geomview_stream &operator<<(long i);    Geomview_stream &operator<<(unsigned long i);    Geomview_stream &operator<<(double d);    template < class InputIterator >    void    draw_triangles(InputIterator begin, InputIterator end);    Geomview_stream &operator>>(char *expr);    void clear();    void look_recenter();    void set_bg_color(const Color &c);    Color get_vertex_color() const;    Color get_edge_color() const;    Color get_face_color() const;    Color set_vertex_color(const Color&);    Color set_edge_color(const Color&);    Color set_face_color(const Color&);    double vcr() const;    double vcg() const;    double vcb() const;    double ecr() const;    double ecg() const;    double ecb() const;    double fcr() const;    double fcg() const;    double fcb() const;    double get_vertex_radius() const    {	return radius;    }    double set_vertex_radius(double r)    {	std::swap(r, radius);	return r;    }    int get_line_width() const    {	return line_width;    }    int set_line_width(int w)    {	std::swap(w, line_width);        return w;    }    bool set_wired(bool b)    {	std::swap(b, wired_flag);	return b;    }    bool get_wired() const    {	return wired_flag;    }    bool set_echo(bool b)    {	std::swap(b, echo_flag);	return b;    }    bool get_echo() const    {	return echo_flag;    }    bool set_raw(bool b)    {	std::swap(b, raw_flag);	return b;    }    bool get_raw() const    {	return raw_flag;    }    bool set_trace(bool b)    {	std::swap(b, trace_flag);	return b;    }    bool get_trace() const    {	return trace_flag;    }    void trace(const std::string s) const    {        if (get_trace())            std::cerr << s;    }    void trace(double d) const    {        if (get_trace())            std::cerr << d << ' ';    }    void trace(int i) const    {        if (get_trace())            std::cerr << i << ' ';    }    void trace(unsigned int i) const    {        if (get_trace())            std::cerr << i << ' ';    }    bool set_binary_mode(bool b = true)    {	std::swap(b, binary_flag);	return b;    }    bool set_ascii_mode(bool b = true)    {	return !set_binary_mode(!b);    }    bool get_binary_mode() const    {	return binary_flag;    }    bool get_ascii_mode() const    {	return !binary_flag;    }    std::string get_new_id(const std::string & s);    const Bbox_3 & get_bbox()    {	return bb;    }    void pickplane()    {        pickplane(get_bbox());    }    static char* nth(char* s, int count);    static void parse_point(const char* pickpoint,		     double &x, double &y, double &z, double &w);private:    void setup_geomview(const char *machine, const char *login);    void frame(const Bbox_3 &bbox);    void pickplane(const Bbox_3 &bbox);    Bbox_3 bb;    Color vertex_color, edge_color, face_color;    bool wired_flag;  // decides if we draw surfaces or edges.    bool echo_flag;   // decides if we echo the point we get back to Geomview.    bool raw_flag;    // decides if we output footers and headers.    bool trace_flag;  // makes operator<<() write a trace on cerr.    bool binary_flag; // makes operator<<() write binary format    int line_width;   // width of edges    double radius;    // radius of vertices    int in, out;      // file descriptors for input and output pipes    int pid;          // the geomview process identification    std::map<std::string, int> id; // used to get a unique ID per type.};// Factorize code for Point_2 and Point_3.template < class FT >voidoutput_point(Geomview_stream &gv, const FT &x, const FT &y, const FT &z){    bool ascii_bak = true; // the initialization value shuts up the compiler.    if (!gv.get_raw()) {    	ascii_bak = gv.set_ascii_mode();    	gv << "(geometry " << gv.get_new_id("P")       	   << " {appearance {linewidth 5 material {edgecolor "           << gv.vcr() << gv.vcg() << gv.vcb() << "}}{SKEL 1 1 ";    }    gv << CGAL::to_double(x) << CGAL::to_double(y) << CGAL::to_double(z);    if (!gv.get_raw()) {        gv << "1 0\n}})";    	gv.set_ascii_mode(ascii_bak);    }}#if defined CGAL_POINT_2_H && \   !defined CGAL_GV_OUT_POINT_2_H#define CGAL_GV_OUT_POINT_2_Htemplate < class R >Geomview_stream&operator<<(Geomview_stream &gv, const Point_2<R> &p){    typename R::FT zero(0);    output_point(gv, p.x(), p.y(), zero);    return gv;}#endif#if defined CGAL_POINT_3_H && \   !defined CGAL_GV_OUT_POINT_3_H#define CGAL_GV_OUT_POINT_3_Htemplate < class R >Geomview_stream&operator<<(Geomview_stream &gv, const Point_3<R> &p){    output_point(gv, p.x(), p.y(), p.z());    return gv;}#endif// The following code is the same for Segment_2 and Segment_3.template < class Segment >voidoutput_segment(Geomview_stream &gv, const Segment &segment){    bool ascii_bak = gv.set_ascii_mode();    gv << "(geometry " << gv.get_new_id("Seg")       << " {appearance {linewidth "       << gv.get_line_width() << "}{VECT "       << 1 <<  2 << 1    // 1 polyline, two vertices, 1 color       << 2               // the first polyline contains 2 vertices       << 1;              // and it has 1 color    // here are start and end points    bool raw_bak = gv.set_raw(true);    gv << segment.source() << segment.target();    gv.set_raw(raw_bak);    // and the color of the segment and its opaqueness    gv << gv.ecr() << gv.ecg() << gv.ecb() << 1.0 << "}})";    gv.set_ascii_mode(ascii_bak);}#if defined CGAL_SEGMENT_2_H && \   !defined CGAL_GV_OUT_SEGMENT_2_H#define CGAL_GV_OUT_SEGMENT_2_Htemplate < class R >Geomview_stream&operator<<(Geomview_stream &gv, const Segment_2<R> &segment){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -