コード例 #1
0
ファイル: TopoAlgs.cpp プロジェクト: beauby/pigale
int TopologicalGraph::ExpandEdges()
{ 
  int nadded=0;
  int morig=ne();
  tedge e;
  int i;
  if (!Set(tedge()).exist(PROP_MULTIPLICITY)) return 0;
  Prop<int>  multiplicity(Set(tedge()),PROP_MULTIPLICITY);
  for (e=1; e<=morig; e++)
    {for (i=2; i<=multiplicity[e]; ++i)
      NewEdge(e.firsttbrin(), e.secondtbrin());
    nadded+=multiplicity[e]-1;
    }
  Set(tedge()).erase(PROP_MULTIPLICITY);
  // add loops
  if (!Set(tvertex()).exist(PROP_NLOOPS))
    return nadded;
  tvertex v;
  Prop<int> nloops(Set(tvertex()),PROP_NLOOPS);
  for (v=1; v<=nv(); ++v)
    for (i=1; i<=nloops[v]; ++i)
      {++nadded;
      NewEdge(v,v);
      }
  Set(tvertex()).erase(PROP_NLOOPS);
  return nadded;
}
コード例 #2
0
	static void _write(liqRibMeshData* pData, const structJob &currentJob)
	{
		CM_TRACE_FUNC("rm_writeMeshData.cpp::_write("<<pData->getFullPathName().asChar()<<","<<currentJob.name.asChar()<<")");

		if( pData->isEmpty() )
		{
			liquidMessage( "Could not export degenerate mesh", messageError );
			return;
		}
		//
		//RiArchiveRecord( RI_COMMENT, "Sometimes the polygon cant be rendered correctly, so I try to reverse the normal. //- yaoyansi" );
		//RiReverseOrientation();

		if(pData->isAreaLight())
		{
			RtLightHandle handle = INVALID_LIGHT_INDEX;

			{ // What happens if we're inside a motion block????? This whole approach of Liquid is flawed...
				LIQDEBUGPRINTF( "-> mesh is area light\n" );
				//	RiAttributeBegin();
				RtString ribname = const_cast< char* >( pData->getFullPathName().asChar() );
				RiAttribute( "identifier", "name", &ribname, RI_NULL );
				RtMatrix tmp;
				memcpy( tmp, pData->getTransformationMatrixPtr(), sizeof( RtMatrix ) );
				RiTransform( tmp );
				float areaIntensity = pData->getAreaIntensity();
				handle = RiAreaLightSource( "arealight", "intensity", &areaIntensity, RI_NULL );
			}
			//
			//mesh data begin
			//
			// Each loop has one polygon, so we just want an array of 1's of
			// the correct size. Stack version.
			//vector< RtInt > nloops( numFaces, 1 );
			// Alternatively (heap version):
			boost::scoped_array< RtInt > nloops( new RtInt[ pData->getNumFaces() ] );
			std::fill( nloops.get(), nloops.get() + pData->getNumFaces(), ( RtInt )1 );

			unsigned numTokens( pData->tokenPointerArray.size() );
			boost::scoped_array< RtToken > tokenArray( new RtToken[ numTokens ] );
			boost::scoped_array< RtPointer > pointerArray( new RtPointer[ numTokens ] );
			assignTokenArraysV( pData->tokenPointerArray, tokenArray.get(), pointerArray.get() );

			RiPointsGeneralPolygonsV( pData->getNumFaces(),
				&nloops[ 0 ],
				pData->getNverts().get(),
				pData->getVerts().get(),
				numTokens,
				tokenArray.get(),
				pointerArray.get() );
			//mesh data end

			{
				// RiAttributeEnd();
				RiIlluminate( handle, 1 );
			}
		}else{
			//mesh data begin
			//
			// Each loop has one polygon, so we just want an array of 1's of
			// the correct size. Stack version.
			//vector< RtInt > nloops( numFaces, 1 );
			// Alternatively (heap version):
			boost::scoped_array< RtInt > nloops( new RtInt[ pData->getNumFaces() ] );
			std::fill( nloops.get(), nloops.get() + pData->getNumFaces(), ( RtInt )1 );

			unsigned numTokens( pData->tokenPointerArray.size() );
			boost::scoped_array< RtToken > tokenArray( new RtToken[ numTokens ] );
			boost::scoped_array< RtPointer > pointerArray( new RtPointer[ numTokens ] );
			assignTokenArraysV( pData->tokenPointerArray, tokenArray.get(), pointerArray.get() );

			RiPointsGeneralPolygonsV( pData->getNumFaces(),
				&nloops[ 0 ],
				pData->getNverts().get(),
				pData->getVerts().get(),
				numTokens,
				tokenArray.get(),
				pointerArray.get() );
			//mesh data end//	
		}
	}