Skip to content

Commit

Permalink
support -first and -second flags where first=A U (A^B), second=B U (A^B)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jul 13, 2016
1 parent 971cb94 commit 3faf80d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 17 deletions.
23 changes: 23 additions & 0 deletions src/cork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,26 @@ void resolveIntersections(
corkMesh2CorkTriMesh(&cmIn0, out);
}

void computeFirst(
CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out
) {
CorkMesh cmIn0, cmIn1;
corkTriMesh2CorkMesh(in0, &cmIn0);
corkTriMesh2CorkMesh(in1, &cmIn1);

cmIn0.boolFirst(cmIn1);

corkMesh2CorkTriMesh(&cmIn0, out);
}

void computeSecond(
CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out
) {
CorkMesh cmIn0, cmIn1;
corkTriMesh2CorkMesh(in0, &cmIn0);
corkTriMesh2CorkMesh(in1, &cmIn1);

cmIn1.boolFirst(cmIn0);

corkMesh2CorkTriMesh(&cmIn1, out);
}
4 changes: 4 additions & 0 deletions src/cork.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ void computeSymmetricDifference(
// such that the two surfaces are now connected.
void resolveIntersections(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out);

// result = A cut by B
void computeFirst(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out);
// result = B cut by A
void computeSecond(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out);
5 changes: 4 additions & 1 deletion src/isct/triangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3295,8 +3295,11 @@ struct behavior *b;
int increment;
int meshnumber;
#endif /* not TRILIBRARY */
int i, j, k;
int i, j;
#ifndef CDT_ONLY
int k;
char workstring[FILENAMESIZE];
#endif

b->poly = b->refine = b->quality = 0;
b->vararea = b->fixedarea = b->usertest = 0;
Expand Down
11 changes: 9 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,15 @@ int main(int argc, char *argv[])
" and output the connected mesh with those\n"
" intersections made explicit and connected",
genericBinaryOp(resolveIntersections));


cmds.regCmd("first",
"-first in0 in1 out Compute the first mesh in0 cut by the second mesh in1,\n"
" and output the result",
genericBinaryOp(computeFirst));
cmds.regCmd("second",
"-second in0 in1 out Compute the second mesh in1 cut by the first mesh in0,\n"
" and output the result",
genericBinaryOp(computeSecond));

cmds.runCommands(arg_it, args.end());

return 0;
Expand Down
28 changes: 14 additions & 14 deletions src/mesh/mesh.bool.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,17 @@ void Mesh<VertData,TriData>::boolXor(Mesh &rhs)
});
}















template<class VertData, class TriData>
void Mesh<VertData,TriData>::boolFirst(Mesh &rhs)
{
BoolProblem bprob(this);
bprob.doSetup(rhs);
bprob.doDeleteAndFlip([](byte data) -> typename BoolProblem::TriCode {
if(data == 1) // part of op 1 OUTSIDE op 0
return BoolProblem::DELETE_TRI;
else // otherwise
return BoolProblem::KEEP_TRI;
});
}
1 change: 1 addition & 0 deletions src/mesh/mesh.decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class Mesh
void boolDiff(Mesh &rhs);
void boolIsct(Mesh &rhs);
void boolXor(Mesh &rhs);
void boolFirst(Mesh &rhs);

private: // Internal Formats
struct Tri {
Expand Down

0 comments on commit 3faf80d

Please sign in to comment.