示例#1
0
文件: Surf.cpp 项目: amgary/OpenVSP
void Surf::LoadControlPnts( vector< vector< vec3d > > & control_pnts )
{
	int i, j;
	assert( control_pnts.size() >= 4 );
	assert( control_pnts[0].size() >= 4);
	m_Pnts = control_pnts;

	m_NumU = m_Pnts.size();
	m_NumW = m_Pnts[0].size();
	m_MaxU = (m_NumU-1)/3;
	m_MaxW = (m_NumW-1)/3;

	//==== Load Patch Vec ====//
	m_BBox.init();
	for ( i = 0 ; i < (int)m_PatchVec.size() ; i++ )
		delete m_PatchVec[i];
	m_PatchVec.clear();

	for ( i = 0 ; i < m_NumU-1 ; i+=3 )
	{
		for ( j = 0 ; j < m_NumW-1 ; j+=3 )
		{
			SurfPatch* patch = new SurfPatch();
			for ( int pi = 0 ; pi < 4 ; pi++ )
				for ( int pj = 0 ; pj < 4 ; pj++ )
				{
					m_BBox.update( m_Pnts[pi+i][pj+j] );
					patch->put_pnt( pi, pj, m_Pnts[pi+i][pj+j] );

					patch->set_u_min_max( i/3, i/3 + 1.0 );
					patch->set_w_min_max( j/3, j/3 + 1.0 );
				}
			patch->set_surf_ptr( this );
			patch->compute_bnd_box();
			m_PatchVec.push_back( patch );
		}
	}
}
示例#2
0
void SurfCore::BuildPatches( Surf* srf ) const
{
    vector< SurfPatch* > patchVec = srf->GetPatchVec();

    for ( int i = 0 ; i < ( int )patchVec.size() ; i++ )
    {
        delete patchVec[i];
    }
    patchVec.clear();

    for ( int ip = 0; ip < m_Surface.number_u_patches(); ip++ )
    {
        for ( int jp = 0; jp < m_Surface.number_v_patches(); jp++ )
        {
            double umin, du, vmin, dv;
            const surface_patch_type *epatch = m_Surface.get_patch( ip, jp, umin, du, vmin, dv );

            SurfPatch* patch = new SurfPatch();

            patch->setPatch( *epatch );

            patch->set_u_min_max( umin, umin + du );
            patch->set_w_min_max( vmin, vmin + dv );

            patch->set_surf_ptr( srf );
            patch->compute_bnd_box();

            patchVec.push_back( patch );
        }
    }

    surface_bounding_box_type bbox;
    m_Surface.get_bounding_box( bbox );
    srf->SetBBox( bbox.get_max(), bbox.get_min() );
    srf->SetPatchVec( patchVec );
}