I am new to MMA and best way to learn is plow though examples ! I copied all the executable lines from the OPEN CASADE LINK example for Surgical fixation plate.
https://reference.wolfram.com/language/OpenCascadeLink/tutorial/SurgicalFixationPlate.html
All output was following the example well except at the point where - w1 = OpenCascadeShapeWire[{e1, e2, e3, e4, e5,e6}] (* gives failed output !*). When I each component individually, using the following -
OpenCascadeShapeType[e1] (*wire*)
OpenCascadeShapeType[e2](*wire*)
OpenCascadeShapeType[e3](*edge*)
OpenCascadeShapeType[e4](*edge*)
OpenCascadeShapeType[e5](*wire*)
OpenCascadeShapeType[e6](*wire*)
note that for e3 and e4 the type is edge.
The failed command is restricted to "Combine several wires into a single wire." - the components must be a wire. But they are not per the type command above.
I suspect the issue is in here - but I do not have sufficient understanding how to correct this. I tried the notebook assistant but to no avail.
I removed all output from my working code so save people the time from inserting the code in the part by part basis as presented in the example link. Funny - when I run the complete code - all in 1 cell, i get a lot of errors. When running it in sections as presented in the example, each section completes as the example shows (except for the problem items I discuss above). This is the code all together without any intermediate outputs.
Needs["OpenCascadeLink`"];
Needs["NDSolve`FEM`"];
length = 16;
thickness = 0.3;
width = 1;
waveAmplitude = 0.15;
numberFixationHoles = 3;
radiusFixationHoles = 0.3;
ϕ = length/3 1/(numberFixationHoles*2);
fixationEdge[x_] := Sin[(π x)/ϕ]
centralEdge[x_] := fixationEdge[x/6]
edge[x_] :=
width/2 +
waveAmplitude*
Which[x <= length/3, fixationEdge[x],
length/3 < x <= length/2, -centralEdge[x]]
edgePlot =
Plot[edge[x + length/2], {x, -length/2, 0}, AspectRatio -> Automatic,
ImageSize -> Large, Ticks -> {True, False}]
discretedEdge = DiscretizeGraphics[edgePlot]
topEdgeCoords = MeshCoordinates[discretedEdge][[1 ;; -1 ;; 15]];
topEdgeCoords[[-1, 1]] = 0.;
Show[discretedEdge, Graphics[{Red, Point[topEdgeCoords]}]]
topEdgeSpline = BSplineCurve[topEdgeCoords];
Graphics[topEdgeSpline]
leftCircleCenter = {-length/2 + width/2, 0};
circleSegement = Circle[leftCircleCenter, width, {π/2, π}];
extensionLine =
Line[{topEdgeCoords[[1]], {leftCircleCenter[[1]] - width,
topEdgeCoords[[1, 2]]}}]
Graphics[{topEdgeSpline, {Red, extensionLine}, circleSegement}]
intersectionPoint = RegionIntersection[extensionLine, circleSegement]
leftIntersectionCoord = intersectionPoint[[1, 1]]
leftIntersectAngle =
NSolveValues[
leftIntersectionCoord[[1]] ==
leftCircleCenter[[1]] + width*Cos[θ], θ,
MaxRoots -> 1][[1]]
leftLine = Line[{leftIntersectionCoord, topEdgeCoords[[1]]}];
leftEdge =
Circle[leftCircleCenter,
width, {2 π - leftIntersectAngle, π}];
Graphics[{topEdgeSpline, {Red, leftLine}, leftEdge}]
rt1 = ReflectionTransform[{1, 0}, {0, 0}];
tr1 = TransformedRegion[topEdgeSpline, rt1];
tr2 = TransformedRegion[leftLine, rt1];
tr3 = TransformedRegion[leftEdge, rt1];
tr3 = tr3 /. Circle[c_List, r_, s_] :> Circle[c, r, {0, s[[1]]}];
Graphics[{topEdgeSpline, leftLine,
leftEdge, {Blue, tr1}, {Red, tr2}, {Magenta, tr3}}]
e1 = OpenCascadeShape[leftEdge];
e2 = OpenCascadeShape[leftLine];
e3 = OpenCascadeShape[topEdgeSpline];
e4 = OpenCascadeShape[tr1];
e5 = OpenCascadeShape[tr2];
e6 = OpenCascadeShape[tr3];
OpenCascadeShapeType[e1] (*wire*)
OpenCascadeShapeType[e2](*wire*)
OpenCascadeShapeType[e3](*edge*)
OpenCascadeShapeType[e4](*edge*)
OpenCascadeShapeType[e5](*wire*)
OpenCascadeShapeType[e6](*wire*)
{e1, e2, e3, e4, e5, e6}
w1 = OpenCascadeShapeWire[{e1, e2, e3, e4, e5,
e6}] (*gives failed output!*)
w11 = OpenCascadeShapeWire[{e1}] (*inserted by sak for validation*)
w12 = OpenCascadeShapeWire[{e2}]
w13 = OpenCascadeShapeWire[{e3}]
w14 = OpenCascadeShapeWire[{e4}]
w15 = OpenCascadeShapeWire[{e5}]
w16 = OpenCascadeShapeWire[{e6}]
rt2 = ReflectionTransform[{0, -1}, {0, 0}];
gt1 = GeometricTransformation[topEdgeSpline, rt2];
gt2 = GeometricTransformation[leftLine, rt2];
gt3 = GeometricTransformation[leftEdge, rt2];
Graphics[{topEdgeSpline, leftLine,
leftEdge, {Blue, gt1}, {Red, gt2}, {Magenta, gt3}}]
w2 = OpenCascadeShapeTransformation[w1, rt2]
face = OpenCascadeShapeFace[{w1, w2}]
bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[face];
bmesh["Wireframe"]