User input validation for Arc/Line splines
Programmatically geometry of an 3DS object is modified via call to SetParam() or
SetNamedParam() methods of IElement. Quite often the new value of the parameter
makes geometry of the model invalid. For example, when radius of an arc is too
small to connect its ends. In this case the above methods return without
changing anything in the geometry. In C++ this situation can be detected from
the returned HRESULT, which will be equal to DI_E_INVALIDGEOMETRY (defined in
<Install dir>\Samples\VC\IncludeDIInterface.h). Higher
level development environments like Visual Basic and .NET can use IElem interface
instead.
IElem interface is analogous to IElement. The only
difference is that SetParam and SetNamedParam
methods have additional parameter, which acts as the return value for This
return value notifies the caller if the new value was accepted, rejected or did
not have any effect on the model.
If IElem is implemented it can be queried from the correspondent IElement interface. Note that
some simple objects (IElement implemented by an axial point) always accept its modification, and hence do not implement
IElem interface.
- After a successful call to SetParam
method and before any other modification of the same parameter, there should be
a call to UpdateSurface
method of the DG Kernel control or call to Update method of
the IModel interface. Normally you would make all requested modifications
for the user input (one modification per parameter) and call UpdateSurface
methods to recalculates the surface and display the result for viewing in
3D.
-
- Note that successful return from SetParam
and SetNamedParam means that only a simple
validation succeeded. The geometry of the model may still be invalid and can be
rejected later during the call to UpdateSurface() method of the control. In
the latter case all modifications since the previous call to UpdateSurface()
will be discarded.
All angles in the software are internally represented in radians, so when the
parameter is an angle, new value should be in range (-PI, PI] otherwise the
methods returns DI_E_INVALIDGEOMETRY and the parameter will remain
unchanged.
Interface List
|