Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / MFC

Basic Curves And Surfaces Modeler

Rate me:
Please Sign up or sign in to vote.
4.17/5 (40 votes)
18 Apr 2012CPOL3 min read 246.5K   16.4K   117  
A basic demo of modeling curves and surfaces in OpenGL.
// ExtrudedSurface.cpp: implementation of the CExtrudedSurface class.
//
//////////////////////////////////////////////////////////////////////


#include "stdafx.h"

#include "ExtrudedSurface.h"
#include "MMath.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CExtrudedSurface::CExtrudedSurface(const CCurve* C, const CVector3D& Dir, const double& s, const double& e) : startLimit(s), endLimit(e)
{
	sType = EXTRUDED;
	baseCurve = C->Copy();
	itsDirection = Dir;
}

CExtrudedSurface::~CExtrudedSurface()
{
	if(baseCurve)
		delete baseCurve;
}

CPoint3D CExtrudedSurface::PointAtPara(const double uPar, const double vPar)
{
	CVector3D P;
	CVector3D G(baseCurve->PointAtPara(uPar));
	CVector3D Dir = itsDirection*vPar;
	P = G+Dir;
	return P.Point();
}

double CExtrudedSurface::FirstUParameter() const
{
	return baseCurve->FirstParameter();
}

double CExtrudedSurface::LastUParameter() const
{
	return baseCurve->LastParameter();
}

double CExtrudedSurface::FirstVParameter() const
{
	return startLimit;
}

double CExtrudedSurface::LastVParameter() const
{
	return endLimit;
}

bool CExtrudedSurface::IsUClosed() const
{
	return false;
}

bool CExtrudedSurface::IsVClosed() const
{
	return false;
}

CSurface* CExtrudedSurface::Copy() const
{
	CExtrudedSurface* R = new CExtrudedSurface(baseCurve, itsDirection, startLimit, endLimit);
	return R;
}

void CExtrudedSurface::Translate(const COneAxis& Ax, const double& amt)
{
	CGeometry::Translate(Ax, amt);
}

void CExtrudedSurface::Translate(double dx, double dy, double dz)
{
	baseCurve->Translate(dx,dy,dz);
}

void CExtrudedSurface::Translate(const CVector3D& V)
{
	baseCurve->Translate(V);
}

void CExtrudedSurface::Translate(const CPoint3D& P1, const CPoint3D& P2)
{
	baseCurve->Translate(P1, P2);
}

void CExtrudedSurface::Rotate(const COneAxis& Ax, double ang)
{
	baseCurve->Rotate(Ax, ang);
}

void CExtrudedSurface::Scale(const CPoint3D& P, double fact)
{
	baseCurve->Scale(P, fact);
}

void CExtrudedSurface::Mirror(const CPoint3D& P)
{
	baseCurve->Mirror(P);
}

void CExtrudedSurface::Mirror(const COneAxis& Ax)
{
	baseCurve->Mirror(Ax);
}

void CExtrudedSurface::Mirror(const CPlane& Pln)
{
	baseCurve->Mirror(Pln);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager Mahindra & Mahindra
India India
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

Comments and Discussions