2
// Copyright 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU Lesser General Public
8
// License as published by the Free Software Foundation; either
9
// version 2.1 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
* \brief Libri2rib output base class implementation.
22
* \author Lionel J. Lacour (intuition01@online.fr)
26
#pragma warning(disable : 4786)
31
#include "inlineparse.h"
34
USING_NAMESPACE( libri2rib );
36
#define PR(x,y) printRequest(x,y)
40
#define PI(x) printInteger(x)
41
#define PF(x) printFloat(x)
42
#define PS(x) printString(x)
43
#define S printSpace()
44
#define EOL printEOL()
48
CqOutput::CqOutput( const char *name, int fdesc,
49
SqOptions::EqCompression comp,
50
SqOptions::EqIndentation i, TqInt isize )
56
m_IndentSize( isize ),
61
case SqOptions::Compression_None:
62
out = new CqStreamFDesc();
64
case SqOptions::Compression_Gzip:
65
out = new CqStreamGzip();
69
if ( name != RI_NULL )
71
out->openFile( name );
75
out->openFile( fdesc );
78
SqSteps a = {RI_BEZIERSTEP, RI_BEZIERSTEP};
92
// *********************************************************************
93
// ******* ******* ******* STEPS STACK FUNCTIONS ******* ******* *******
94
// *********************************************************************
97
m_Steps.push( m_Steps.top() );
101
if ( m_Steps.size() == 0 )
112
// **************************************************************
113
// ******* ******* ******* PRINTING TOOLS ******* ******* *******
114
// **************************************************************
115
void CqOutput::printPL( RtInt n, RtToken tokens[], RtPointer parms[],
116
RtInt vertex, RtInt varying, RtInt uniform, RtInt facevarying )
128
for ( i = 0; i < n ; i++ )
132
id = m_Dictionary.getTokenId( std::string( tokens[ i ] ) );
134
catch ( CqError & r )
140
printToken( tokens[ i ] ); S;
141
tt = m_Dictionary.getType( id );
142
sz = m_Dictionary.allocSize( id, vertex, varying, uniform, facevarying);
152
flt = static_cast<RtFloat *> ( parms[ i ] );
153
printArray( sz, flt );
156
flt = static_cast<RtFloat *> ( parms[ i ] );
157
printArray( sz * m_ColorNComps, flt );
160
cp = static_cast<char **> ( parms[ i ] );
162
for ( j = 0; j < sz; j++ )
164
printCharP( cp[ j ] ); S;
169
nt = static_cast<RtInt *> ( parms[ i ] );
170
printArray( sz, nt );
178
std::string CqOutput::getFilterFuncName( RtFilterFunc filterfunc, const char *name ) const
180
if ( filterfunc == RiBoxFilter ) return "box";
181
else if ( filterfunc == RiTriangleFilter ) return "triangle";
182
else if ( filterfunc == RiCatmullRomFilter ) return "catmull-rom";
183
else if ( filterfunc == RiSincFilter ) return "sinc";
184
else if ( filterfunc == RiGaussianFilter ) return "gaussian";
185
else if ( filterfunc == RiDiskFilter ) return "disk";
186
else if ( filterfunc == RiBesselFilter ) return "bessel";
189
throw CqError( RIE_CONSISTENCY, RIE_WARNING,
190
"Unknown RiFilterFunc. ",
191
name, " function skipped.", TqTrue );
199
// *****************************************************************
200
// ******* ******* ******* OUTPUT FUNCTIONS ******* ******* *******
201
// *****************************************************************
202
RtToken CqOutput::RiDeclare( const char *name, const char *declaration )
205
std::string a( name );
206
std::string b( declaration );
211
m_Dictionary.addToken( ip.getIdentifier(), ip.getClass(), ip.getType(), ip.getQuantity(), TqFalse );
213
PR( "Declare", Declare ); S;
214
printCharP( name ); S;
215
printCharP( declaration );
218
return const_cast<RtToken> ( name );
221
RtVoid CqOutput::RiBegin( RtToken name )
226
RtVoid CqOutput::RiEnd( RtVoid )
231
RtVoid CqOutput::RiFrameBegin( RtInt frame )
233
PR( "FrameBegin", FrameBegin ); S;
241
RtVoid CqOutput::RiFrameEnd( RtVoid )
244
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
247
PR( "FrameEnd", FrameEnd );
251
RtVoid CqOutput::RiWorldBegin( RtVoid )
253
PR( "WorldBegin", WorldBegin );
260
RtVoid CqOutput::RiWorldEnd( RtVoid )
263
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
266
PR( "WorldEnd", WorldEnd );
270
RtObjectHandle CqOutput::RiObjectBegin( RtVoid )
272
PR( "ObjectBegin", ObjectBegin ); S;
273
PI( ( RtInt ) m_ObjectHandle );
278
return ( RtObjectHandle ) m_ObjectHandle++;
281
RtVoid CqOutput::RiObjectEnd( RtVoid )
284
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
287
PR( "ObjectEnd", ObjectEnd );
291
RtVoid CqOutput::RiObjectInstance( RtObjectHandle handle )
293
PR( "ObjectInstance", ObjectInstance ); S;
294
PI( ( RtInt ) handle );
298
RtVoid CqOutput::RiAttributeBegin( RtVoid )
300
PR( "AttributeBegin", AttributeBegin );
307
RtVoid CqOutput::RiAttributeEnd( RtVoid )
310
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
313
PR( "AttributeEnd", AttributeEnd );
317
RtVoid CqOutput::RiTransformBegin( RtVoid )
319
PR( "TransformBegin", TransformBegin );
325
RtVoid CqOutput::RiTransformEnd( RtVoid )
328
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
330
PR( "TransformEnd", TransformEnd );
334
RtVoid CqOutput::RiSolidBegin( RtToken operation )
336
PR( "SolidBegin", SolidBegin ); S;
337
printToken( operation );
344
RtVoid CqOutput::RiSolidEnd( RtVoid )
347
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
350
PR( "SolidEnd", SolidEnd );
354
RtVoid CqOutput::RiMotionBeginV( RtInt n, RtFloat times[] )
356
PR( "MotionBegin", MotionBegin ); S;
357
printArray( n, times );
363
RtVoid CqOutput::RiMotionEnd( RtVoid )
366
if ( m_IndentLevel < 0 ) m_IndentLevel = 0;
368
PR( "MotionEnd", MotionEnd );
375
// **************************************************************
376
// ******* ******* ******* CAMERA OPTIONS ******* ******* *******
377
// **************************************************************
378
RtVoid CqOutput::RiFormat ( RtInt xres, RtInt yres, RtFloat aspect )
380
PR( "Format", Format ); S;
387
RtVoid CqOutput::RiFrameAspectRatio ( RtFloat aspect )
389
PR( "FrameAspectRatio", FrameAspectRatio ); S;
394
RtVoid CqOutput::RiScreenWindow ( RtFloat left, RtFloat right, RtFloat bottom, RtFloat top )
396
PR( "ScreenWindow", ScreenWindow ); S;
404
RtVoid CqOutput::RiCropWindow ( RtFloat xmin, RtFloat xmax, RtFloat ymin, RtFloat ymax )
406
PR( "CropWindow", CropWindow ); S;
414
RtVoid CqOutput::RiProjectionV ( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
416
PR( "Projection", Projection ); S;
417
printCharP( name ); S;
418
printPL( n, tokens, parms );
421
RtVoid CqOutput::RiClipping( RtFloat hither, RtFloat yon )
423
PR( "Clipping", Clipping ); S;
429
RtVoid CqOutput::RiClippingPlane( RtFloat x, RtFloat y, RtFloat z,
430
RtFloat nx, RtFloat ny, RtFloat nz )
432
PR( "ClippingPlane", ClippingPlane ); S;
442
RtVoid CqOutput::RiDepthOfField ( RtFloat fstop, RtFloat focallength, RtFloat focaldistance )
444
PR( "DepthOfField", DepthOfField ); S;
446
PF( focallength ); S;
451
RtVoid CqOutput::RiShutter( RtFloat min, RtFloat max )
453
PR( "Shutter", Shutter ); S;
462
// ***************************************************************
463
// ******* ******* ******* DISPLAY OPTIONS ******* ******* *******
464
// ***************************************************************
465
RtVoid CqOutput::RiPixelVariance( RtFloat variation )
467
PR( "PixelVariance", PixelVariance ); S;
472
RtVoid CqOutput::RiPixelSamples( RtFloat xsamples, RtFloat ysamples )
474
PR( "PixelSamples", PixelSamples ); S;
480
RtVoid CqOutput::RiPixelFilter( RtFilterFunc filterfunc, RtFloat xwidth, RtFloat ywidth )
482
std::string st = getFilterFuncName( filterfunc, "PixelFilter" );
483
PR( "PixelFilter", PixelFilter ); S;
490
RtVoid CqOutput::RiExposure( RtFloat gain, RtFloat gamma )
492
PR( "Exposure", Exposure ); S;
498
RtVoid CqOutput::RiImagerV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
500
PR( "Imager", Imager ); S;
501
printCharP( name ); S;
502
printPL( n, tokens, parms );
505
RtVoid CqOutput::RiQuantize( RtToken type, RtInt one, RtInt min, RtInt max, RtFloat ampl )
507
PR( "Quantize", Quantize ); S;
508
printToken( type ); S;
516
RtVoid CqOutput::RiDisplayV( const char *name, RtToken type, RtToken mode,
517
RtInt n, RtToken tokens[], RtPointer parms[] )
519
PR( "Display", Display ); S;
520
printCharP( name ); S;
521
printToken( type ); S;
522
printToken( mode ); S;
523
printPL( n, tokens, parms );
529
// ******************************************************************
530
// ******* ******* ******* ADDITIONAL OPTIONS ******* ******* *******
531
// ******************************************************************
532
RtVoid CqOutput::RiHiderV( const char *type, RtInt n, RtToken tokens[], RtPointer parms[] )
534
PR( "Hider", Hider ); S;
535
printCharP( type ); S;
536
printPL( n, tokens, parms );
539
RtVoid CqOutput::RiColorSamples( RtInt n, RtFloat nRGB[], RtFloat RGBn[] )
541
PR( "ColorSamples", ColorSamples ); S;
542
printArray( n * 3, nRGB ); S;
543
printArray( n * 3, RGBn );
549
RtVoid CqOutput::RiRelativeDetail( RtFloat relativedetail )
551
PR( "RelativeDetail", RelativeDetail ); S;
552
PF( relativedetail );
556
RtVoid CqOutput::RiOptionV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
558
PR( "Option", Option ); S;
559
printCharP( name ); S;
560
printPL( n, tokens, parms );
566
// ******************************************************************
567
// ******* ******* ******* SHADING ATTRIBUTES ******* ******* *******
568
// ******************************************************************
569
RtVoid CqOutput::RiColor( RtColor color )
571
PR( "Color", Color ); S;
572
printArray( m_ColorNComps, color );
576
RtVoid CqOutput::RiOpacity( RtColor color )
578
PR( "Opacity", Opacity ); S;
579
printArray( m_ColorNComps, color );
583
RtVoid CqOutput::RiTextureCoordinates( RtFloat s1, RtFloat t1, RtFloat s2, RtFloat t2,
584
RtFloat s3, RtFloat t3, RtFloat s4, RtFloat t4 )
586
PR( "TextureCoordinates", TextureCoordinates ); S;
598
RtLightHandle CqOutput::RiLightSourceV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
600
PR( "LightSource", LightSource ); S;
601
printCharP( name ); S;
602
PI( ( RtInt ) m_LightHandle ); S;
603
printPL( n, tokens, parms );
605
return ( RtLightHandle ) m_LightHandle++;
608
RtLightHandle CqOutput::RiAreaLightSourceV( const char *name,
609
RtInt n, RtToken tokens[], RtPointer parms[] )
611
PR( "AreaLightSource", AreaLightSource ); S;
612
printCharP( name ); S;
613
PI( ( RtInt ) m_LightHandle ); S;
614
printPL( n, tokens, parms );
616
return ( RtLightHandle ) m_LightHandle++;
619
RtVoid CqOutput::RiIlluminate( RtLightHandle light, RtBoolean onoff )
621
PR( "Illuminate", Illuminate ); S;
622
PI( ( RtInt ) light ); S;
624
if ( onoff == RI_TRUE )
631
RtVoid CqOutput::RiSurfaceV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
633
PR( "Surface", Surface ); S;
634
printCharP( name ); S;
635
printPL( n, tokens, parms );
638
RtVoid CqOutput::RiAtmosphereV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
640
PR( "Atmosphere", Atmosphere ); S;
641
printCharP( name ); S;
642
printPL( n, tokens, parms );
645
RtVoid CqOutput::RiInteriorV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
647
PR( "Interior", Interior ); S;
648
printCharP( name ); S;
649
printPL( n, tokens, parms );
652
RtVoid CqOutput::RiExteriorV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
654
PR( "Exterior", Exterior ); S;
655
printCharP( name ); S;
656
printPL( n, tokens, parms );
659
RtVoid CqOutput::RiShadingRate( RtFloat size )
661
PR( "ShadingRate", ShadingRate ); S;
666
RtVoid CqOutput::RiShadingInterpolation( RtToken type )
668
PR( "ShadingInterpolation", ShadingInterpolation ); S;
673
RtVoid CqOutput::RiMatte( RtBoolean onoff )
675
PR( "Matte", Matte ); S;
677
if ( onoff == RI_TRUE )
687
// *******************************************************************
688
// ******* ******* ******* GEOMETRY ATTRIBUTES ******* ******* *******
689
// *******************************************************************
690
RtVoid CqOutput::RiBound( RtBound b )
692
PR( "Bound", Bound ); S;
697
RtVoid CqOutput::RiDetail( RtBound d )
699
PR( "Detail", Detail ); S;
704
RtVoid CqOutput::RiDetailRange( RtFloat minvis, RtFloat lowtran, RtFloat uptran, RtFloat maxvis )
706
PR( "DetailRange", DetailRange ); S;
714
RtVoid CqOutput::RiGeometricApproximation( RtToken type, RtFloat value )
716
PR( "GeometricApproximation", GeometricApproximation ); S;
717
printToken( type ); S;
722
RtVoid CqOutput::RiBasis( RtBasis ubasis, RtInt ustep, RtBasis vbasis, RtInt vstep )
727
PR( "Basis", Basis ); S;
728
for ( i = 0; i < 16; i++ )
730
m[ i ] = ubasis[ i / 4 ][ i % 4 ];
732
printArray( 16, &( m[ 0 ] ) ); S;
735
for ( i = 0; i < 16; i++ )
737
m[ i ] = vbasis[ i / 4 ][ i % 4 ];
739
printArray( 16, m ); S;
743
m_Steps.top().uStep = ustep;
744
m_Steps.top().vStep = vstep;
747
RtVoid CqOutput::RiTrimCurve( RtInt nloops, RtInt ncurves[], RtInt order[],
748
RtFloat knot[], RtFloat min[], RtFloat max[], RtInt n[],
749
RtFloat u[], RtFloat v[], RtFloat w[] )
753
for ( i = 0; i < nloops; i++ )
754
ttlc += ncurves[ i ];
758
for ( i = 0; i < ttlc; i++ )
761
knotsize += order[ i ] + n[ i ];
764
PR( "TrimCurve", TrimCurve ); S;
765
printArray( nloops, ncurves ); S;
766
printArray( ttlc, order ); S;
767
printArray( knotsize, knot ); S;
768
printArray( ttlc, min ); S;
769
printArray( ttlc, max ); S;
770
printArray( ttlc, n ); S;
771
printArray( nbcoords, u ); S;
772
printArray( nbcoords, v ); S;
773
printArray( nbcoords, w );
777
RtVoid CqOutput::RiOrientation( RtToken o )
779
PR( "Orientation", Orientation ); S;
784
RtVoid CqOutput::RiReverseOrientation( RtVoid )
786
PR( "ReverseOrientation", ReverseOrientation );
790
RtVoid CqOutput::RiSides( RtInt sides )
792
PR( "Sides", Sides ); S;
797
RtVoid CqOutput::RiDisplacementV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
799
PR( "Displacement", Displacement ); S;
800
printCharP( name ); S;
801
printPL( n, tokens, parms );
807
// ***************************************************************
808
// ******* ******* ******* TRANSFORMATIONS ******* ******* *******
809
// ***************************************************************
810
RtVoid CqOutput::RiIdentity( RtVoid )
812
PR( "Identity", Identity );
816
RtVoid CqOutput::RiTransform( RtMatrix transform )
819
for ( RtInt i = 0; i < 16; i++ )
821
m[ i ] = transform[ i / 4 ][ i % 4 ];
824
PR( "Transform", Transform ); S;
825
printArray( 16, &( m[ 0 ] ) );
829
RtVoid CqOutput::RiConcatTransform( RtMatrix transform )
832
for ( RtInt i = 0; i < 16; i++ )
834
m[ i ] = transform[ i / 4 ][ i % 4 ];
837
PR( "ConcatTransform", ConcatTransform ); S;
838
printArray( 16, &( m[ 0 ] ) );
842
RtVoid CqOutput::RiPerspective( RtFloat fov )
844
PR( "Perspective", Perspective ); S;
849
RtVoid CqOutput::RiTranslate( RtFloat dx, RtFloat dy, RtFloat dz )
851
PR( "Translate", Translate ); S;
858
RtVoid CqOutput::RiRotate( RtFloat angle, RtFloat dx, RtFloat dy, RtFloat dz )
860
PR( "Rotate", Rotate ); S;
868
RtVoid CqOutput::RiScale( RtFloat sx, RtFloat sy, RtFloat sz )
870
PR( "Scale", Scale ); S;
877
RtVoid CqOutput::RiSkew( RtFloat angle, RtFloat dx1, RtFloat dy1, RtFloat dz1,
878
RtFloat dx2, RtFloat dy2, RtFloat dz2 )
880
PR( "Skew", Skew ); S;
891
RtVoid CqOutput::RiDeformationV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
893
PR( "Deformation", Deformation ); S;
894
printCharP( name ); S;
895
printPL( n, tokens, parms );
898
RtVoid CqOutput::RiCoordinateSystem( RtToken space )
900
PR( "CoordinateSystem", CoordinateSystem ); S;
905
RtVoid CqOutput::RiCoordSysTransform( RtToken space )
907
PR( "CoordSysTransform", CoordSysTransform ); S;
912
RtVoid CqOutput::RiAttributeV( const char *name, RtInt n, RtToken tokens[], RtPointer parms[] )
914
PR( "Attribute", Attribute ); S;
915
printCharP( name ); S;
916
printPL( n, tokens, parms );
922
// **********************************************************
923
// ******* ******* ******* PRIMITIVES ******* ******* *******
924
// **********************************************************
925
RtVoid CqOutput::RiPolygonV( RtInt nverts, RtInt n, RtToken tokens[], RtPointer parms[] )
927
PR( "Polygon", Polygon ); S;
928
printPL( n, tokens, parms, nverts, nverts, nverts );
931
RtVoid CqOutput::RiGeneralPolygonV( RtInt nloops, RtInt nverts[],
932
RtInt n, RtToken tokens[], RtPointer parms[] )
935
for ( RtInt i = 0; i < nloops; i++ )
937
nbpts += nverts[ i ];
940
PR( "GeneralPolygon", GeneralPolygon ); S;
941
printArray( nloops, nverts ); S;
942
printPL( n, tokens, parms, nbpts, nbpts, nbpts );
945
RtVoid CqOutput::RiPointsPolygonsV( RtInt npolys, RtInt nverts[], RtInt verts[],
946
RtInt n, RtToken tokens[], RtPointer parms[] )
948
PR( "PointsPolygons", PointsPolygons ); S;
949
printArray( npolys, nverts ); S;
953
for ( i = 0; i < npolys; i++ )
955
nbpts += nverts[ i ];
957
printArray( nbpts, verts ); S;
960
for ( i = 0; i < nbpts; i++ )
962
if ( psize < verts[ i ] )
965
printPL( n, tokens, parms, psize + 1, psize + 1, npolys, nbpts );
968
RtVoid CqOutput::RiPointsGeneralPolygonsV( RtInt npolys, RtInt nloops[], RtInt nverts[],
970
RtInt n, RtToken tokens[], RtPointer parms[] )
972
PR( "PointsGeneralPolygons", PointsGeneralPolygons ); S;
973
printArray( npolys, nloops ); S;
977
for ( i = 0; i < npolys; i++ )
979
nbvert += nloops[ i ];
981
printArray( nbvert, nverts ); S;
984
for ( i = 0; i < nbvert; i++ )
988
printArray( nv, verts ); S;
991
for ( i = 0; i < nv; i++ )
993
if ( psize < verts[ i ] )
996
RtInt facevarying = nv;
997
printPL( n, tokens, parms, psize + 1, psize + 1, npolys, facevarying );
1000
RtVoid CqOutput::RiPatchV( RtToken type, RtInt n, RtToken tokens[], RtPointer parms[] )
1003
if ( type == RI_BILINEAR )
1005
else if ( type == RI_BICUBIC )
1009
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1010
"Unknown RiPatch type: ", type,
1011
" RiPatch() instruction skipped", TqTrue );
1014
PR( "Patch", Patch ); S;
1015
printToken( type ); S;
1016
printPL( n, tokens, parms, nb, 4 );
1019
RtVoid CqOutput::RiPatchMeshV( RtToken type, RtInt nu, RtToken uwrap,
1020
RtInt nv, RtToken vwrap, RtInt n, RtToken tokens[],
1023
RtInt nuptch, nvptch;
1025
if ( type == RI_BILINEAR )
1027
if ( uwrap == RI_PERIODIC )
1031
else if ( uwrap == RI_NONPERIODIC )
1038
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1039
"Unknown RiPatchMesh uwrap token:", uwrap,
1040
" RiPatchMesh instruction skipped", TqTrue );
1042
if ( vwrap == RI_PERIODIC )
1046
else if ( vwrap == RI_NONPERIODIC )
1053
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1054
"Unknown RiPatchMesh vwrap token:", vwrap,
1055
" RiPatchMesh instruction skipped", TqTrue );
1057
ii += nuptch + nvptch;
1061
else if ( type == RI_BICUBIC )
1063
RtInt nustep = m_Steps.top().uStep;
1064
RtInt nvstep = m_Steps.top().vStep;
1066
if ( uwrap == RI_PERIODIC )
1068
nuptch = nu / nustep;
1070
else if ( uwrap == RI_NONPERIODIC )
1072
nuptch = ( nu - 4 ) / nustep + 1;
1077
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1078
"Unknown RiPatchMesh uwrap token:", uwrap,
1079
" RiPatchMesh instruction skipped", TqTrue );
1081
if ( vwrap == RI_PERIODIC )
1083
nvptch = nv / nvstep;
1085
else if ( vwrap == RI_NONPERIODIC )
1087
nvptch = ( nv - 4 ) / nvstep + 1;
1092
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1093
"Unknown RiPatchMesh vwrap token:", vwrap,
1094
" RiPatchMesh instruction skipped", TqTrue );
1096
ii += nuptch + nvptch;
1102
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1103
"Unknown RiPatchMesh type:", type,
1104
" RiPatchMesh instruction skipped", TqTrue );
1107
PR( "PatchMesh", PatchMesh ); S;
1108
printToken( type ); S;
1110
printToken( uwrap ); S;
1112
printToken( vwrap ); S;
1113
printPL( n, tokens, parms, nu * nv, ii, nuptch * nvptch );
1116
RtVoid CqOutput::RiNuPatchV( RtInt nu, RtInt uorder, RtFloat uknot[],
1117
RtFloat umin, RtFloat umax,
1118
RtInt nv, RtInt vorder, RtFloat vknot[],
1119
RtFloat vmin, RtFloat vmax,
1120
RtInt n, RtToken tokens[], RtPointer parms[] )
1122
PR( "NuPatch", NuPatch ); S;
1125
printArray( nu + uorder, uknot ); S;
1131
printArray( nv + vorder, vknot ); S;
1134
printPL( n, tokens, parms, nu * nv, ( 2 + nu - uorder ) * ( 2 + nv - vorder ), ( 1 + nu - uorder ) * ( 1 + nv - vorder ) );
1137
RtVoid CqOutput::RiSphereV( RtFloat radius, RtFloat zmin, RtFloat zmax, RtFloat tmax,
1138
RtInt n, RtToken tokens[], RtPointer parms[] )
1140
PR( "Sphere", Sphere ); S;
1145
printPL( n, tokens, parms, 4, 4 );
1148
RtVoid CqOutput::RiConeV( RtFloat height, RtFloat radius, RtFloat tmax,
1149
RtInt n, RtToken tokens[], RtPointer parms[] )
1151
PR( "Cone", Cone ); S;
1155
printPL( n, tokens, parms, 4, 4 );
1158
RtVoid CqOutput::RiCylinderV( RtFloat radius, RtFloat zmin, RtFloat zmax, RtFloat tmax,
1159
RtInt n, RtToken tokens[], RtPointer parms[] )
1161
PR( "Cylinder", Cylinder ); S;
1166
printPL( n, tokens, parms, 4, 4 );
1169
RtVoid CqOutput::RiHyperboloidV( RtPoint point1, RtPoint point2, RtFloat tmax,
1170
RtInt n, RtToken tokens[], RtPointer parms[] )
1172
PR( "Hyperboloid", Hyperboloid ); S;
1173
printArray( 3, point1 ); S;
1174
printArray( 3, point2 ); S;
1176
printPL( n, tokens, parms, 4, 4 );
1179
RtVoid CqOutput::RiParaboloidV( RtFloat rmax, RtFloat zmin, RtFloat zmax, RtFloat tmax,
1180
RtInt n, RtToken tokens[], RtPointer parms[] )
1182
PR( "Paraboloid", Paraboloid ); S;
1187
printPL( n, tokens, parms, 4, 4 );
1190
RtVoid CqOutput::RiDiskV( RtFloat height, RtFloat radius, RtFloat tmax,
1191
RtInt n, RtToken tokens[], RtPointer parms[] )
1193
PR( "Disk", Disk ); S;
1197
printPL( n, tokens, parms, 4, 4 );
1200
RtVoid CqOutput::RiTorusV( RtFloat majrad, RtFloat minrad, RtFloat phimin, RtFloat phimax,
1201
RtFloat tmax, RtInt n, RtToken tokens[], RtPointer parms[] )
1203
PR( "Torus", Torus ); S;
1209
printPL( n, tokens, parms, 4, 4 );
1212
RtVoid CqOutput::RiBlobbyV( RtInt nleaf, RtInt ncode, RtInt code[],
1213
RtInt nflt, RtFloat flt[],
1214
RtInt nstr, RtToken str[],
1215
RtInt n, RtToken tokens[], RtPointer parms[] )
1217
PR( "Blobby", Blobby ); S;
1218
printArray( ncode, code ); S;
1219
printArray( nflt, flt ); S;
1221
for ( RtInt i = 0; i < nstr; i++ )
1223
printToken( str[ i ] ); S;
1226
printPL( n, tokens, parms, nleaf, nleaf );
1229
RtVoid CqOutput::RiPointsV( RtInt npoints,
1230
RtInt n, RtToken tokens[], RtPointer parms[] )
1232
PR( "Points", Points ); S;
1233
printPL( n, tokens, parms, npoints, npoints );
1236
RtVoid CqOutput::RiCurvesV( RtToken type, RtInt ncurves,
1237
RtInt nvertices[], RtToken wrap,
1238
RtInt n, RtToken tokens[], RtPointer parms[] )
1242
if ( type == RI_LINEAR )
1244
if ( wrap == RI_PERIODIC )
1246
for ( i = 0; i < ncurves; i++ )
1248
vval += nvertices[ i ];
1251
else if ( wrap == RI_NONPERIODIC )
1253
for ( i = 0; i < ncurves; i++ )
1255
vval += nvertices[ i ];
1260
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1261
"Unknown RiCurves wrap token:", wrap,
1262
" RiCurves instruction skipped", TqTrue );
1265
else if ( type == RI_CUBIC )
1267
if ( wrap == RI_PERIODIC )
1269
for ( i = 0; i < ncurves; i++ )
1271
vval += ( nvertices[ i ] - 4 ) / m_Steps.top().vStep;
1274
else if ( wrap == RI_NONPERIODIC )
1276
for ( i = 0; i < ncurves; i++ )
1278
vval += 2 + ( nvertices[ i ] - 4 ) / m_Steps.top().vStep;
1283
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1284
"Unknown RiCurves wrap token:", wrap,
1285
" RiCurves instruction skipped", TqTrue );
1290
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1291
"Unknown RiCurves type:", type,
1292
" RiCurves instruction skipped", TqTrue );
1295
PR( "Curves", Curves ); S;
1296
printToken( type ); S;
1297
printArray( ncurves, nvertices ); S;
1298
printToken( wrap ); S;
1301
for ( i = 0; i < ncurves; i++ )
1303
nbpts += nvertices[ i ];
1305
printPL( n, tokens, parms, nbpts, vval, ncurves );
1308
RtVoid CqOutput::RiSubdivisionMeshV( RtToken mask, RtInt nf, RtInt nverts[],
1310
RtInt ntags, RtToken tags[], RtInt numargs[],
1311
RtInt intargs[], RtFloat floatargs[],
1312
RtInt n, RtToken tokens[], RtPointer parms[] )
1314
PR( "SubdivisionMesh", SubdivisionMesh ); S;
1315
printToken( mask ); S;
1316
printArray( nf, nverts ); S;
1320
for ( i = 0; i < nf; i++ )
1322
vsize += nverts[ i ];
1324
printArray( vsize, verts ); S;
1326
printArray( ntags, tags ); S;
1327
printArray( ntags * 2, numargs ); S;
1329
RtInt isize = 0, fsize = 0;
1330
for ( i = 0; i < ntags*2; i++ )
1333
isize += numargs[ i ];
1335
fsize += numargs[ i ];
1337
printArray( isize, intargs ); S;
1338
printArray( fsize, floatargs ); S;
1341
for ( i = 0; i < vsize; i++ )
1343
if ( psize < verts[ i ] )
1346
printPL( n, tokens, parms, psize + 1, psize + 1, nf, vsize );
1349
RtVoid CqOutput::RiProcedural( RtPointer data, RtBound bound,
1350
RtVoid ( *subdivfunc ) ( RtPointer, RtFloat ),
1351
RtVoid ( *freefunc ) ( RtPointer ) )
1355
if ( subdivfunc == RiProcDelayedReadArchive )
1357
sf = "DelayedReadArchive";
1360
else if ( subdivfunc == RiProcRunProgram )
1365
else if ( subdivfunc == RiProcDynamicLoad )
1372
throw CqError( RIE_SYNTAX, RIE_ERROR, "Unknown procedural function.", TqTrue );
1375
PR( "Procedural", Procedural ); S;
1383
printCharP( ( ( RtString * ) data ) [ 0 ] ); S;
1387
for ( i = 0; i < 6 ; i++ )
1389
PF( bound[ i ] ); S;
1398
printCharP( ( ( RtString * ) data ) [ 0 ] ); S;
1399
printCharP( ( ( RtString * ) data ) [ 1 ] ); S;
1403
for ( i = 0; i < 6 ; i++ )
1405
PF( bound[ i ] ); S;
1413
RtVoid CqOutput::RiGeometryV( RtToken type, RtInt n, RtToken tokens[], RtPointer parms[] )
1415
PR( "Geometry", Geometry ); S;
1416
printToken( type ); S;
1417
printPL( n, tokens, parms );
1423
// *******************************************************
1424
// ******* ******* ******* TEXTURE ******* ******* *******
1425
// *******************************************************
1426
RtVoid CqOutput::RiMakeTextureV( const char *pic, const char *tex, RtToken swrap, RtToken twrap,
1427
RtFilterFunc filterfunc, RtFloat swidth, RtFloat twidth,
1428
RtInt n, RtToken tokens[], RtPointer parms[] )
1430
std::string ff = getFilterFuncName( filterfunc, "MakeTexture" );
1432
PR( "MakeTexture", MakeTexture ); S;
1433
printCharP( pic ); S;
1434
printCharP( tex ); S;
1435
printToken( swrap ); S;
1436
printToken( twrap ); S;
1440
printPL( n, tokens, parms );
1443
RtVoid CqOutput::RiMakeBumpV( const char *pic, const char *tex, RtToken swrap, RtToken twrap,
1444
RtFilterFunc filterfunc, RtFloat swidth, RtFloat twidth,
1445
RtInt n, RtToken tokens[], RtPointer parms[] )
1447
std::string ff = getFilterFuncName( filterfunc, "MakeBump" );
1449
PR( "MakeBump", MakeBump ); S;
1450
printCharP( pic ); S;
1451
printCharP( tex ); S;
1452
printToken( swrap ); S;
1453
printToken( twrap ); S;
1457
printPL( n, tokens, parms );
1460
RtVoid CqOutput::RiMakeLatLongEnvironmentV( const char *pic, const char *tex, RtFilterFunc filterfunc,
1461
RtFloat swidth, RtFloat twidth,
1462
RtInt n, RtToken tokens[], RtPointer parms[] )
1464
std::string ff = getFilterFuncName( filterfunc, "MakeLatLongEnvironment" );
1466
PR( "MakeLatLongEnvironment", MakeLatLongEnvironment ); S;
1467
printCharP( pic ); S;
1468
printCharP( tex ); S;
1472
printPL( n, tokens, parms );
1475
RtVoid CqOutput::RiMakeCubeFaceEnvironmentV( const char *px, const char *nx, const char *py, const char *ny,
1476
const char *pz, const char *nz, const char *tex, RtFloat fov,
1477
RtFilterFunc filterfunc, RtFloat swidth,
1479
RtInt n, RtToken tokens[], RtPointer parms[] )
1481
std::string ff = getFilterFuncName( filterfunc, "MakeCubeFaceEnvironment" );
1483
PR( "MakeCubeFaceEnvironment", MakeCubeFaceEnvironment ); S;
1484
printCharP( px ); S;
1485
printCharP( nx ); S;
1486
printCharP( py ); S;
1487
printCharP( ny ); S;
1488
printCharP( pz ); S;
1489
printCharP( nz ); S;
1490
printCharP( tex ); S;
1495
printPL( n, tokens, parms );
1498
RtVoid CqOutput::RiMakeShadowV( const char *pic, const char *tex,
1499
RtInt n, RtToken tokens[], RtPointer parms[] )
1501
PR( "MakeShadow", MakeShadow ); S;
1502
printCharP( pic ); S;
1503
printCharP( tex ); S;
1504
printPL( n, tokens, parms );
1510
// *******************************************************
1511
// ******* ******* ******* ARCHIVE ******* ******* *******
1512
// *******************************************************
1513
RtVoid CqOutput::RiArchiveRecord( RtToken type, std::string txt )
1517
if ( type == RI_COMMENT ) tmp = "#";
1518
else if ( type == RI_STRUCTURE ) tmp = "##";
1519
else if ( type == RI_VERBATIM )
1521
print( txt.c_str() ); return ;
1525
throw CqError( RIE_BADTOKEN, RIE_ERROR,
1526
"Unknown ArchiveRecord type: ", type, "", TqTrue );
1528
// EOL must be forced for binary
1529
print( ( tmp + txt + "\n" ).c_str() );
1532
RtVoid CqOutput::RiReadArchiveV( RtToken name, RtArchiveCallback callback,
1533
RtInt n, RtToken tokens[], RtPointer parms[] )
1535
PR( "ReadArchive", ReadArchive ); S;
1543
// *************************************************************
1544
// ******* ******* ******* ERROR HANDLER ******* ******* *******
1545
// *************************************************************
1546
RtVoid CqOutput::RiErrorHandler( RtErrorFunc handler )
1549
if ( handler == RiErrorIgnore ) ch = "ignore";
1550
else if ( handler == RiErrorPrint ) ch = "print";
1551
else if ( handler == RiErrorAbort ) ch = "abort";
1554
throw CqError( RIE_CONSISTENCY, RIE_ERROR, "Unknown Error handler", TqTrue );
1556
PR( "ErrorHandler", ErrorHandler ); S;