~corrado-maurini/dolfin/tao

« back to all changes in this revision

Viewing changes to dolfin/generation/CSGPrimitives3D.h

  • Committer: corrado maurini
  • Date: 2012-12-18 12:16:08 UTC
  • mfrom: (6685.78.207 trunk)
  • Revision ID: corrado.maurini@upmc.fr-20121218121608-nk82ly9jgsld9u84
updating with trunk, fix uint in TAO solver and hacking the check for tao FindTAO.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2012 Anders Logg
 
2
//
 
3
// This file is part of DOLFIN.
 
4
//
 
5
// DOLFIN is free software: you can redistribute it and/or modify
 
6
// it under the terms of the GNU Lesser General Public License as published by
 
7
// the Free Software Foundation, either version 3 of the License, or
 
8
// (at your option) any later version.
 
9
//
 
10
// DOLFIN is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
// GNU Lesser General Public License for more details.
 
14
//
 
15
// You should have received a copy of the GNU Lesser General Public License
 
16
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
 
17
//
 
18
// Modified by Benjamin Kehlet, 2012
 
19
// Modified by Johannes Ring, 2012
 
20
//
 
21
// First added:  2012-04-11
 
22
// Last changed: 2012-11-12
 
23
 
 
24
#ifndef __CSG_PRIMITIVES_3D_H
 
25
#define __CSG_PRIMITIVES_3D_H
 
26
 
 
27
#include "CSGPrimitive.h"
 
28
#include <dolfin/mesh/Point.h>
 
29
 
 
30
namespace dolfin
 
31
{
 
32
 
 
33
  /// Base class for 3D primitives
 
34
  class CSGPrimitive3D : public CSGPrimitive
 
35
  {
 
36
  public:
 
37
 
 
38
    /// Return dimension of geometry
 
39
    std::size_t dim() const { return 3; }
 
40
 
 
41
  };
 
42
 
 
43
  /// This class describes a 3D sphere which can be used to build
 
44
  /// geometries using Constructive Solid Geometry (CSG).
 
45
  class Sphere : public CSGPrimitive3D
 
46
  {
 
47
  public:
 
48
 
 
49
    /// Create sphere at x = (x0, x1, x2) with radius r.
 
50
    ///
 
51
    /// *Arguments*
 
52
    ///     x0 (double)
 
53
    ///         x0-coordinate of center.
 
54
    ///     x1 (double)
 
55
    ///         x1-coordinate of center.
 
56
    ///     x2 (double)
 
57
    ///         x2-coordinate of center.
 
58
    ///     r (double)
 
59
    ///         radius.
 
60
    Sphere(Point c, double r, std::size_t slices=16);
 
61
 
 
62
    /// Informal string representation
 
63
    std::string str(bool verbose) const;
 
64
 
 
65
    Type getType() const
 
66
    { return CSGGeometry::Sphere; }
 
67
 
 
68
    const Point c;
 
69
    const double r;
 
70
    const std::size_t slices;
 
71
 
 
72
  };
 
73
 
 
74
  /// This class describes a 3D box which can be used to build
 
75
  /// geometries using Constructive Solid Geometry (CSG).
 
76
  class Box : public CSGPrimitive3D
 
77
  {
 
78
  public:
 
79
 
 
80
    /// Create box defined by two opposite corners
 
81
    /// x = (x0, x1, x2) and y = (y0, y1, y2).
 
82
    ///
 
83
    /// *Arguments*
 
84
    ///     x0 (double)
 
85
    ///         x0-coordinate of first corner.
 
86
    ///     x1 (double)
 
87
    ///         x1-coordinate of first corner.
 
88
    ///     x2 (double)
 
89
    ///         x2-coordinate of first corner.
 
90
    ///     y0 (double)
 
91
    ///         y0-coordinate of second corner.
 
92
    ///     y1 (double)
 
93
    ///         y1-coordinate of second corner.
 
94
    ///     y2 (double)
 
95
    ///         y2-coordinate of second corner.
 
96
    Box(double x0, double x1, double x2,
 
97
        double y0, double y1, double y2);
 
98
 
 
99
    /// Informal string representation
 
100
    std::string str(bool verbose) const;
 
101
 
 
102
    Type getType() const
 
103
    { return CSGGeometry::Box; }
 
104
 
 
105
    double _x0, _x1, _x2, _y0, _y1, _y2;
 
106
  };
 
107
 
 
108
  /// This class describes a 3D cone which can be used to build
 
109
  /// geometries using Constructive Solid Geometry (CSG).
 
110
  class Cone : public CSGPrimitive3D
 
111
  {
 
112
  public:
 
113
 
 
114
    /// Create cone defined by upper and lower center
 
115
    /// and radius respectively.
 
116
    ///
 
117
    /// *Arguments*
 
118
    ///     top (Point)
 
119
    ///         Center at top of cone.
 
120
    ///      top_radius(double)
 
121
    ///         Radius bottom of cone.
 
122
    ///     bottom(Point)
 
123
    ///         Center at top of cone.
 
124
    ///     bottom_radius (double)
 
125
    ///         radius at top of cone.
 
126
    ///     slices (std::size_t)
 
127
    ///         number of faces on the side when generating a
 
128
    ///         polyhedral approximation.
 
129
    Cone(Point top, Point bottom, double top_radius, double bottom_radius, std::size_t slices=32);
 
130
 
 
131
    /// Informal string representation
 
132
    std::string str(bool verbose) const;
 
133
 
 
134
    Type getType() const
 
135
    { return CSGGeometry::Cone; }
 
136
 
 
137
    const Point top, bottom;
 
138
    const double top_radius, bottom_radius;
 
139
    const std::size_t slices;
 
140
  };
 
141
 
 
142
  /// This class describes a 3D cylinder which can be used to build
 
143
  /// geometries using Constructive Solid Geometry (CSG). A cylinder
 
144
  /// is here just a special case of a cone.
 
145
  class Cylinder : public Cone
 
146
  {
 
147
  public:
 
148
    Cylinder(Point top, Point bottom, double r, std::size_t slices=32) : Cone(top, bottom, r, r, slices){}
 
149
  };
 
150
 
 
151
  /// This class describes a Tetrahedron which can be used to build
 
152
  /// geometries using Constructive Solid Geometry (CSG).
 
153
  class Tetrahedron : public CSGPrimitive3D
 
154
  {
 
155
  public:
 
156
    Tetrahedron(Point x0, Point x1, Point x2, Point x3);
 
157
 
 
158
    /// Informal string representation
 
159
    std::string str(bool verbose) const;
 
160
 
 
161
    Type getType() const
 
162
    { return CSGGeometry::Tetrahedron; }
 
163
 
 
164
 
 
165
    Point x0, x1, x2, x3;
 
166
  };
 
167
 
 
168
  /// This class describes a 3D surface loaded from file.
 
169
  /// The supported file types
 
170
  class Surface3D : public CSGPrimitive3D
 
171
  {
 
172
  public:
 
173
    Surface3D(std::string filename);
 
174
 
 
175
    /// Informal string representation
 
176
    std::string str(bool verbose) const;
 
177
 
 
178
    Type getType() const
 
179
    { return CSGGeometry::Surface3D; }
 
180
 
 
181
    std::string filename;
 
182
  };
 
183
}
 
184
#endif