30constexpr int NO_INDEX = -1;
54 Vert(
const mpq3 &mco,
const double3 &dco,
int id,
int orig);
64std::ostream &
operator<<(std::ostream &os,
const Vert *
v);
80 Plane(
const mpq3 &norm_exact,
const mpq_class &d_exact);
81 Plane(
const double3 &
norm,
double d);
89 void make_canonical();
93 bool exact_populated()
const;
94 void populate_exact();
97std::ostream &
operator<<(std::ostream &os,
const Plane *plane);
115struct Face : NonCopyable {
116 Array<const Vert *> vert;
117 Array<int> edge_orig;
118 Array<bool> is_intersect;
119 Plane *plane =
nullptr;
126 Face(Span<const Vert *>
verts,
int id,
int orig, Span<int> edge_origs, Span<bool> is_intersect);
127 Face(Span<const Vert *>
verts,
int id,
int orig);
132 return vert.
size() == 3;
139 bool cyclic_equal(
const Face &other)
const;
141 FacePos next_pos(FacePos p)
const
143 return (p + 1) % vert.
size();
146 FacePos prev_pos(FacePos p)
const
148 return (p + vert.
size() - 1) % vert.
size();
151 const Vert *
const &
operator[](
int index)
const
161 const Vert *
const *
begin()
const
166 const Vert *
const *end()
const
171 IndexRange index_range()
const
173 return IndexRange(vert.
size());
176 void populate_plane(
bool need_exact);
178 bool plane_populated()
const
180 return plane !=
nullptr;
184std::ostream &
operator<<(std::ostream &os,
const Face *f);
193class IMeshArena : NonCopyable, NonMovable {
194 class IMeshArenaImpl;
195 std::unique_ptr<IMeshArenaImpl> pimpl_;
205 void reserve(
int vert_num_hint,
int face_num_hint);
207 int tot_allocated_verts()
const;
208 int tot_allocated_faces()
const;
216 const Vert *add_or_find_vert(
const mpq3 &co,
int orig);
217 const Vert *add_or_find_vert(
const double3 &co,
int orig);
218 const Vert *add_or_find_vert(Vert *vert);
222 Span<int> edge_origs,
223 Span<bool> is_intersect);
224 Face *add_face(Span<const Vert *>
verts,
int orig, Span<int> edge_origs);
225 Face *add_face(Span<const Vert *>
verts,
int orig);
228 const Vert *find_vert(
const mpq3 &co)
const;
229 const Face *find_face(Span<const Vert *>
verts)
const;
244 Array<const Vert *> vert_;
245 Map<const Vert *, int> vert_to_index_;
246 bool vert_populated_ =
false;
252 void set_faces(Span<Face *>
faces);
253 Face *face(
int index)
const
258 int face_size()
const
263 int vert_size()
const
268 bool has_verts()
const
270 return vert_populated_;
273 void set_dirty_verts()
275 vert_populated_ =
false;
276 vert_to_index_.
clear();
277 vert_ = Array<const Vert *>();
281 void populate_vert();
282 void populate_vert(
int max_verts);
284 const Vert *vert(
int index)
const
291 int lookup_vert(
const Vert *
v)
const;
293 IndexRange vert_index_range()
const
296 return IndexRange(vert_.
size());
299 IndexRange face_index_range()
const
301 return IndexRange(face_.
size());
304 Span<const Vert *> vertices()
const
307 return Span<const Vert *>(vert_);
310 Span<Face *>
faces()
const
312 return Span<Face *>(face_);
324 bool erase_face_positions(
int f_index, Span<bool> face_pos_erase, IMeshArena *arena);
326 void remove_null_faces();
329std::ostream &
operator<<(std::ostream &os,
const IMesh &mesh);
342 void combine(
const float3 &p)
347 void combine(
const double3 &p)
358 void expand(
float pad)
384IMesh trimesh_self_intersect(
const IMesh &tm_in, IMeshArena *arena);
386IMesh trimesh_nary_intersect(
const IMesh &tm_in,
388 FunctionRef<
int(
int)> shape_fn,
398IMesh triangulate_polymesh(IMesh &imesh, IMeshArena *arena);
403void write_obj_mesh(IMesh &m,
const std::string &objname);
bool operator==(const AssetWeakReference &a, const AssetWeakReference &b)
int pad[32 - sizeof(int)]
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btVector3 & operator[](int i)
Get a mutable reference to a row of the matrix as a vector.
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
VecBase< float, 3 > float3
std::ostream & operator<<(std::ostream &stream, EulerOrder order)
T min(const T &a, const T &b)
void min_max(const T &value, T &min, T &max)
T max(const T &a, const T &b)
VecBase< double, 3 > double3