Skip to content

Commit

Permalink
Taking into account mesh dimension in CSGBuilder::multmatrix().
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLevy committed Nov 20, 2023
1 parent 56d18cf commit 4fd0d73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
15 changes: 10 additions & 5 deletions src/lib/geogram/mesh/mesh_CSG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,17 @@ namespace GEO {

CSGMesh_var CSGBuilder::multmatrix(const mat4& M, const CSGScope& scope) {
CSGMesh_var result = group(scope);
index_t dim = result->vertices.dimension();
for(index_t v: result->vertices) {
vec3 p(result->vertices.point_ptr(v));
p = transform_point(M,p);
result->vertices.point_ptr(v)[0] = p.x;
result->vertices.point_ptr(v)[1] = p.y;
result->vertices.point_ptr(v)[2] = p.z;
double* p = result->vertices.point_ptr(v);
double x = p[0];
double y = p[1];
double z = (dim == 3) ? p[2] : 0.0;
vec3 P(x,y,z);
P = transform_point(M,P);
for(index_t c=0; c<dim; ++c) {
p[c] = P[c];
}
}
result->update_bbox();
return result;
Expand Down
26 changes: 16 additions & 10 deletions src/lib/geogram/mesh/mesh_surface_intersection_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ namespace GEO {
geo_argused(j);
geo_argused(k);
geo_argused(l);

ExactPoint I;
get_edge_edge_intersection(e1,e2,I);
vertex_.push_back(Vertex(this,I));
Expand Down Expand Up @@ -700,6 +701,7 @@ namespace GEO {
pred_cache_insert_buffer_.resize(0);
use_pred_cache_insert_buffer_ = false;
cnstr_operand_bits_.resize(0);
constraints_.resize(0);
CDTBase2d::clear();
}

Expand Down Expand Up @@ -824,18 +826,22 @@ namespace GEO {
index_t E1, index_t i, index_t j,
index_t E2, index_t k, index_t l
) {
// Note / TODO: I could memorize constraint extremities
// and use constraints initial vertices instead of
// pi,pj - pk,pl that might be themselves generated
// by intersections. Doing so would reduce the length
// of the expressions. In the end, since I call
// optimize_number_representation() with exact_nt it will
// not make any difference, but with expansion_nt it is
// another story.

geo_argused(E1);
geo_argused(E2);
geo_argused(i);
geo_argused(j);
geo_argused(k);
geo_argused(l);

// Here we could use i,j,k,l directly, but it is *much better* to take
// the original extremities of the constrained segments, since they have
// simpler coordinates ! (i,j,k,l might be themselves vertices created
// from constraints intersections, whereas constraint extremities can only
// be initial vertices).
i = constraints_[E1].indices[0];
j = constraints_[E1].indices[1];
k = constraints_[E2].indices[0];
l = constraints_[E2].indices[1];

ExactVec2H U = point_[j] - point_[i];
ExactVec2H V = point_[l] - point_[k];
ExactVec2H D = point_[k] - point_[i];
Expand Down
7 changes: 4 additions & 3 deletions src/lib/geogram/mesh/mesh_surface_intersection_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,9 @@ namespace GEO {
);

void insert_constraint(index_t v1, index_t v2, index_t operand_bits) {
CDTBase2d::insert_constraint(v1,v2);
constraints_.push_back(bindex(v1,v2,bindex::KEEP_ORDER));
cnstr_operand_bits_.push_back(operand_bits);
CDTBase2d::insert_constraint(v1,v2);
}

/**
Expand Down Expand Up @@ -629,8 +630,8 @@ namespace GEO {
vector<index_t> facet_inclusion_bits_;
mutable std::map<trindex, Sign> pred_cache_;
bool use_pred_cache_insert_buffer_;
mutable std::vector< std::pair<trindex, Sign> >
pred_cache_insert_buffer_;
mutable std::vector< std::pair<trindex, Sign> > pred_cache_insert_buffer_;
vector<bindex> constraints_;
};

/**********************************************************************/
Expand Down

0 comments on commit 4fd0d73

Please sign in to comment.