MakeSurface:
PUBLIC PROC [
surface: Surface,
octreeMode: OctreeMode,
valueProc: ValueProc,
threshold: REAL ← 1.0,
triangulate: BOOL ¬ FALSE,
vertexOkProc: VertexOkProc ← NIL,
polygonOkProc: PolygonOkProc ← NIL,
normalProc: NormalProc ← NIL,
colorProc: ColorProc ← NIL,
textureProc: TextureProc ← NIL,
statusProc: StatusProc ← NIL,
tolerance: REAL ← 0.0001,
edgeMode: EdgeMode ← binarySectioning,
clientData: REF ANY ← NIL]
~ {
IF statusProc =
NIL
OR statusProc[$MakeOctree] # $Abort
THEN {
surface.octree ← MakeOctree[octreeMode, valueProc, threshold, normalProc, statusProc, clientData];
[] ¬ MakePolygons[surface, valueProc, threshold, triangulate, vertexOkProc, polygonOkProc, normalProc, colorProc, textureProc, statusProc, tolerance, edgeMode, clientData];
};
};
MakePolygons:
PUBLIC PROC [
surface: Surface,
valueProc: ValueProc,
threshold: REAL ← 1.0,
triangulate: BOOL ¬ FALSE,
vertexOkProc: VertexOkProc ← NIL,
polygonOkProc: PolygonOkProc ← NIL,
normalProc: NormalProc ← NIL,
colorProc: ColorProc ← NIL,
textureProc: TextureProc ← NIL,
statusProc: StatusProc ← NIL,
tolerance: REAL ← 0.0001,
edgeMode: EdgeMode ← binarySectioning,
clientData: REF ANY ← NIL]
RETURNS [nEvaluations: INT ¬ 0]
~ {
ENABLE abort => CONTINUE;
CheckStatus:
PROC [type:
ATOM, commatize:
BOOL ←
FALSE] ~ {
IF statusProc = NIL THEN RETURN;
IF statusProc[type] = $Abort THEN ERROR abort;
IF NOT Rope.IsEmpty[msg] AND commatize THEN msg ← Rope.Concat[", ", msg];
IF NOT Rope.IsEmpty[msg] AND statusProc[msg] = $Abort THEN ERROR abort;
};
cubeProc: CubeProc ~ {
IF statusProc # NIL AND statusProc[cube] = $Abort THEN RETURN[FALSE];
};
msg: ROPE;
IF surface = NIL OR surface.octree = NIL THEN RETURN;
CheckStatus[$SetCorners, TRUE];
nEvaluations ¬
ImplicitPoints.SetTerminalCubeCornerValuesAndCrossedPoints[
surface.octree.root, valueProc, threshold, normalProc,
cubeProc, tolerance, edgeMode, clientData];
CheckStatus[$MakeVertices];
msg ← ImplicitPoints.SetSurfaceVertices[surface, surface.octree.root, valueProc, threshold, normalProc, cubeProc, vertexOkProc, clientData];
CheckStatus[$MakePolygons];
msg ← ImplicitPolygons.SetSurfacePolygons[
surface, surface.octree.root, triangulate, valueProc, threshold, cubeProc, polygonOkProc, clientData];
CheckStatus[$MakeNormals, TRUE];
ImplicitPolygons.SetFaceNormalsCenters[surface];
msg ← "normals";
CheckStatus[$MakeTextures, TRUE];
ImplicitPoints.SetVertexTextures[surface, textureProc, cubeProc, clientData];
ImplicitPoints.SetVertexColors[surface, colorProc, cubeProc, clientData];
msg ← IF textureProc # NIL THEN "texture" ELSE NIL;
CheckStatus[$Done];
};