Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 
Add your own
alternative version

Basic Curves And Surfaces Modeler

, 18 Apr 2012
A basic demo of modeling curves and surfaces in OpenGL.
cadsurfexe.zip
CadSurfexe
CadSurf.exe
VKGeom.dll
VKGraphic.dll
cadsurf_demo.zip
cadsurf_src.zip
CadSurf_src
VKernel
VKGraphic
VKGraphic.dsp
VKGraphic.dsw
VKGraphic.plg
VKGeom
VKGeom.dsp
VKGeom.dsw
cadsurf
CadSurf.clw
CadSurf.dsp
cadsurf.dsw
Thumbs.db
res
bmp00001.bmp
cadsurf.ico
CADSURFDOC.ICO
new_splash.bmp
new_splash.PNG
new_splash_small.bmp
tb_geom.bmp
Thumbs.db
toolbar.bmp
toolbar1.bmp
untitled.bmp
XPStyle.manifest
CadSurf_VS2008.zip
CadSurf
cadsurf
CadSurf.suo
res
bmp00001.bmp
cadsurf.ico
CADSURFDOC.ICO
new_splash.bmp
new_splash.PNG
new_splash_small.bmp
tb_geom.bmp
Thumbs.db
toolbar.bmp
toolbar1.bmp
untitled.bmp
VKernel
VKGeom
VKGraphic
VKGraphic.plg
// OneAxis.cpp: implementation of the COneAxis class.
//
//////////////////////////////////////////////////////////////////////

#if HAVE_CONFIG_H
#  include <config.h>
#endif

#include "stdafx.h"

#include "OneAxis.h"
#include "Point3D.h"
#include "Vector3D.h"
#include "MMath.h"

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

//Implementation of class OneAxis 
//(Used for construction of revolutions and as axis of symmetries)
COneAxis::COneAxis()
{
	Position = CPoint3D(0,0,0);
	Direction = CVector3D(0,0,1);
	Direction.Normalize();
	Origin.SetParam(0,0,0);
	geomType = CONEAXIS;
}

COneAxis::COneAxis(const CPoint3D& Pos, const CVector3D& Dir) : Position(Pos), Direction(Dir)
{
	Direction.Normalize();
	Origin.SetParam(Pos.GetX(),Pos.GetY(),Pos.GetZ());
	geomType = CONEAXIS;
}

COneAxis::~COneAxis()
{
}

void COneAxis::SetPosition(const CPoint3D& P)
{
	Position = P;
	Origin = P;
}

void COneAxis::SetPosition(double x, double y, double z)

{
	Position.SetParam(x,y,z);
	Origin.SetParam(x,y,z);
}

void COneAxis::SetDirection(const CVector3D& D)
{
	Direction = D;
	Direction.Normalize();
}

void COneAxis::SetDirection(double dx, double dy, double dz)
{
	Direction.SetParam(dx,dy,dz);
	Direction.Normalize();
}

CPoint3D COneAxis::GetPosition() const
{
	return Position;
}

CVector3D COneAxis::GetOrigin() const
{
	return Origin;
}

CVector3D COneAxis::GetDirection() const
{
	return Direction;
}

bool COneAxis::operator == (const COneAxis& rhAx) const
{
	bool eq = (Position == rhAx.GetPosition() && Direction == rhAx.GetDirection()
				&& Origin == rhAx.GetOrigin());
	return eq;
}

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

void COneAxis::Translate(double dx, double dy, double dz)
{
	CPoint3D P = Position;
	P.Translate(dx, dy, dz);
	SetPosition(P);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Translate(const CVector3D& V)
{
	CPoint3D P = Position;
	P.Translate(V);
	SetPosition(P);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Translate(const CPoint3D& P1, const CPoint3D& P2)
{
	CPoint3D P = Position;
	P.Translate(P1, P2);
	SetPosition(P);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Rotate(const COneAxis& Ax, double ang)
{
	CPoint3D P = Position;
	CVector3D D = Direction;
	P.Rotate(Ax, ang);
	D.Rotate(Ax, ang);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Scale(const CPoint3D& Pnt, double fact)
{
	CPoint3D P = Position;
	CVector3D D = Direction;
	P.Scale(Pnt, fact);
	D.Scale(Pnt, fact);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Mirror(const CPoint3D& Pnt)
{
	CPoint3D P = Position;
	CVector3D D = Direction;
	P.Mirror(Pnt);
	D.Mirror(Pnt);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Mirror(const COneAxis& Ax)
{
	CPoint3D P = Position;
	CVector3D D = Direction;
	/*CString str;
	str.Format(" Now Direction X %0.3lf Y %0.3lf Z %0.3lf", D.GetX(),D.GetY(),D.GetZ());
	MessageBox(0, str, "From Axis", MB_OK);*/
	P.Mirror(Ax);
	CVector3D dir = Ax.GetDirection();
	if(dir.IsParallel(D))
		D.Mirror(Ax.GetDirection());
	else
		D.Mirror(Ax);
	/*str.Format(" Now Direction X %0.3lf Y %0.3lf Z %0.3lf", D.GetX(),D.GetY(),D.GetZ());
	MessageBox(0, str, "From Axis", MB_OK);*/
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

void COneAxis::Mirror(const CPlane& Pln)
{
	CPoint3D P = Position;
	CVector3D D = Direction;
	P.Mirror(Pln);
	D.Mirror(Pln);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY(), P.GetZ());
}

COneAxis COneAxis::OX()
{
	COneAxis Ax(CPoint3D(0,0,0), CVector3D(1,0,0));
	return Ax;
}

COneAxis COneAxis::OY()
{
	COneAxis Ax(CPoint3D(0,0,0), CVector3D(0,1,0));
	return Ax;
}

COneAxis COneAxis::OZ()
{
	COneAxis Ax(CPoint3D(0,0,0), CVector3D(0,0,1));
	return Ax;
}

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)

About the Author

Sharjith
Engineer Tata Technologies Ltd
India India
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

| Advertise | Privacy | Mobile
Web03 | 2.8.140718.1 | Last Updated 18 Apr 2012
Article Copyright 2003 by Sharjith
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid