Exemple #1
0
void Surf::ApplyES( vec3d uw, double t )
{
	double grm1 = m_GridDensityPtr->GetGrowRatio() - 1.0;
	int nmapu = m_SrcMap.size();
	int nmapw = m_SrcMap[0].size();

	int ibase, jbase;
	double u = uw.x();
	double w = uw.y();
	UWtoTargetMapij( u, w, ibase, jbase );

	vec3d p = CompPnt( u, w );

	int iadd[] = { 0, 1, 0, 1 };
	int jadd[] = { 0, 0, 1, 1 };

	for(int i = 0; i < 4; i++ )
	{
		int itarget = ibase + iadd[i];
		int jtarget = jbase + jadd[i];

		if( itarget < nmapu && itarget >= 0 && jtarget < nmapw && jtarget >= 0 )
		{
			vec3d p2 = m_SrcMap[ itarget ][ jtarget ].m_pt;
			double r = ( p2 - p ).mag();
			double targetstr = t + r * grm1;
			if( m_SrcMap[ itarget ][ jtarget ].m_str > targetstr )
			{
				m_SrcMap[ itarget ][ jtarget ].m_str = targetstr;
				pair< int, int > ijstart( itarget, jtarget );
				WalkMap( ijstart, ijstart );
			}
		}
	}
}
Exemple #2
0
void SSLineSeg::UpdateDrawObj( VspSurf* surf, Geom* geom, DrawObj& draw_obj, const int *num_pnts_ptr )
{
    int num_pnts;
    if ( num_pnts_ptr )
    {
        num_pnts = *num_pnts_ptr;
    }
    else
    {
        num_pnts = CompNumDrawPnts( surf, geom );
    }

    draw_obj.m_PntVec.resize( num_pnts + 1 );

    for ( int i = 0 ; i <= num_pnts ; i ++ )
    {
        vec3d uw = ( m_P0 + m_line * ( ( double )i / num_pnts ) );
        draw_obj.m_PntVec[i] = CompPnt( surf, uw );
    }

    draw_obj.m_LineWidth = 3.0;
    draw_obj.m_LineColor = vec3d( 177.0 / 255, 1, 58.0 / 255 );
    draw_obj.m_Type = DrawObj::VSP_LINE_STRIP;
    draw_obj.m_GeomChanged = true;
}
Exemple #3
0
void Surf::BuildTargetMap( vector< MapSource* > &sources, int sid )
{
	int npatchu = ( m_NumU - 1 ) / 3;
	int npatchw = ( m_NumW - 1 ) / 3;

	int nmapu = npatchu * ( m_NumMap - 1 ) + 1;
	int nmapw = npatchw * ( m_NumMap - 1 ) + 1;

	// Initialize map matrix dimensions
	m_SrcMap.resize( nmapu );
	for( int i = 0; i < nmapu ; i++ )
	{
		m_SrcMap[i].resize( nmapw );
	}

	// Loop over surface evaluating source strength and curvature
	for( int i = 0; i < nmapu ; i++ )
	{
		double u = ( 1.0 * i ) / ( m_NumMap - 1 );
		for( int j = 0; j < nmapw ; j++ )
		{
			double w = ( 1.0 * j ) / ( m_NumMap - 1 );

			double len = numeric_limits<double>::max( );

			// apply curvature based limits
			double curv_len = TargetLen( u, w, m_GridDensityPtr->GetMaxGap(), m_GridDensityPtr->GetRadFrac());
			len = min( len, curv_len );

			// apply minimum edge length as safety on curvature
			len = max( len, m_GridDensityPtr->GetMinLen() );

			// apply sources
			vec3d p = CompPnt( u, w );
			double grid_len = m_GridDensityPtr->GetTargetLen( p );
			len = min( len, grid_len );

			// finally check max size
			len = min( len, m_GridDensityPtr->GetBaseLen() );

			MapSource ms = MapSource( p, len, sid );
			m_SrcMap[i][j] = ms;
			sources.push_back( &( m_SrcMap[i][j] ) );
		}
	}
}
Exemple #4
0
bool Surf::BorderCurveOnSurface( Surf* surfPtr )
{
	bool retFlag = false;
	double tol = 1.0e-05;

	vector< SCurve* > border_curves;
	surfPtr->LoadSCurves( border_curves );

	for ( int i = 0 ; i < (int)border_curves.size() ; i++ )
	{
		vector< vec3d > control_pnts;
		border_curves[i]->ExtractBorderControlPnts( control_pnts );

		int num_pnts_on_surf = 0;
		for ( int c = 0 ; c < (int)control_pnts.size() ; c++ )
		{
			vec2d uw = ClosestUW( control_pnts[c], m_MaxU/2.0, m_MaxW/2.0 );

			vec3d p = CompPnt( uw[0], uw[1] );

			double d = dist( control_pnts[c], p );

			if ( d < tol )
			{
				num_pnts_on_surf++;
				retFlag = true;
			}
		}
		if ( num_pnts_on_surf >= 2 )
		{
			//==== If Surface Add To List ====//
			m_CfdMeshMgr->AddPossCoPlanarSurf( this, surfPtr );
		}
	}

	return retFlag;
}
Exemple #5
0
//===== Compute Point On Surf Given  U W (Between 0 1 ) =====//
vec3d SurfCore::CompPnt01( double u, double w ) const
{
    return CompPnt( GetMinU() + u * GetDU(), GetMinW() + w * GetDW() );
}
Exemple #6
0
vec2d Surf::ClosestUW( vec3d & pnt, double guess_u, double guess_w, double guess_del_u, double guess_del_w, double tol )
{
	double u = guess_u;
	double w = guess_w;
	double del_u = guess_del_u;
	double del_w = guess_del_w;
	double dist = dist_squared( pnt, CompPnt(u, w) );

	if ( dist < tol )
		return vec2d( u, w );

	int iter = 20;
	while ( iter > 0 )
	{
		double u_plus  = u + del_u;
		double u_minus = u - del_u;
		if ( u_plus  > m_MaxU )
		{
			u_plus  = m_MaxU;
			del_u *= 0.25;
		}
		if ( u_minus < 0 )
		{
			u_minus = 0.0;
			del_u *= 0.25;
		}

		double dist_plus_u  = dist_squared( pnt, CompPnt(u_plus, w) );
		double dist_minus_u = dist_squared( pnt, CompPnt(u_minus, w) );
		if ( dist_plus_u < dist )
		{
			u = u_plus;
			del_u *= 2.0;
			dist = dist_plus_u;
		}
		else if ( dist_minus_u < dist )
		{
			u = u_minus;
			del_u *= 2.0;
			dist = dist_minus_u;
		}
		else
		{
			del_u *= 0.5;
			iter--;
		}

		double w_plus = w + del_w;
		double w_minus = w - del_w;
		if ( w_plus > m_MaxW )
		{
			w_plus = m_MaxW;
			del_w *= 0.25;
		}
		if ( w_minus < 0 )
		{
			w_minus = 0;
			del_w *= 0.25;
		}

		double dist_plus_w  = dist_squared( pnt, CompPnt(u, w_plus ) );
		double dist_minus_w = dist_squared( pnt, CompPnt(u, w_minus ) );
		if ( dist_plus_w < dist )
		{
			w = w_plus;
			del_w *= 2.0;
			dist = dist_plus_w;
		}
		else if ( dist_minus_w < dist )
		{
			w = w_minus;
			del_w *= 2.0;
			dist = dist_minus_w;
		}
		else
		{
			del_w *= 0.5;
			iter--;
		}
	}

	return vec2d( u, w );
}
Exemple #7
0
void Surf::Draw()
{
	////==== Draw Control Hull ====//
	//glLineWidth( 2.0 );
	//glColor3ub( 0, 0, 255 );

	//for ( int i = 0 ; i < (int)m_Pnts.size() ; i++ )
	//{
	//	glBegin( GL_LINE_STRIP );
	//	for ( int j = 0 ; j < (int)m_Pnts[i].size() ; j++ )
	//	{
	//		glVertex3dv( m_Pnts[i][j].data() );
	//	}
	//	glEnd();
	//}
	//glPointSize( 3.0 );
	//glColor3ub( 255, 255, 255 );
	//glBegin( GL_POINTS );
	//for ( int i = 0 ; i < (int)m_Pnts.size() ; i++ )
	//{
	//	for ( int j = 0 ; j < (int)m_Pnts[i].size() ; j++ )
	//	{
	//		glVertex3dv( m_Pnts[i][j].data() );
	//	}
	//}
	//glEnd();


/************************************************/

	//==== Draw Surface ====//
	int max_u = (m_NumU-1)/3;
	int max_w = (m_NumW-1)/3;

	glLineWidth( 1.0 );
	glColor3ub( 0, 255, 0 );

	int num_xsec = 10;
	int num_tess = 20;
	for ( int i = 0 ; i < num_xsec ; i++ )
	{
		double u = max_u*(double)i/(double)(num_xsec-1);
		glBegin( GL_LINE_STRIP );
		for ( int j = 0 ; j < num_tess ; j++ )
		{
			double w = max_w*(double)j/(double)(num_tess-1);
			vec3d p = CompPnt( u, w );
			glVertex3dv( p.data() );
		}
		glEnd();
	}

	for ( int j = 0 ; j < num_xsec ; j++ )
	{
		double w = max_w*(double)j/(double)(num_xsec-1);
		glBegin( GL_LINE_STRIP );
		for ( int i = 0 ; i < num_tess ; i++ )
		{
			double u = max_u*(double)i/(double)(num_tess-1);
			vec3d p = CompPnt( u, w );
			glVertex3dv( p.data() );

		}
		glEnd();
	}
/**********************************/

	//for ( int i = 0 ; i < (int)m_SCurveVec.size() ; i++ )
	//{
	//	m_SCurveVec[i]->Draw();
	//}

	m_Mesh.Draw();

	//for ( int i = 0 ; i < (int)m_PatchVec.size() ; i++ )
	//{
	//	m_PatchVec[i]->Draw();
	//}

	//glLineWidth( 2.0 );
	//glColor3ub( 255, 0, 0 );
	//glBegin( GL_LINES );
	//for ( int i = 0 ; i < (int)ipnts.size() ; i++ )
	//{
	//	if ( i%4 > 1 )
	//		glColor3ub( 255, 0, 0 );
	//	else
	//		glColor3ub( 255, 255, 0 );


	//	vec3d uw = ipnts[i];
	//	vec3d p = CompPnt( uw[0], uw[1] );
	//	glVertex3dv( p.data() );
	//}
	//glEnd();



}
Exemple #8
0
//===== Compute Point On Surf Given  U W (Between 0 1 ) =====//
vec3d Surf::CompPnt01( double u, double w )
{
	return CompPnt( u*m_MaxU, w*m_MaxW );
}
//===== Compute Point U 0.0 -> 1.0 =====//
vec3d VspCurve::CompPnt01( double u )
{
    return CompPnt( u * m_Curve.get_tmax() );
}