Debian Codegraph @

src/scene/x3d/x3dnodes_standard_nurbs.inc

raw
1 {%MainUnit x3dnodes.pas}
2 {
3 Copyright 2008-2023 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 {$ifdef read_interface}
18 { Base type for nodes that provide control curve information in 2D space. }
19 TAbstractNurbsControlCurveNode = class(TAbstractNode)
20 {$I auto_generated_node_helpers/x3dnodes_x3dnurbscontrolcurvenode.inc}
21 end;
22
23 { Base type for all geometry node types that are created parametrically
24 and use control points to describe the final shape of the surface. }
25 TAbstractParametricGeometryNode = class(TAbstractGeometryNode)
26 {$I auto_generated_node_helpers/x3dnodes_x3dparametricgeometrynode.inc}
27 end;
28
29 { Abstract geometry type for all types of NURBS surfaces. }
30 TAbstractNurbsSurfaceGeometryNode = class(TAbstractParametricGeometryNode)
31 protected
32 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
33 public
34 function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override;
35 function LocalBoundingBox(State: TX3DGraphTraverseState;
36 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
37 function BoundingBox(State: TX3DGraphTraverseState;
38 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
39 function TrianglesCount(State: TX3DGraphTraverseState;
40 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
41 function InternalCoord(State: TX3DGraphTraverseState;
42 out ACoord: TMFVec3f): boolean; override;
43 function CoordField: TSFNode; override;
44 function SolidField: TSFBool; override;
45
46 { Get the position of a point on the surface.
47
48 The returned position is in the local transformation space of this shape.
49 This method is guaranteed to work the same,
50 regardless if this node is part of any TX3DRootNode and TCastleSceneCore
51 or not.
52
53 @param U First parameter of the parametric surface, in [0..1] range.
54 @param V Second parameter of the parametric surface, in [0..1] range.
55 @param(OutputNormal Optional. If non-nil, will be set to the normal,
56 that is, normalized direction in 3D that is orthogonal to the surface
57 at this point.) }
58 function Point(const U, V: Single; const OutputNormal: PVector3 = nil): TVector3;
59
60 {$I auto_generated_node_helpers/x3dnodes_x3dnurbssurfacegeometrynode.inc}
61 end;
62
63 { Groups a set of curve segments for a composite contour, for X3D.
64
65 X3D cannot share implementation with VRML 2.0 version (TContour2DNode_2),
66 since for VRML 2.0 this is a valid geometry node (TAbstractGeometryNode
67 descendant). }
68 TContour2DNode = class(TAbstractNode)
69 protected
70 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
71 public
72 class function ForVRMLVersion(const Version: TX3DVersion): boolean; override;
73 {$I auto_generated_node_helpers/x3dnodes_contour2d.inc}
74 end;
75
76 { Piecewise linear curve segment as a part
77 of a trimming contour in the u, v domain of a surface. }
78 TContourPolyline2DNode = class(TAbstractNurbsControlCurveNode)
79 {$I auto_generated_node_helpers/x3dnodes_contourpolyline2d.inc}
80 end;
81
82 { 3D coordinates defines using double precision floating point values. }
83 TCoordinateDoubleNode = class(TAbstractCoordinateNode)
84 public
85 function CoordCount: Cardinal; override;
86 {$I auto_generated_node_helpers/x3dnodes_coordinatedouble.inc}
87 end;
88
89 { Visible NURBS curve in 3D. }
90 TNurbsCurveNode = class(TAbstractParametricGeometryNode)
91 protected
92 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
93 public
94 class function ForVRMLVersion(const Version: TX3DVersion): boolean; override;
95 function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override;
96 function LocalBoundingBox(State: TX3DGraphTraverseState;
97 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
98 function BoundingBox(State: TX3DGraphTraverseState;
99 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
100 function TrianglesCount(State: TX3DGraphTraverseState;
101 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
102 function InternalCoord(State: TX3DGraphTraverseState;
103 out ACoord: TMFVec3f): boolean; override;
104 function CoordField: TSFNode; override;
105
106 { Make this NURBS curve equal to a piecewise Bezier curve by setting appropriate
107 "knot". This looks at @link(ControlPoint) count and @link(Order)
108 (set Order = 4 for a typical cubic Bezier curve). }
109 procedure PiecewiseBezier;
110
111 { Get the position of a point on the curve.
112
113 The returned position is in the local transformation space of this shape.
114 This method is guaranteed to work the same,
115 regardless if this node is part of any TX3DRootNode and TCastleSceneCore
116 or not.
117
118 @param U The place on a curve, in [0..1] range.
119 @param(Tangent Optional. If non-nil, will be set to the tangent,
120 that is, direction in 3D in which the curve is going.) }
121 function Point(const U: Single; const Tangent: PVector3 = nil): TVector3;
122
123 {$I auto_generated_node_helpers/x3dnodes_nurbscurve.inc}
124 end;
125 TNurbsCurveNode_3 = TNurbsCurveNode;
126
127 { Trimming segment that is expressed a NURBS curve and is
128 part of a trimming contour in the u,v domain of the surface. }
129 TNurbsCurve2DNode = class(TAbstractNurbsControlCurveNode)
130 {$I auto_generated_node_helpers/x3dnodes_nurbscurve2d.inc}
131 end;
132
133 { Interpolate (animate) orientations as tangent vectors of the 3D NURBS curve. }
134 TNurbsOrientationInterpolatorNode = class(TAbstractChildNode)
135 strict private
136 procedure EventSet_FractionReceive(const Event: TX3DEvent; const Value: TX3DField;
137 const Time: TX3DTime);
138 protected
139 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
140 public
141 constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override;
142 {$I auto_generated_node_helpers/x3dnodes_nurbsorientationinterpolator.inc}
143 end;
144
145 { Visible NURBS 3D surface. }
146 TNurbsPatchSurfaceNode = class(TAbstractNurbsSurfaceGeometryNode)
147 {$I auto_generated_node_helpers/x3dnodes_nurbspatchsurface.inc}
148 end;
149
150 { Interpolate (animate) positions along the 3D NURBS curve. }
151 TNurbsPositionInterpolatorNode = class(TAbstractChildNode)
152 strict private
153 procedure EventSet_FractionReceive(const Event: TX3DEvent; const Value: TX3DField;
154 const Time: TX3DTime);
155 protected
156 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
157 public
158 constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override;
159 class function ForVRMLVersion(const Version: TX3DVersion): boolean; override;
160
161 {$I auto_generated_node_helpers/x3dnodes_nurbspositioninterpolator.inc}
162 end;
163 TNurbsPositionInterpolatorNode_3 = TNurbsPositionInterpolatorNode;
164
165 { Groups a set of NURBS surface nodes to a common group
166 for rendering purposes, to ensure a common tesselation within the group. }
167 TNurbsSetNode = class(TAbstractChildNode)
168 public
169 { Implementation note: Fdgeometry is not enumerated in DirectEnumerateActive,
170 as it's not actually rendered from NurbsSet node.
171 Children here have to be placed elsewhere, in some Shape,
172 to actually get enumerated as "active". }
173 { }
174
175 {$I auto_generated_node_helpers/x3dnodes_nurbsset.inc}
176 end;
177
178 { Interpolate (animate) by sampling a position and normal at 3D NURBS surface
179 from an input 2D surface parameters. }
180 TNurbsSurfaceInterpolatorNode = class(TAbstractChildNode)
181 strict private
182 procedure EventSet_FractionReceive(const Event: TX3DEvent; const Value: TX3DField;
183 const Time: TX3DTime);
184 protected
185 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
186 public
187 constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override;
188 {$I auto_generated_node_helpers/x3dnodes_nurbssurfaceinterpolator.inc}
189 end;
190
191 { Path in 2D space (that can be constructed from NURBS curves,
192 or straight segments) extruded along a 3D NURBS curve.
193 @bold(Rendering of this node is not implemented yet.) }
194 TNurbsSweptSurfaceNode = class(TAbstractParametricGeometryNode)
195 protected
196 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
197 public
198 function SolidField: TSFBool; override;
199 function LocalBoundingBox(State: TX3DGraphTraverseState;
200 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
201 function VerticesCount(State: TX3DGraphTraverseState;
202 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
203 function TrianglesCount(State: TX3DGraphTraverseState;
204 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
205
206 {$I auto_generated_node_helpers/x3dnodes_nurbssweptsurface.inc}
207 end;
208
209 { Path in 2D space (that can be constructed from NURBS curves,
210 or straight segments) extruded along a 2D NURBS curve.
211 @bold(Rendering of this node is not implemented yet.) }
212 TNurbsSwungSurfaceNode = class(TAbstractParametricGeometryNode)
213 protected
214 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
215 public
216 function SolidField: TSFBool; override;
217 function LocalBoundingBox(State: TX3DGraphTraverseState;
218 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
219 function VerticesCount(State: TX3DGraphTraverseState;
220 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
221 function TrianglesCount(State: TX3DGraphTraverseState;
222 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
223
224 {$I auto_generated_node_helpers/x3dnodes_nurbsswungsurface.inc}
225 end;
226
227 { NURBS surface existing in the parametric domain of its surface host
228 specifying the mapping of the texture onto the surface.
229 @bold(Not implemented yet.) }
230 TNurbsTextureCoordinateNode = class(TAbstractNode)
231 {$I auto_generated_node_helpers/x3dnodes_nurbstexturecoordinate.inc}
232 end;
233
234 { Visible 3D NURBS surface (like a @link(TNurbsPatchSurfaceNode))
235 that is trimmed by a set of trimming loops.
236
237 @bold(The trimming is not implemented yet. This is rendered exactly
238 like the normal @link(TNurbsPatchSurfaceNode).) }
239 TNurbsTrimmedSurfaceNode = class(TAbstractNurbsSurfaceGeometryNode)
240 protected
241 function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override;
242 public
243 function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override;
244 {$I auto_generated_node_helpers/x3dnodes_nurbstrimmedsurface.inc}
245 end;
246
247 {$endif read_interface}
248
249 {$ifdef read_implementation}
250
251 function TAbstractNurbsSurfaceGeometryNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
252 begin
253 Result := FdcontrolPoint.Enumerate(Func);
254 if Result <> nil then Exit;
255
256 Result := FdtexCoord.Enumerate(Func);
257 if Result <> nil then Exit;
258 end;
259
260 class function TContour2DNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
261 begin
262 Result := Version.Major >= 3;
263 end;
264
265 function TContour2DNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
266 begin
267 Result := Fdchildren.Enumerate(Func);
268 if Result <> nil then Exit;
269 end;
270
271 function TCoordinateDoubleNode.CoordCount: Cardinal;
272 begin
273 Result := FdPoint.Items.Count;
274 end;
275
276 class function TNurbsCurveNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
277 begin
278 Result := Version.Major >= 3;
279 end;
280
281 function TNurbsCurveNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
282 begin
283 Result := FdcontrolPoint.Enumerate(Func);
284 if Result <> nil then Exit;
285 end;
286
287 { Convert X3D or VRML 97 NurbsCurve to LineSet. }
288 procedure NurbsCurveProxy(
289 const LS: TLineSetNode;
290 const ControlPoint: TVector3List;
291 const Tessellation, Order: Integer;
292 const FieldKnot, Weight: TDoubleList);
293 var
294 ResultCoord: TCoordinateNode;
295 Tess: Cardinal;
296 I: Integer;
297 Increase: Double;
298 Knot: TDoubleList;
299 NurbsCalculator: TNurbsCurveCalculator;
300 begin
301 if ControlPoint.Count = 0 then Exit;
302
303 if Order < 2 then
304 begin
305 WritelnWarning('VRML/X3D', 'NURBS order must be >= 2');
306 Exit;
307 end;
308
309 { We can be sure now that
310 - we have ControlPoint, non-nil, with at least 1 point.
311 - we have Order >= 2 }
312
313 { calculate correct Knot vector }
314 Knot := TDoubleList.Create;
315 Knot.Assign(FieldKnot);
316 NurbsKnotIfNeeded(Knot, ControlPoint.Count, Order, nkEndpointUniform);
317
318 { calculate tesselation: Tess, Increase }
319 Tess := ActualTessellation(Tessellation, ControlPoint.Count);
320 Increase := (Knot.Last - Knot.First) / (Tess - 1);
321
322 { make resulting Coordinate node }
323 ResultCoord := TCoordinateNode.Create('', LS.BaseUrl);
324 LS.FdCoord.Value := ResultCoord;
325
326 { calculate result Coordinate.point field }
327 ResultCoord.FdPoint.Items.Count := Tess;
328 NurbsCalculator := TNurbsCurveCalculator.Create(ControlPoint, Order, Knot, Weight);
329 try
330 for I := 0 to Tess - 1 do
331 ResultCoord.FdPoint.Items.L[I] := NurbsCalculator.GetPoint(
332 Knot.First + Increase * I, nil);
333 finally FreeAndNil(NurbsCalculator) end;
334
335 { set LineSet.vertexCount (otherwise it's coord will be ignored) }
336 LS.FdVertexCount.Items.Add(Tess);
337
338 FreeAndNil(Knot);
339 end;
340
341 function TNurbsCurveNode.Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode;
342 var
343 ControlPointList: TVector3List;
344 begin
345 Result := TLineSetNode.Create(X3DName, BaseUrl);
346 try
347 { TODO: we should handle here all TAbstractCoordinateNode }
348 if ControlPoint is TCoordinateNode then
349 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items
350 else
351 Exit;
352
353 NurbsCurveProxy(TLineSetNode(Result), ControlPointList, FdTessellation.Value,
354 FdOrder.Value, FdKnot.Items, FdWeight.Items);
355 except FreeAndNil(Result); raise end;
356 end;
357
358 function TNurbsCurveNode.CoordField: TSFNode;
359 begin
360 Result := FdControlPoint;
361 end;
362
363 { Although our BoundingBox and LocalBoundingBox do not rely on InternalCoord()
364 override, it is still necessary to react to animation of Coordinate node
365 points, see
366 http://www.web3d.org/x3d/content/examples/Basic/NURBS/_pages/page01.html }
367 function TNurbsCurveNode.InternalCoord(State: TX3DGraphTraverseState;
368 out ACoord: TMFVec3f): boolean;
369 begin
370 Result := true;
371 if FdControlPoint.Value is TCoordinateNode then // also checks that FdControlPoint.Value <> nil
372 ACoord := TCoordinateNode(FdControlPoint.Value).FdPoint
373 else
374 ACoord := nil;
375 end;
376
377 { We cannot simply override InternalCoord() and let bounding box be calculated
378 based on it. It would fail for curves with weigths. }
379 function TNurbsCurveNode.LocalBoundingBox(State: TX3DGraphTraverseState;
380 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
381 begin
382 if FdControlPoint.Value is TCoordinateNode then // also checks that FdControlPoint.Value <> nil
383 Result := NurbsBoundingBox(TCoordinateNode(FdControlPoint.Value).FdPoint.Items, FdWeight.Items)
384 else
385 Result := TBox3D.Empty;
386 end;
387
388 { We cannot simply override InternalCoord() and let bounding box be calculated
389 based on it. It would fail for curves with weigths. }
390 function TNurbsCurveNode.BoundingBox(State: TX3DGraphTraverseState;
391 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
392 begin
393 if FdControlPoint.Value is TCoordinateNode then // also checks that FdControlPoint.Value <> nil
394 Result := NurbsBoundingBox(TCoordinateNode(FdControlPoint.Value).FdPoint.Items, FdWeight.Items, State.Transformation.Transform)
395 else
396 Result := TBox3D.Empty;
397 end;
398
399 function TNurbsCurveNode.TrianglesCount(State: TX3DGraphTraverseState;
400 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
401 begin
402 Result := 0;
403 end;
404
405 procedure TNurbsCurveNode.PiecewiseBezier;
406 var
407 ControlPointCount: Integer;
408 begin
409 FdKnot.Items.Clear;
410
411 if ControlPoint is TCoordinateNode then
412 begin
413 ControlPointCount := TCoordinateNode(ControlPoint).FdPoint.Count;
414 NurbsKnotIfNeeded(FdKnot.Items, ControlPointCount, Order, nkPiecewiseBezier);
415 end;
416 end;
417
418 function TNurbsCurveNode.Point(const U: Single; const Tangent: PVector3): TVector3;
419 var
420 ControlPointList: TVector3List;
421 CurrentKnot: TDoubleList;
422 begin
423 if ControlPoint is TCoordinateNode then
424 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items
425 else
426 raise EInvalidNurbs.Create('Only NURBS with Coordinate node are supported');
427
428 if ControlPointList.Count = 0 then
429 raise EInvalidNurbs.Create('Only NURBS with at least 1 controlPoint are supported');
430
431 if Order < 2 then
432 raise EInvalidNurbs.Create('NURBS order must be >= 2');
433
434 { calculate correct CurrentKnot vector }
435 CurrentKnot := TDoubleList.Create;
436 CurrentKnot.Assign(FdKnot.Items);
437 NurbsKnotIfNeeded(CurrentKnot, ControlPointList.Count, Order, nkEndpointUniform);
438
439 Result := NurbsCurvePoint(ControlPointList,
440 MapRange(U, 0, 1, CurrentKnot.First, CurrentKnot.Last),
441 Order, CurrentKnot, FdWeight.Items, Tangent);
442
443 FreeAndNil(CurrentKnot);
444 end;
445
446 { TNurbsOrientationInterpolatorNode ------------------------------------------ }
447
448 constructor TNurbsOrientationInterpolatorNode.Create(const AX3DName, ABaseUrl: String);
449 begin
450 inherited;
451 EventSet_Fraction.AddNotification({$ifdef FPC}@{$endif} EventSet_FractionReceive);
452 end;
453
454 function TNurbsOrientationInterpolatorNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
455 begin
456 Result := FdcontrolPoint.Enumerate(Func);
457 if Result <> nil then Exit;
458 end;
459
460 procedure TNurbsOrientationInterpolatorNode.EventSet_FractionReceive(
461 const Event: TX3DEvent; const Value: TX3DField; const Time: TX3DTime);
462 var
463 ControlPointList: TVector3List;
464 Knot: TDoubleList;
465 Tangent: TVector3;
466 Orientation: TVector4;
467 begin
468 if not EventValue_Changed.SendNeeded then Exit;
469
470 { TODO: we should handle here all TAbstractCoordinateNode }
471 if ControlPoint is TCoordinateNode then
472 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items
473 else
474 Exit;
475
476 if ControlPointList.Count = 0 then Exit;
477
478 if FdOrder.Value < 2 then
479 begin
480 WritelnWarning('VRML/X3D', 'NURBS order must be >= 2');
481 Exit;
482 end;
483
484 { We can be sure now that
485 - we have ControlPointList, non-nil, with at least 1 point.
486 - we have Order >= 2 }
487
488 { calculate correct Knot vector }
489 Knot := TDoubleList.Create;
490 Knot.Assign(FdKnot.Items);
491 NurbsKnotIfNeeded(Knot, ControlPointList.Count, FdOrder.Value, nkEndpointUniform);
492
493 NurbsCurvePoint(ControlPointList,
494 (Value as TSFFloat).Value,
495 FdOrder.Value, Knot, FdWeight.Items, @Tangent);
496
497 FreeAndNil(Knot);
498
499 { calculate Orientation from Tangent.
500 For this, we treat Tangent like "camera direction", and we have to set
501 "camera up" as anything orthogonal to direction. }
502 Orientation := OrientationFromDirectionUp(Tangent, AnyOrthogonalVector(Tangent));
503
504 EventValue_Changed.Send(Orientation, Time);
505 end;
506
507 { Converting X3D NurbsPatchSurface and VRML 97 NurbsSurface to
508 IndexedQuadSet. This is for Proxy methods implementation. }
509 procedure NurbsPatchSurfaceProxy(
510 const QS: TIndexedQuadSetNode;
511 const ControlPoint: TVector3List;
512 const UTessellation, VTessellation, UDimension, VDimension, UOrder, VOrder: Integer;
513 const FieldUKnot, FieldVKnot, Weight: TDoubleList;
514 const PossiblyUClosed, PossiblyVClosed, Solid, Ccw: boolean;
515 const TexCoord: TX3DNode);
516
517 const
518 { This has to be slightly larger than normal epsilon
519 (test nurbs_dune_primitives.x3dv). }
520 ClosedCheckEpsilon = 0.000001;
521
522 procedure LogClosed(Value: boolean);
523 begin
524 if Value then
525 WritelnLog('NURBS', 'Checking if NURBS surface is really closed (because it''s VRML 97 NurbsSurface or NurbsPatchSurface with .xClosed is TRUE): no, ignoring (otherwise would cause invalid geometry/normals)')
526 else
527 WritelnLog('NURBS', 'Checking if NURBS surface is really closed: yes');
528 end;
529
530 function CalculateUClosed: boolean;
531 var
532 J: Integer;
533 begin
534 Result := PossiblyUClosed;
535 if Result then
536 begin
537 for J := 0 to VDimension - 1 do
538 if not TVector3.Equals(
539 ControlPoint.L[ J * UDimension],
540 ControlPoint.L[UDimension - 1 + J * UDimension], ClosedCheckEpsilon) then
541 begin
542 Result := false;
543 Break;
544 end;
545 LogClosed(Result);
546 end;
547 end;
548
549 function CalculateVClosed: boolean;
550 var
551 I: Integer;
552 begin
553 Result := PossiblyVClosed;
554 if Result then
555 begin
556 for I := 0 to UDimension - 1 do
557 if not TVector3.Equals(
558 ControlPoint.L[I ],
559 ControlPoint.L[I + (VDimension - 1) * UDimension], ClosedCheckEpsilon) then
560 begin
561 Result := false;
562 Break;
563 end;
564 LogClosed(Result);
565 end;
566 end;
567
568 var
569 UTess, VTess: Cardinal;
570 UClosed, VClosed: boolean;
571
572 function MakeIndex(I, J: Cardinal): Cardinal;
573 begin
574 if (I = UTess - 1) and UClosed then I := 0;
575 if (J = VTess - 1) and VClosed then J := 0;
576 Result := I + J * UTess;
577 end;
578
579 var
580 ResultCoord, ResultNormal: TVector3List;
581 ResultIndex: TInt32List;
582 I, J, NextIndex: Cardinal;
583 UIncrease, VIncrease: Double;
584 UKnot, VKnot: TDoubleList;
585 ResultTexCoord: TVector2List;
586 Normal: TVector3;
587 NurbsCalculator: TNurbsSurfaceCalculator;
588 begin
589 if ControlPoint.Count = 0 then Exit;
590
591 if UDimension * VDimension <>
592 Integer(ControlPoint.Count) then
593 begin
594 WritelnWarning('VRML/X3D', Format('Number of coordinates in Nurbs[Patch]Surface.controlPoint (%d) doesn''t match uDimension * vDimension (%d * %d = %d)',
595 [ ControlPoint.Count,
596 UDimension, VDimension,
597 UDimension * VDimension ]));
598 Exit;
599 end;
600
601 if (UDimension < 0) or
602 (VDimension < 0) then
603 begin
604 WritelnWarning('VRML/X3D', 'Nurbs[Patch]Surface.u/vDimension must be >= 0');
605 Exit;
606 end;
607
608 if (UOrder < 2) or
609 (VOrder < 2) then
610 begin
611 WritelnWarning('VRML/X3D', 'NURBS order must be >= 2');
612 Exit;
613 end;
614
615 { We can be sure now that we have
616 - correct ControlPoint, non-nil, with at least 1 point.
617 - uDimension, vDimension match ControlPoint count, and are > 0.
618 - we have Order >= 2.
619 }
620
621 { calculate actual XClosed values, using PossiblyXClosed values.
622
623 For X3D:
624
625 - The PossiblyXClosed come from xClosed fields. Still, we have to check
626 them.
627
628 Since we use xClosed fields not only to calculate normals,
629 but to actually set the geometry indexes, we have to check them
630 carefully and avoid using if look bad. Otherwise not only the normals,
631 but the whole geometry would look bad when xClosed fields are wrongly
632 set to TRUE.
633
634 Moreover, X3D spec says "If the last control point is not identical
635 with the first control point, the field is ignored."
636 for X3DNurbsSurfaceGeometryNode. So it seems the implementation
637 isn't supposed to "trust" xClosed = TRUE value anyway (that's also
638 why no VRML warning is done about it, although we log it).
639 Examples of such wrong xClosed = TRUE settings may be found
640 even on web3d.org examples, see
641 http://www.web3d.org/x3d/content/examples/NURBS/
642 e.g. "Fred The Bunny" in X3d.)
643
644 For VRML 97 NurbsSurface, these are always true, we have to always
645 check this for VRML 97 NurbsSurface. }
646
647 UClosed := CalculateUClosed;
648 VClosed := CalculateVClosed;
649
650 { calculate correct UKnot, VKnot vectors }
651 UKnot := TDoubleList.Create;
652 UKnot.Assign(FieldUKnot);
653 NurbsKnotIfNeeded(UKnot, UDimension, UOrder, nkEndpointUniform);
654 VKnot := TDoubleList.Create;
655 VKnot.Assign(FieldVKnot);
656 NurbsKnotIfNeeded(VKnot, VDimension, VOrder, nkEndpointUniform);
657
658 { calculate tesselation: xTess, xIncrease }
659 UTess := ActualTessellation(UTessellation, UDimension);
660 VTess := ActualTessellation(VTessellation, VDimension);
661 UIncrease := (UKnot.Last - UKnot.First) / (UTess - 1);
662 VIncrease := (VKnot.Last - VKnot.First) / (VTess - 1);
663
664 { make resulting Coordinate and Normal nodes }
665 QS.FdCoord.Value := TCoordinateNode.Create('', QS.BaseUrl);
666 ResultCoord := (QS.FdCoord.Value as TCoordinateNode).FdPoint.Items;
667 ResultCoord.Count := UTess * VTess;
668
669 QS.FdNormal.Value := TNormalNode.Create('', QS.BaseUrl);
670 ResultNormal := (QS.FdNormal.Value as TNormalNode).FdVector.Items;
671 ResultNormal.Count := UTess * VTess;
672
673 NurbsCalculator := TNurbsSurfaceCalculator.Create(ControlPoint,
674 UDimension, VDimension,
675 UOrder, VOrder,
676 UKnot, VKnot,
677 Weight);
678 try
679 { calculate result Coordinate.point and Normal.vector field }
680 for I := 0 to UTess - 1 do
681 for J := 0 to VTess - 1 do
682 begin
683 ResultCoord.L[I + J * UTess] :=
684 NurbsCalculator.GetPoint(
685 UKnot.First + UIncrease * I,
686 VKnot.First + VIncrease * J,
687 @Normal);
688 if Ccw then
689 ResultNormal.L[I + J * UTess] := Normal else
690 ResultNormal.L[I + J * UTess] := -Normal;
691 end;
692 finally FreeAndNil(NurbsCalculator) end;
693
694 { For now, don't use normal values --- they are nonsense at the edges
695 of the surface? See nurbs_curve_interpolators.x3dv for demo. }
696 QS.FdNormal.Value := nil;
697
698 { calculate index field }
699 ResultIndex := QS.FdIndex.Items;
700 ResultIndex.Count := 4 * (UTess - 1) * (VTess - 1);
701 NextIndex := 0;
702 for I := 1 to UTess - 1 do
703 for J := 1 to VTess - 1 do
704 begin
705 { This order (important for solid = TRUE values) is compatible
706 with white dune and octagaplayer. }
707 ResultIndex.L[NextIndex] := MakeIndex(I , J ); Inc(NextIndex);
708 ResultIndex.L[NextIndex] := MakeIndex(I-1, J ); Inc(NextIndex);
709 ResultIndex.L[NextIndex] := MakeIndex(I-1, J-1); Inc(NextIndex);
710 ResultIndex.L[NextIndex] := MakeIndex(I , J-1); Inc(NextIndex);
711 end;
712 Assert(NextIndex = Cardinal(ResultIndex.Count));
713
714 QS.FdSolid.Value := Solid;
715 QS.FdCcw.Value := Ccw;
716
717 { calculate texCoord field }
718 QS.FdTexCoord.Value := TexCoord;
719 if QS.FdTexCoord.Value = nil then
720 begin
721 { X3D spec says "By default, texture coordinates in the unit square
722 (or cube for 3D coordinates) are generated automatically
723 from the parametric subdivision.". I think this means that tex coords
724 S/T = 0..1 range from starting to ending knot. }
725 QS.FdTexCoord.Value := TTextureCoordinateNode.Create('', QS.BaseUrl);
726 ResultTexCoord := (QS.FdTexCoord.Value as TTextureCoordinateNode).FdPoint.Items;
727 ResultTexCoord.Count := UTess * VTess;
728 for I := 0 to UTess - 1 do
729 for J := 0 to VTess - 1 do
730 ResultTexCoord.L[I + J * UTess] := Vector2(
731 I / (UTess - 1),
732 J / (VTess - 1));
733 end;
734
735 FreeAndNil(UKnot);
736 FreeAndNil(VKnot);
737 end;
738
739 function TAbstractNurbsSurfaceGeometryNode.Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode;
740 var
741 ControlPointList: TVector3List;
742 begin
743 Result := TIndexedQuadSetNode.Create(X3DName, BaseUrl);
744 try
745 { TODO: we should handle here all TAbstractCoordinateNode }
746 if ControlPoint <> nil then
747 begin
748 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items;
749 NurbsPatchSurfaceProxy(TIndexedQuadSetNode(Result),
750 ControlPointList,
751 FdUTessellation.Value,
752 FdVTessellation.Value,
753 FdUDimension.Value,
754 FdVDimension.Value,
755 FdUOrder.Value,
756 FdVOrder.Value,
757 FdUKnot.Items,
758 FdVKnot.Items,
759 FdWeight.Items,
760 FdUClosed.Value,
761 FdVClosed.Value,
762 FdSolid.Value,
763 true { ccw always true for X3D NurbsPatchSurface },
764 FdTexCoord.Value);
765 end;
766
767 { Note: In case of null / invalid / unhandled ControlPoint,
768 we still return valid (just empty) IndexedQuadSet node. }
769 except FreeAndNil(Result); raise end;
770 end;
771
772 function TAbstractNurbsSurfaceGeometryNode.CoordField: TSFNode;
773 begin
774 Result := FdControlPoint;
775 end;
776
777 { Although our BoundingBox and LocalBoundingBox do not rely on InternalCoord()
778 override, it is still necessary to react to animation of Coordinate node
779 points, see
780 http://www.web3d.org/x3d/content/examples/Basic/NURBS/_pages/page01.html }
781 function TAbstractNurbsSurfaceGeometryNode.InternalCoord(State: TX3DGraphTraverseState;
782 out ACoord: TMFVec3f): boolean;
783 begin
784 Result := true;
785 if FdControlPoint.Value is TCoordinateNode then // also checks that FdControlPoint.Value <> nil
786 ACoord := TCoordinateNode(FdControlPoint.Value).FdPoint
787 else
788 ACoord := nil;
789 end;
790
791 { We cannot simply override InternalCoord() and let bounding box be calculated
792 based on it. It would fail for curves with weigths. }
793 function TAbstractNurbsSurfaceGeometryNode.LocalBoundingBox(State: TX3DGraphTraverseState;
794 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
795 begin
796 if FdControlPoint.Value is TCoordinateNode then // also checks that FdControlPoint.Value <> nil
797 Result := NurbsBoundingBox(TCoordinateNode(FdControlPoint.Value).FdPoint.Items, FdWeight.Items)
798 else
799 Result := TBox3D.Empty;
800 end;
801
802 { We cannot simply override InternalCoord() and let bounding box be calculated
803 based on it. It would fail for curves with weigths. }
804 function TAbstractNurbsSurfaceGeometryNode.BoundingBox(State: TX3DGraphTraverseState;
805 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
806 begin
807 if FdControlPoint.Value is TCoordinateNode then // also checks that FdControlPoint.Value <> nil
808 Result := NurbsBoundingBox(TCoordinateNode(FdControlPoint.Value).FdPoint.Items, FdWeight.Items, State.Transformation.Transform)
809 else
810 Result := TBox3D.Empty;
811 end;
812
813 function TAbstractNurbsSurfaceGeometryNode.TrianglesCount(State: TX3DGraphTraverseState;
814 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
815 var
816 UTess, VTess: Cardinal;
817 begin
818 if (FdUDimension.Value > 0) and
819 (FdVDimension.Value > 0) then
820 begin
821 UTess := ActualTessellation(FdUTessellation.Value, FdUDimension.Value);
822 VTess := ActualTessellation(FdVTessellation.Value, FdVDimension.Value);
823 Result := (UTess - 1) * (VTess - 1) * 2;
824 end else
825 Result := 0;
826 end;
827
828 function TAbstractNurbsSurfaceGeometryNode.SolidField: TSFBool;
829 begin
830 Result := FdSolid;
831 end;
832
833 function TAbstractNurbsSurfaceGeometryNode.Point(const U, V: Single; const OutputNormal: PVector3 = nil): TVector3;
834 var
835 ControlPointList: TVector3List;
836 UKnot, VKnot: TDoubleList;
837 begin
838 if ControlPoint is TCoordinateNode then
839 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items
840 else
841 raise EInvalidNurbs.Create('Only NURBS with Coordinate node are supported');
842
843 if ControlPointList.Count = 0 then
844 raise EInvalidNurbs.Create('Only NURBS with at least 1 controlPoint are supported');
845
846 if FdUDimension.Value * FdVDimension.Value <>
847 Integer(ControlPointList.Count) then
848 raise EInvalidNurbs.CreateFmt('Number of coordinates in NURBS surface controlPoint (%d) doesn''t match uDimension * vDimension (%d * %d = %d)', [
849 ControlPointList.Count,
850 FdUDimension.Value,
851 FdVDimension.Value,
852 FdUDimension.Value * FdVDimension.Value
853 ]);
854
855 if (FdUDimension.Value < 0) or
856 (FdVDimension.Value < 0) then
857 raise EInvalidNurbs.Create('NURBS surface u/vDimension must be >= 0');
858
859 if (FdUOrder.Value < 2) or
860 (FdVOrder.Value < 2) then
861 raise EInvalidNurbs.Create('NURBS surface u/vOrder must be >= 2');
862
863 { We can be sure now that we have
864 - correct ControlPointList, non-nil, with at least 1 point.
865 - uDimension, vDimension match ControlPointList count, and are > 0.
866 - we have Order >= 2.
867 }
868
869 { calculate correct UKnot, VKnot vectors }
870 UKnot := TDoubleList.Create;
871 UKnot.Assign(FdUKnot.Items);
872 NurbsKnotIfNeeded(UKnot, FdUDimension.Value, FdUOrder.Value, nkEndpointUniform);
873 VKnot := TDoubleList.Create;
874 VKnot.Assign(FdVKnot.Items);
875 NurbsKnotIfNeeded(VKnot, FdVDimension.Value, FdVOrder.Value, nkEndpointUniform);
876
877 Result :=
878 NurbsSurfacePoint(ControlPointList,
879 FdUDimension.Value,
880 FdVDimension.Value,
881 U,
882 V,
883 FdUOrder.Value,
884 FdVOrder.Value,
885 UKnot,
886 VKnot,
887 FdWeight.Items,
888 OutputNormal);
889
890 FreeAndNil(UKnot);
891 FreeAndNil(VKnot);
892 end;
893
894 constructor TNurbsPositionInterpolatorNode.Create(const AX3DName, ABaseUrl: String);
895 begin
896 inherited;
897 EventSet_Fraction.AddNotification({$ifdef FPC}@{$endif} EventSet_FractionReceive);
898 end;
899
900 class function TNurbsPositionInterpolatorNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
901 begin
902 Result := Version.Major >= 3;
903 end;
904
905 function TNurbsPositionInterpolatorNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
906 begin
907 Result := FdcontrolPoint.Enumerate(Func);
908 if Result <> nil then Exit;
909 end;
910
911 procedure TNurbsPositionInterpolatorNode.EventSet_FractionReceive(
912 const Event: TX3DEvent; const Value: TX3DField; const Time: TX3DTime);
913 var
914 ControlPointList: TVector3List;
915 Knot: TDoubleList;
916 OutputValue: TVector3;
917 begin
918 if not EventValue_Changed.SendNeeded then Exit;
919
920 if ControlPoint is TCoordinateNode then
921 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items
922 else
923 Exit;
924
925 if ControlPointList.Count = 0 then Exit;
926
927 if FdOrder.Value < 2 then
928 begin
929 WritelnWarning('VRML/X3D', 'NURBS order must be >= 2');
930 Exit;
931 end;
932
933 { We can be sure now that
934 - we have ControlPointList, non-nil, with at least 1 point.
935 - we have Order >= 2 }
936
937 { calculate correct Knot vector }
938 Knot := TDoubleList.Create;
939 Knot.Assign(FdKnot.Items);
940 NurbsKnotIfNeeded(Knot, ControlPointList.Count, FdOrder.Value, nkEndpointUniform);
941
942 OutputValue := NurbsCurvePoint(ControlPointList, (Value as TSFFloat).Value,
943 FdOrder.Value, Knot, FdWeight.Items, nil);
944
945 FreeAndNil(Knot);
946
947 EventValue_Changed.Send(OutputValue, Time);
948 end;
949
950 { TNurbsSurfaceInterpolatorNode ---------------------------------------------- }
951
952 constructor TNurbsSurfaceInterpolatorNode.Create(const AX3DName, ABaseUrl: String);
953 begin
954 inherited;
955 EventSet_Fraction.AddNotification({$ifdef FPC}@{$endif} EventSet_FractionReceive);
956 end;
957
958 function TNurbsSurfaceInterpolatorNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
959 begin
960 Result := FdcontrolPoint.Enumerate(Func);
961 if Result <> nil then Exit;
962 end;
963
964 procedure TNurbsSurfaceInterpolatorNode.EventSet_FractionReceive(
965 const Event: TX3DEvent; const Value: TX3DField; const Time: TX3DTime);
966 var
967 ControlPointList: TVector3List;
968 OutputNormal: TVector3;
969 OutputPosition: TVector3;
970 UKnot, VKnot: TDoubleList;
971 begin
972 if not (EventPosition_Changed.SendNeeded or
973 EventNormal_Changed.SendNeeded) then Exit;
974
975 { TODO: we should handle here all TAbstractCoordinateNode }
976 if ControlPoint is TCoordinateNode then
977 ControlPointList := TCoordinateNode(ControlPoint).FdPoint.Items
978 else
979 Exit;
980
981 if ControlPointList.Count = 0 then Exit;
982
983 if FdUDimension.Value * FdVDimension.Value <>
984 Integer(ControlPointList.Count) then
985 begin
986 WritelnWarning('VRML/X3D', Format('Number of coordinates in NurbsSurfaceInterpolator.controlPoint (%d) doesn''t match uDimension * vDimension (%d * %d = %d)',
987 [ ControlPointList.Count,
988 FdUDimension.Value, FdVDimension.Value,
989 FdUDimension.Value * FdVDimension.Value ]));
990 Exit;
991 end;
992
993 if (FdUDimension.Value < 0) or
994 (FdVDimension.Value < 0) then
995 begin
996 WritelnWarning('VRML/X3D', 'NurbsSurfaceInterpolator.u/vDimension must be >= 0');
997 Exit;
998 end;
999
1000 if (FdUOrder.Value < 2) or
1001 (FdVOrder.Value < 2) then
1002 begin
1003 WritelnWarning('VRML/X3D', 'NURBS order must be >= 2');
1004 Exit;
1005 end;
1006
1007 { We can be sure now that we have
1008 - correct ControlPointList, non-nil, with at least 1 point.
1009 - uDimension, vDimension match ControlPointList count, and are > 0.
1010 - we have Order >= 2.
1011 }
1012
1013 { calculate correct UKnot, VKnot vectors }
1014 UKnot := TDoubleList.Create;
1015 UKnot.Assign(FdUKnot.Items);
1016 NurbsKnotIfNeeded(UKnot, FdUDimension.Value, FdUOrder.Value, nkEndpointUniform);
1017 VKnot := TDoubleList.Create;
1018 VKnot.Assign(FdVKnot.Items);
1019 NurbsKnotIfNeeded(VKnot, FdVDimension.Value, FdVOrder.Value, nkEndpointUniform);
1020
1021 OutputPosition :=
1022 NurbsSurfacePoint(ControlPointList,
1023 FdUDimension.Value,
1024 FdVDimension.Value,
1025 (Value as TSFVec2f).Value[0],
1026 (Value as TSFVec2f).Value[1],
1027 FdUOrder.Value,
1028 FdVOrder.Value,
1029 UKnot,
1030 VKnot,
1031 FdWeight.Items,
1032 @OutputNormal);
1033
1034 FreeAndNil(UKnot);
1035 FreeAndNil(VKnot);
1036
1037 EventPosition_Changed.Send(OutputPosition, Time);
1038 EventNormal_Changed.Send(OutputNormal, Time);
1039 end;
1040
1041 function TNurbsSweptSurfaceNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
1042 begin
1043 Result := FdcrossSectionCurve.Enumerate(Func);
1044 if Result <> nil then Exit;
1045
1046 Result := FdtrajectoryCurve.Enumerate(Func);
1047 if Result <> nil then Exit;
1048 end;
1049
1050 function TNurbsSweptSurfaceNode.LocalBoundingBox(State: TX3DGraphTraverseState;
1051 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
1052 begin
1053 { Rendering of TNurbsSweptSurfaceNode not implemented. }
1054 Result := TBox3D.Empty;
1055 end;
1056
1057 function TNurbsSweptSurfaceNode.VerticesCount(State: TX3DGraphTraverseState;
1058 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
1059 begin
1060 { Rendering of TNurbsSweptSurfaceNode not implemented. }
1061 Result := 0;
1062 end;
1063
1064 function TNurbsSweptSurfaceNode.TrianglesCount(State: TX3DGraphTraverseState;
1065 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
1066 begin
1067 { Rendering of TNurbsSweptSurfaceNode not implemented. }
1068 Result := 0;
1069 end;
1070
1071 function TNurbsSweptSurfaceNode.SolidField: TSFBool;
1072 begin
1073 Result := FdSolid;
1074 end;
1075
1076 function TNurbsSwungSurfaceNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
1077 begin
1078 Result := FdprofileCurve.Enumerate(Func);
1079 if Result <> nil then Exit;
1080
1081 Result := FdtrajectoryCurve.Enumerate(Func);
1082 if Result <> nil then Exit;
1083 end;
1084
1085 function TNurbsSwungSurfaceNode.LocalBoundingBox(State: TX3DGraphTraverseState;
1086 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
1087 begin
1088 { Rendering of TNurbsSwungSurfaceNode not implemented. }
1089 Result := TBox3D.Empty;
1090 end;
1091
1092 function TNurbsSwungSurfaceNode.VerticesCount(State: TX3DGraphTraverseState;
1093 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
1094 begin
1095 { Rendering of TNurbsSwungSurfaceNode not implemented. }
1096 Result := 0;
1097 end;
1098
1099 function TNurbsSwungSurfaceNode.TrianglesCount(State: TX3DGraphTraverseState;
1100 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
1101 begin
1102 { Rendering of TNurbsSwungSurfaceNode not implemented. }
1103 Result := 0;
1104 end;
1105
1106 function TNurbsSwungSurfaceNode.SolidField: TSFBool;
1107 begin
1108 Result := FdSolid;
1109 end;
1110
1111 function TNurbsTrimmedSurfaceNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer;
1112 begin
1113 Result := FdtrimmingContour.Enumerate(Func);
1114 if Result <> nil then Exit;
1115 end;
1116
1117 function TNurbsTrimmedSurfaceNode.Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode;
1118 begin
1119 Result := inherited;
1120 if FdTrimmingContour.Count <> 0 then
1121 WritelnWarning('VRML/X3D', 'NurbsTrimmedSurface.trimmingContour is not implemented yet (that is, NurbsTrimmedSurface is rendered just like NurbsPatchSurface)');
1122 end;
1123
1124 procedure RegisterNURBSNodes;
1125 begin
1126 NodesManager.RegisterNodeClasses([
1127 TContour2DNode,
1128 TContourPolyline2DNode,
1129 TCoordinateDoubleNode,
1130 TNurbsCurveNode,
1131 TNurbsCurve2DNode,
1132 TNurbsOrientationInterpolatorNode,
1133 TNurbsPatchSurfaceNode,
1134 TNurbsPositionInterpolatorNode,
1135 TNurbsSetNode,
1136 TNurbsSurfaceInterpolatorNode,
1137 TNurbsSweptSurfaceNode,
1138 TNurbsSwungSurfaceNode,
1139 TNurbsTextureCoordinateNode,
1140 TNurbsTrimmedSurfaceNode
1141 ]);
1142 end;
1143
1144 {$endif read_implementation}