42 constexpr
int NO_INDEX = -1;
66 Vert(
const mpq3 &mco,
const double3 &dco,
int id,
int orig);
92 Plane(
const mpq3 &norm_exact,
const mpq_class &d_exact);
93 Plane(
const double3 &
norm,
const double d);
101 void make_canonical();
102 bool exact_populated()
const;
103 void populate_exact();
106 std::ostream &
operator<<(std::ostream &os,
const Plane *plane);
124 struct Face : NonCopyable {
125 Array<const Vert *> vert;
126 Array<int> edge_orig;
127 Array<bool> is_intersect;
128 Plane *plane =
nullptr;
135 Face(Span<const Vert *>
verts,
int id,
int orig, Span<int> edge_origs, Span<bool> is_intersect);
136 Face(Span<const Vert *>
verts,
int id,
int orig);
141 return vert.size() == 3;
148 bool cyclic_equal(
const Face &other)
const;
150 FacePos next_pos(FacePos p)
const
152 return (p + 1) % vert.size();
155 FacePos prev_pos(FacePos p)
const
157 return (p + vert.size() - 1) % vert.size();
170 const Vert *
const *begin()
const
175 const Vert *
const *end()
const
180 IndexRange index_range()
const
182 return IndexRange(vert.size());
185 void populate_plane(
bool need_exact);
187 bool plane_populated()
const
189 return plane !=
nullptr;
202 class IMeshArena : NonCopyable, NonMovable {
203 class IMeshArenaImpl;
204 std::unique_ptr<IMeshArenaImpl> pimpl_;
214 void reserve(
int vert_num_hint,
int face_num_hint);
216 int tot_allocated_verts()
const;
217 int tot_allocated_faces()
const;
225 const Vert *add_or_find_vert(
const mpq3 &co,
int orig);
226 const Vert *add_or_find_vert(
const double3 &co,
int orig);
230 Span<int> edge_origs,
231 Span<bool> is_intersect);
232 Face *add_face(Span<const Vert *>
verts,
int orig, Span<int> edge_origs);
233 Face *add_face(Span<const Vert *>
verts,
int orig);
236 const Vert *find_vert(
const mpq3 &co)
const;
237 const Face *find_face(Span<const Vert *>
verts)
const;
253 Array<const Vert *> vert_;
254 Map<const Vert *, int> vert_to_index_;
255 bool vert_populated_ =
false;
263 void set_faces(Span<Face *>
faces);
264 Face *face(
int index)
const
269 int face_size()
const
274 int vert_size()
const
279 bool has_verts()
const
281 return vert_populated_;
284 void set_dirty_verts()
286 vert_populated_ =
false;
287 vert_to_index_.clear();
288 vert_ = Array<const Vert *>();
292 void populate_vert();
293 void populate_vert(
int max_verts);
295 const Vert *vert(
int index)
const
302 int lookup_vert(
const Vert *
v)
const;
304 IndexRange vert_index_range()
const
307 return IndexRange(vert_.size());
310 IndexRange face_index_range()
const
312 return IndexRange(face_.size());
315 Span<const Vert *> vertices()
const
318 return Span<const Vert *>(vert_);
321 Span<Face *>
faces()
const
323 return Span<Face *>(face_);
335 bool erase_face_positions(
int f_index, Span<bool> face_pos_erase, IMeshArena *arena);
337 void remove_null_faces();
352 IMesh trimesh_self_intersect(
const IMesh &tm_in, IMeshArena *arena);
354 IMesh trimesh_nary_intersect(
const IMesh &tm_in,
356 std::function<
int(
int)> shape_fn,
361 IMesh triangulate_polymesh(IMesh &imesh, IMeshArena *arena);
364 void write_obj_mesh(IMesh &m,
const std::string &objname);
ATTR_WARN_UNUSED_RESULT const BMVert * v
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.
std::ostream & operator<<(std::ostream &os, const CDT_result< T > &r)
constexpr bool operator==(StringRef a, StringRef b)
unsigned __int64 uint64_t