void Example3_NurbsIn() { std::cout << "loading archive" << std::endl; IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(), "nurbs3.abc" ); std::cout << "making INuPatch object" << std::endl; INuPatch myNurbs( IObject( archive, kTop) , "nurbs_surface_withW"); std::cout << "getting INuPatch schema" << std::endl; INuPatchSchema &nurbsSchema = myNurbs.getSchema(); // get the samples from the curves std::cout << "getting INuPatch sample" << std::endl; INuPatchSchema::Sample nurbsSample; nurbsSchema.get( nurbsSample ); // test the bounding box std::cout << nurbsSample.getSelfBounds().min << std::endl; std::cout << nurbsSample.getSelfBounds().max << std::endl; TESTING_ASSERT( nurbsSample.getSelfBounds().min == V3d( 0.0, 0.0, -3.0 ) ); TESTING_ASSERT( nurbsSample.getSelfBounds().max == V3d( 3.0, 3.0, 3.0 ) ); std::cout << "Number of trim curves: " << nurbsSample.getTrimNumLoops() << std::endl; TESTING_ASSERT( nurbsSample.getTrimNumLoops() == 0 ); TESTING_ASSERT( nurbsSample.hasTrimCurve() == false ); TESTING_ASSERT( nurbsSample.getPositionWeights()->size() == ( size_t ) g_nP ); TESTING_ASSERT( nurbsSchema.isConstant() == true ); }
//-***************************************************************************** void ProcessNuPatch( INuPatch &patch, ProcArgs &args ) { INuPatchSchema &ps = patch.getSchema(); TimeSamplingPtr ts = ps.getTimeSampling(); SampleTimeSet sampleTimes; GetRelevantSampleTimes( args, ts, ps.getNumSamples(), sampleTimes ); //trim curves are described outside the motion blocks if ( ps.hasTrimCurve() ) { //get the current time sample independent of any shutter values INuPatchSchema::Sample sample = ps.getValue( ISampleSelector( args.frame / args.fps ) ); RiTrimCurve( sample.getTrimNumCurves()->size(), //numloops (RtInt*) sample.getTrimNumCurves()->get(), (RtInt*) sample.getTrimOrders()->get(), (RtFloat*) sample.getTrimKnots()->get(), (RtFloat*) sample.getTrimMins()->get(), (RtFloat*) sample.getTrimMaxes()->get(), (RtInt*) sample.getTrimNumVertices()->get(), (RtFloat*) sample.getTrimU()->get(), (RtFloat*) sample.getTrimV()->get(), (RtFloat*) sample.getTrimW()->get() ); } bool multiSample = sampleTimes.size() > 1; if ( multiSample ) { WriteMotionBegin( args, sampleTimes ); } for ( SampleTimeSet::iterator iter = sampleTimes.begin(); iter != sampleTimes.end(); ++iter ) { ISampleSelector sampleSelector( *iter ); INuPatchSchema::Sample sample = ps.getValue( sampleSelector ); ParamListBuilder paramListBuilder; //build this here so that it's still in scope when RiNuPatchV is //called. std::vector<RtFloat> pwValues; if ( sample.getPositionWeights() ) { if ( sample.getPositionWeights()->size() == sample.getPositions()->size() ) { //need to combine P with weight form Pw pwValues.reserve( sample.getPositions()->size() * 4 ); const float32_t * pStart = reinterpret_cast<const float32_t * >( sample.getPositions()->get() ); const float32_t * wStart = reinterpret_cast<const float32_t * >( sample.getPositionWeights()->get() ); for ( size_t i = 0, e = sample.getPositionWeights()->size(); i < e; ++i ) { pwValues.push_back( pStart[i*3] ); pwValues.push_back( pStart[i*3+1] ); pwValues.push_back( pStart[i*3+2] ); pwValues.push_back( wStart[i] ); } paramListBuilder.add( "Pw", (RtPointer) &pwValues[0] ); } } if ( pwValues.empty() ) { //no Pw so go straight with P paramListBuilder.add( "P", (RtPointer)sample.getPositions()->get() ); } ICompoundProperty arbGeomParams = ps.getArbGeomParams(); AddArbitraryGeomParams( arbGeomParams, sampleSelector, paramListBuilder ); //For now, use the last knot value for umin and umax as it's //not described in the alembic data RiNuPatchV( sample.getNumU(), sample.getUOrder(), (RtFloat *) sample.getUKnot()->get(), 0.0, //umin sample.getUKnot()->get()[sample.getUKnot()->size()-1],//umax sample.getNumV(), sample.getVOrder(), (RtFloat *) sample.getVKnot()->get(), 0.0, //vmin sample.getVKnot()->get()[sample.getVKnot()->size()-1], //vmax paramListBuilder.n(), paramListBuilder.nms(), paramListBuilder.vals() ); } if ( multiSample ) { RiMotionEnd(); } }