-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshape.hh
194 lines (147 loc) · 5.9 KB
/
shape.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#ifndef __FLYWAVE_MESH_TOPO_OCC_SHAPE_HH__
#define __FLYWAVE_MESH_TOPO_OCC_SHAPE_HH__
#include "geometry_object.hh"
#include "location.hh"
#include "mesh_receiver.hh"
#include "orientation.hh"
#include <BRepBuilderAPI_Copy.hxx>
#include <OSD_Timer.hxx>
#include <TopoDS_Shape.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Quantity_Color.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Macro.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <vector>
namespace flywave {
namespace topo {
enum texture_mapping_rule {
texture_cube,
texture_normal,
texture_normal_auto_scale
};
class shape : public geometry_object {
public:
shape();
virtual ~shape() = default;
shape(const shape &) = default;
shape &operator=(const shape &) = default;
shape(shape &&) noexcept;
shape &operator=(shape &&) noexcept;
static boost::optional<shape> make_shape(TopoDS_Shape shp);
virtual bool is_null() const override;
virtual bool is_valid() const override;
virtual geometry_object_type type() const override;
virtual Bnd_Box bounding_box(double tolerance = 1e-12) const override;
int hash_code() const;
virtual bool equals(const geometry_object &) const override;
explicit operator bool() const;
void set_surface_colour(const Quantity_Color &c) { _surface_colour = c; }
void set_curve_colour(const Quantity_Color &c) { _curve_colour = c; }
void set_label(const char *name) { _label = std::string(name); }
void set_u_origin(double u) { _u_origin = u; }
void set_v_origin(double v) { _v_origin = v; }
void set_u_repeat(double u) { _u_repeat = u; }
void set_v_repeat(double v) { _v_repeat = v; }
void set_scale_v(double u) { _scale_v = u; }
void set_scale_u(double v) { _scale_u = v; }
void set_auto_scale_size_on_u(double u) { _auto_scale_size_on_u = u; }
void set_auto_scale_size_on_v(double v) { _auto_scale_size_on_v = v; }
void set_txture_map_type(texture_mapping_rule t);
void set_rotation_angle(double angle) { _rotation_angle = angle; }
Quantity_Color surface_colour() const { return _surface_colour; }
Quantity_Color curve_colour() const { return _curve_colour; }
const char *label() const { return _label.c_str(); }
double get_u_origin() const { return _u_origin; }
double get_v_origin() const { return _v_origin; }
double get_u_repeat() const { return _u_repeat; }
double get_v_repeat() const { return _v_repeat; }
double get_scale_v() const { return _scale_v; }
double get_scale_u() const { return _scale_u; }
double get_auto_scale_size_on_u() const { return _auto_scale_size_on_u; }
double get_auto_scale_size_on_v() const { return _auto_scale_size_on_v; }
texture_mapping_rule get_txture_map_type() const { return _txture_map_type; }
double get_rotation_angle() const { return _rotation_angle; }
bool surface_colour(double *colour) const;
int transform(gp_Trsf mat);
int translate(gp_Vec delta);
int rotate(double angle, gp_Pnt p1, gp_Pnt p2);
int rotate(double angle, gp_Ax1 a);
int rotate(gp_Quaternion R);
int scale(gp_Pnt pnt, double scale);
int mirror(gp_Pnt pnt, gp_Pnt nor);
int mirror(gp_Ax1 a);
int mirror(gp_Ax2 a);
shape transformed(gp_Trsf mat) const;
shape translated(gp_Vec delta) const;
shape rotated(double angle, gp_Pnt p1, gp_Pnt p2) const;
shape rotated(double angle, gp_Ax1 a) const;
shape rotated(gp_Quaternion R) const;
shape scaled(gp_Pnt pnt, double scale) const;
shape mirrored(gp_Pnt pnt, gp_Pnt nor) const;
shape mirrored(gp_Ax1 a) const;
shape mirrored(gp_Ax2 a) const;
gp_Pln find_plane(double tolerance = 1e-6);
TopoDS_Shape &value();
const TopoDS_Shape &value() const;
virtual operator TopoDS_Shape &();
virtual operator const TopoDS_Shape &() const;
topo_location location() const;
bool location(double *loc) const;
void set_location(const topo_location &loc);
orientation get_orientation() const;
void set_orientation(orientation ori);
shape oriented(orientation ori) const;
bool fix_shape();
template <typename TShape> boost::optional<TShape> cast() const;
boost::optional<shape> auto_cast() const;
std::string shape_type() const;
virtual int write_triangulation(mesh_receiver &mesh, double tolerance,
double deflection, double angle,
bool uv_coords);
virtual int mesh(mesh_receiver &mesh, double precision = 1.0e-06,
double deflection = 0.1, double angle = 0.5,
bool uv_coords = false) {
return write_triangulation(mesh, precision, deflection, angle, uv_coords);
}
virtual shape copy(bool deep = true) const;
inline bool operator==(const shape &s) const { return this->equals(s); }
inline bool operator!=(const shape &s) const { return !(*this == s); }
shape(TopoDS_Shape shp);
shape(const shape &s, TopoDS_Shape shp);
protected:
void prepare_box_texture_coordinates(const TopoDS_Shape &aShape);
void get_box_texture_coordinate(const gp_Pnt &p, const gp_Dir &N1,
gp_Vec2d &theCoord_p);
void clear_maps();
void build_maps();
int transform_impl(gp_Trsf &trans);
friend class cad_reader;
std::string _label;
Quantity_Color _surface_colour;
Quantity_Color _curve_colour;
TopoDS_Shape _shape;
TopTools_IndexedMapOfShape _vmap, _emap, _fmap;
Standard_Real _u_origin;
Standard_Real _v_origin;
Standard_Real _u_repeat;
Standard_Real _v_repeat;
Standard_Real _scale_u;
Standard_Real _scale_v;
Standard_Real _auto_scale_size_on_u;
Standard_Real _auto_scale_size_on_v;
Standard_Real _rotation_angle;
texture_mapping_rule _txture_map_type;
Standard_Real _bnd_box_sz;
Standard_Real _Xmin, _Ymin, _Zmin, _Xmax, _Ymax, _Zmax;
};
} // namespace topo
} // namespace flywave
namespace std {
template <> struct hash<::flywave::topo::shape> {
size_t operator()(const ::flywave::topo::shape &v) const {
return v.hash_code();
}
};
} // namespace std
#endif // __FLYWAVE_MESH_TOPO_OCC_SHAPE_HH__