void JollyBanker::ReadFile(string name) {//this will create the queue ifstream infile(name); string line; while (getline(infile, line)) { istringstream theLine(line); char tranCode; theLine >> tranCode; if (tranCode == 'O') { string last, first; int id; theLine >> last >> first >> id; Transactions temp(tranCode, last, first, id); transactions.push(temp); } else if (tranCode == 'D' || tranCode=='W')
string V3PreProcImp::getline() { // Get a single line from the parse stream. Buffer unreturned text until the newline. if (isEof()) return ""; const char* rtnp; bool gotEof = false; while (NULL==(rtnp=strchr(m_lineChars.c_str(),'\n')) && !gotEof) { string buf; int tok = getFinalToken(buf/*ref*/); if (debug()>=5) { string bufcln = V3PreLex::cleanDbgStrg(buf); fprintf (stderr,"%d: GETFETC: %-10s: %s\n", m_lexp->m_tokFilelinep->lineno(), tokenName(tok), bufcln.c_str()); } if (tok==VP_EOF) { // Add a final newline, if the user forgot the final \n. if (m_lineChars != "" && m_lineChars[m_lineChars.length()-1] != '\n') { m_lineChars.append("\n"); } gotEof = true; } else { m_lineChars.append(buf); } } // Make new string with data up to the newline. int len = rtnp-m_lineChars.c_str()+1; string theLine(m_lineChars, 0, len); m_lineChars = m_lineChars.erase(0,len); // Remove returned characters if (debug()>=4) { string lncln = V3PreLex::cleanDbgStrg(theLine); fprintf (stderr,"%d: GETLINE: %s\n", m_lexp->m_tokFilelinep->lineno(), lncln.c_str()); } return theLine; }
/** Create a RIB compatible representation of a Maya pfxToon node as RiCurves. */ liqRibPfxToonData::liqRibPfxToonData( MObject pfxToon ) : nverts(), CVs(), curveWidth(), cvColor(), cvOpacity() { LIQDEBUGPRINTF( "-> creating pfxToon curves\n" ); MStatus status( MS::kSuccess ); // Update the pfxToon node with the renderCamera's position // otherwise the resulting outline might be incorrect MDagPath cameraPath; MSelectionList camList; camList.add( liqglo_renderCamera ); camList.getDagPath( 0, cameraPath ); MMatrix cam_mat( cameraPath.inclusiveMatrix() ); MFnDependencyNode pfxToonNode( pfxToon ); pfxToonNode.findPlug( "cameraPointX" ).setValue( cam_mat( 3, 0 ) ); pfxToonNode.findPlug( "cameraPointY" ).setValue( cam_mat( 3, 1 ) ); pfxToonNode.findPlug( "cameraPointZ" ).setValue( cam_mat( 3, 2 ) ); MFnPfxGeometry pfxtoon( pfxToon, &status ); if ( status == MS::kSuccess ) { MRenderLineArray profileArray; MRenderLineArray creaseArray; MRenderLineArray intersectionArray; bool doLines = true; bool doTwist = false; bool doWidth = true; bool doFlatness = false; bool doParameter = false; bool doColor = true; bool doIncandescence = false; bool doTransparency = true; bool doWorldSpace = false; status = pfxtoon.getLineData( profileArray, creaseArray, intersectionArray, doLines, doTwist, doWidth, doFlatness, doParameter, doColor, doIncandescence, doTransparency, doWorldSpace ); if ( status == MS::kSuccess ) { // Het the lines and fill the arrays. ncurves = profileArray.length(); { MFnDependencyNode pfxNode( pfxToon ); MString info( "[liquid] pfxToon node " ); info += pfxNode.name() + " : " + ncurves + " curves."; cout << info << endl << flush; } unsigned totalNumberOfVertices( 0 ); if ( ncurves > 0 ) { nverts = shared_array< RtInt >( new RtInt[ ncurves ] ); // Calculate storage requirments. // This is a lot more efficient than all those reallocs() // (or resize()s if we used a vector) that were done before // in the main loop below. for ( unsigned i( 0 ); i < ncurves; i++ ) { MRenderLine theLine( profileArray.renderLine( i, &status ) ); if ( MS::kSuccess == status ) { MVectorArray vertices( theLine.getLine() ); totalNumberOfVertices += vertices.length(); } } // Allocate memory CVs = shared_array< RtFloat >( new RtFloat[ totalNumberOfVertices * 3 ] ); if ( !CVs ) { MString err( "liqRibPfxToonData failed to allocate CV memory!" ); cout << err << endl << flush; throw( err ); return; } curveWidth = shared_array< RtFloat >( new RtFloat[ totalNumberOfVertices ] ); if ( !curveWidth ) { MString err( "liqRibPfxToonData failed to allocate per vertex width memory!" ); cout << err << endl << flush; throw( err ); return; } cvColor = shared_array< RtFloat >( new RtFloat[ totalNumberOfVertices * 3 ] ); if ( !cvColor ) { MString err( "liqRibPfxToonData failed to allocate CV color memory!" ); cout << err << endl << flush; throw(err); return; } cvOpacity = shared_array< RtFloat >( new RtFloat[ totalNumberOfVertices * 3 ] ); if ( !cvOpacity ) { MString err("liqRibPfxToonData failed to allocate CV opacity memory !"); cout << err << endl << flush; throw( err ); return; } RtFloat* cvPtr; RtFloat* widthPtr; RtFloat* colorPtr; RtFloat* opacityPtr; totalNumberOfVertices = 0; for ( unsigned i( 0 ); i < ncurves; i++ ) { MRenderLine theLine( profileArray.renderLine( i, &status ) ); if ( MS::kSuccess == status ) { const MVectorArray& vertices( theLine.getLine() ); const MDoubleArray& width( theLine.getWidth() ); const MVectorArray& vertexColor( theLine.getColor() ); const MVectorArray& vertexTransparency( theLine.getTransparency() ); //cout <<"line "<<i<<" contains "<<vertices.length()<<" vertices."<<endl; //cout <<vertexColor<<endl; nverts[i] = vertices.length(); totalNumberOfVertices += vertices.length(); cvPtr = CVs.get() + ( totalNumberOfVertices * 3 - nverts[ i ] * 3 ) ; widthPtr = curveWidth.get() + ( totalNumberOfVertices - nverts[ i ] ) ; colorPtr = cvColor.get() + ( totalNumberOfVertices * 3 - nverts[ i ] * 3 ) ; opacityPtr = cvOpacity.get() + ( totalNumberOfVertices * 3 - nverts[ i ] * 3 ) ; for ( unsigned vertIndex( 0 ); vertIndex < vertices.length(); vertIndex++ ) { *cvPtr++ = ( RtFloat ) vertices[ vertIndex ].x; *cvPtr++ = ( RtFloat ) vertices[ vertIndex ].y; *cvPtr++ = ( RtFloat ) vertices[ vertIndex ].z; *widthPtr++ = ( RtFloat )width[ vertIndex ]; *colorPtr++ = ( RtFloat )vertexColor[ vertIndex ].x ; *colorPtr++ = ( RtFloat )vertexColor[ vertIndex ].y ; *colorPtr++ = ( RtFloat )vertexColor[ vertIndex ].z ; *opacityPtr++ = ( RtFloat )( 1.0f - vertexTransparency[ vertIndex ].x ) ; *opacityPtr++ = ( RtFloat )( 1.0f - vertexTransparency[ vertIndex ].y ) ; *opacityPtr++ = ( RtFloat )( 1.0f - vertexTransparency[ vertIndex ].z ) ; } } } // Store for output liqTokenPointer points_pointerPair; if ( !points_pointerPair.set( "P", rPoint, true, false, totalNumberOfVertices ) ) { MString err( "liqRibPfxToonData: liqTokenPointer failed to allocate CV memory !" ); cout << err << endl; throw(err); return; } points_pointerPair.setDetailType( rVertex ); points_pointerPair.setTokenFloats( CVs ); tokenPointerArray.push_back( points_pointerPair ); // Store width params liqTokenPointer width_pointerPair; if ( !width_pointerPair.set( "width", rFloat, true, false, totalNumberOfVertices ) ) { MString err("liqRibPfxToonData: liqTokenPointer failed to allocate width memory !"); cout <<err<<endl; throw(err); return; } width_pointerPair.setDetailType( rVarying ); width_pointerPair.setTokenFloats( curveWidth ); tokenPointerArray.push_back( width_pointerPair ); // Store color params liqTokenPointer color_pointerPair; if ( !color_pointerPair.set( "pfxToon_vtxColor", rColor, true, false, totalNumberOfVertices ) ) { MString err("liqRibPfxToonData: liqTokenPointer failed to allocate color memory !"); cout <<err<<endl; throw(err); return; } color_pointerPair.setDetailType( rVertex ); color_pointerPair.setTokenFloats( cvColor ); tokenPointerArray.push_back( color_pointerPair ); // Store opacity params liqTokenPointer opacity_pointerPair; if ( !opacity_pointerPair.set( "pfxToon_vtxOpacity", rColor, true, false, totalNumberOfVertices ) ) { MString err("liqRibPfxToonData: liqTokenPointer failed to allocate opacity memory !"); cout <<err<<endl<<flush; throw(err); return; } opacity_pointerPair.setDetailType( rVertex ); opacity_pointerPair.setTokenFloats( cvOpacity ); tokenPointerArray.push_back( opacity_pointerPair ); addAdditionalSurfaceParameters( pfxToon ); } } } }