|
here is header file
#ifndef CustLine1_H
#define CustLine1_H
#define ACRX_DXF_DEFINE_MEMBERS(CustLine1,AcDbCurveDWG_VERSION,\ MAINTENANCE_VERSION,PROXY_FLAGS,DXF_NAME,APP) \
class CustLine1 : public AcDbCurve
{
public:
ACRX_DECLARE_MEMBERS(CustLine1);
CustLine1(); //constructor
~CustLine1(); //Destructor
// Declaring function to overrride for my custom entity line;
virtual Acad::ErrorStatus
dwgInFields(AcDbDwgFiler* filer);
virtual Acad::ErrorStatus
dwgOutFields(AcDbDwgFiler* filer) const;
virtual Acad::ErrorStatus
dxfInFields(AcDbDxfFiler* filer);
virtual Acad::ErrorStatus
dxfOutFields(AcDbDxfFiler* filer) const;
<Destructor> (~AcDbObject)
// Declaring AcDbEntity functions to be overriden in cpp file, for my custom entity line;
virtual Adesk::Boolean
subWorldDraw(
AcGiWorldDraw* mode);
virtual Acad::ErrorStatus
subGetGeomExtents(
AcDbExtents& extents) const;
virtual Acad::ErrorStatus
subTransformBy(
const AcGeMatrix3d& xform);
virtual Acad::ErrorStatus
subGetTransformedCopy(
const AcGeMatrix3d& xform,
AcDbEntity*& ent) const;
// Declaring AcDbCurve funcitons that need to be overidden for my custom entity line;
virtual Adesk::Boolean isClosed() const; \
virtual Adesk::Boolean isPeriodic() const; \
virtual Acad::ErrorStatus getStartParam(double&) const; \
virtual Acad::ErrorStatus getEndParam(double&) const; \
virtual Acad::ErrorStatus getStartPoint(AcGePoint3d&) const; \
virtual Acad::ErrorStatus getEndPoint(AcGePoint3d&) const; \
virtual Acad::ErrorStatus getPointAtParam(double, AcGePoint3d&) const; \
virtual Acad::ErrorStatus getParamAtPoint(const AcGePoint3d&, double&) const; \
virtual Acad::ErrorStatus getDistAtParam(double, double&) const; \
virtual Acad::ErrorStatus getParamAtDist(double, double&) const; \
virtual Acad::ErrorStatus getDistAtPoint(const AcGePoint3d&, double&) const; \
virtual Acad::ErrorStatus getPointAtDist(double, AcGePoint3d&) const; \
virtual Acad::ErrorStatus extend( double newParam);
virtual Acad::ErrorStatus getOrthoProjectedCurve(const AcGePlane&, \
AcDbCurve*&) const; \
virtual Acad::ErrorStatus getProjectedCurve(const AcGePlane&, \
const AcGeVector3d&, AcDbCurve*&) const; \
};
#pragma pack (pop)
#endif
And now the CustLine1. cpp file ( work in progress_need to finish calculations)
//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//////////////////////////////////////////////////////////////////////////////
//
// Arx entry for '«PROJECTNAME»' project.
//
#if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
#error _DEBUG should not be defined except in internal Adesk debug builds
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rxregsvc.h>
#include <rxboiler.h>
#include <rxobject.h>
#include <aced.h>
#include <dbsymtb.h>
#include <dbmain.h>
#include <dbents.h>
#include <gemat3d.h>
#include <gepent3d.h>
#include <gevec3d.h>
#include <gevec2d.h>
#include <gemat3d.h>
#include <acgi.h>
#include <drawable.h>
#include "tchar.h"
#include <CustLine1.h>
#define VERSION_CUSTLINE1
CustLine1::CustLine1() //constructor
{
// Declare my variables here
int x;
int y;
int z;
}
CustLine1::~CustLine1() // Destructor
{}
class CustLine1 : public AcDbCurve
{
public:
ACRX_DECLARE_MEMBERS(CustLine1);
AcRxClass* CustLine1::desc()
{
if (CustLine1::gpDesc != 0)
return CustLine1::gpDesc;
return CustLine1::gpDesc =
(AcRxClass*)((AcRxDictionary*)acrxSysRegistry()->
at("ClassDictionary"))->at("CustLine1");
}
AcRxClass* CustLine1::isA() const
{
return CustLine1::desc();
}
AcRxClass* CustLine1::gpDesc = 0;
static AcRxObject * makeCustLine1()
{
return new CustLine1();
}
void CustLine1::rxInit()
{
if (CustLine1::gpDesc != 0)
return;
CustLine1::gpDesc = newAcRxClass("CustLine1",
"AsdkCurve", AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
0, &makeCustLine1, "Line1", "\"AutoCAD\"");
}
ACRX_DEFINE_MEMBERS(CustLine1);
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
static AcRxObject * make##CustLine1() { return new CustLine1(); }
void CustLine1::rxInit() {
ACRX_STATIC_CHECK(CustLine1);
CustLine1::gpDesc = newAcRxClass(ACRX_T(#CustLine1), ACRX_T(AcDbCurve),
DWG_VERSION,MAINTENANCE_VERSION,PROXY_FLAGS, \
&make##CustLine1, ACRX_T(DXFCustLine1), ACRX_T(#APP));
}
void CustLine1::rxInit(AppNameChangeFuncPtr ptr) {
ACRX_STATIC_CHECK(CustLine1);
CustLine1::gpDesc = newAcRxClass(ACRX_T(#CustLine1), ACRX_T(AcDbCurve),
DWG_VERSION,MAINTENANCE_VERSION,PROXY_FLAGS, \
&make##CustLine1, ACRX_T(DXFCustLine1), ACRX_T(#APP), ptr);
}
// AcdbEntity functions overriding
// implement dwgInFields;
Acad::ErrorStatus
CustLine1::dwgInFields(AcDbDwgFiler* filer)
{
assertWriteEnabled();
Acad::ErrorStatus es;
if ((es = AcDbCurve::dwgInFields(filer)) != Acad::eOk)
{
return es;
}
// Object Version - must always be the first item.
//
Adesk::Int16 version;
filer->readItem(&version);
if (version > VERSION)
return Acad::eMakeMeProxy;
switch (version)
{
case 1:
{
AcGePoint3d center;
filer->readPoint3d(¢er);
AcGePoint3d startPoint;
filer->readPoint3d(&startPoint);
filer->readInt32(&mNumSides);
filer->readVector3d(&mPlaneNormal);
acutDelString(mpName);
filer->readString(&mpName);
filer->readHardPointerId(&mTextStyle);
//convert data from old format
acdbWcs2Ecs(asDblArray(center),asDblArray(center),
asDblArray(mPlaneNormal),Adesk::kFalse);
mCenter.set(center.x,center.y);
mElevation = center.z;
acdbWcs2Ecs(asDblArray(startPoint),asDblArray(startPoint),
asDblArray(mPlaneNormal),Adesk::kFalse);
mStartPoint.set(startPoint.x,startPoint.y);
assert(mElevation == startPoint.z);
break;
}
case 2:
filer->readPoint2d(&mCenter);
filer->readPoint2d(&mStartPoint);
filer->readInt32(&mNumSides);
filer->readVector3d(&mPlaneNormal);
acutDelString(mpName);
filer->readString(&mpName);
filer->readHardPointerId(&mTextStyle);
filer->readDouble(&mElevation);
break;
default:
assert(false);
}
return filer->filerStatus();
}
// Overriding dwgOutFields
Acad::ErrorStatus
CustLine1::dwgOutFields(AcDbDwgFiler* filer) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = AcDbCurve::dwgOutFields(filer))
!= Acad::eOk)
{
return es;
}
// Object Version - must always be the first item.
//
Adesk::Int16 version = VERSION;
filer->writeItem(version);
filer->writePoint2d(mCenter);
filer->writePoint2d(mStartPoint);
filer->writeInt32(mNumSides);
filer->writeVector3d(mPlaneNormal);
filer->writeString(mpName);
// mTextStyle is a hard pointer id, so filing it out to
// the purge filer (kPurgeFiler) prevents purging of
// this object.
//
filer->writeHardPointerId(mTextStyle);
filer->writeDouble(mElevation);
return filer->filerStatus();
}
//Overridding dxfInFields
Acad::ErrorStatus
CustLine1::dxfInFields(AcDbDxfFiler* filer)
{
assertWriteEnabled();
Acad::ErrorStatus es = Acad::eOk;
resbuf rb;
if ((AcDbCurve::dxfInFields(filer) != Acad::eOk)
|| !filer->atSubclassData("CustLine1"))
{
return filer->filerStatus();
}
// Object Version
Adesk::Int16 version;
filer->readItem(&rb);
if (rb.restype != AcDb::kDxfInt16)
{
filer->pushBackItem();
filer->setError(Acad::eInvalidDxfCode,
"\nError: expected group code %d (version)",
AcDb::kDxfInt16);
return filer->filerStatus();
}
version = rb.resval.rint;
if (version > VERSION)
return Acad::eMakeMeProxy;
AcGePoint3d cen3d,sp3d;
AcGePoint2d cen2d,sp2d;
long numSides;
AcDbObjectId textStyle;
double elevation;
Adesk::UInt32 fieldsFlags = 0;
char * pName = NULL;
AcGeVector3d planeNormal;
while ((es == Acad::eOk)
&& ((es = filer->readResBuf(&rb)) == Acad::eOk))
{
switch (rb.restype) {
case AcDb::kDxfXCoord:
if (version == 1)
cen3d = asPnt3d(rb.resval.rpoint);
else
cen2d = asPnt2d(rb.resval.rpoint);
fieldsFlags |= 0x1;
break;
case AcDb::kDxfXCoord + 1:
if (version == 1)
sp3d = asPnt3d(rb.resval.rpoint);
else
sp2d = asPnt2d(rb.resval.rpoint);
fieldsFlags |= 0x2;
break;
case AcDb::kDxfInt32:
numSides = rb.resval.rlong;
fieldsFlags |= 0x4;
break;
case AcDb::kDxfNormalX:
planeNormal = asVec3d(rb.resval.rpoint);
fieldsFlags |= 0x8;
break;
case AcDb::kDxfText:
acutUpdString(rb.resval.rstring,pName);
fieldsFlags |= 0x11;
break;
case AcDb::kDxfHardPointerId:
acdbGetObjectId(textStyle, rb.resval.rlname);
fieldsFlags |= 0x12;
break;
case AcDb::kDxfReal:
if (version == 2)
{
fieldsFlags |= 0x10;
elevation = rb.resval.rreal;
break;
}
//fall through intentional
default:
// An unrecognized group. Push it back so that
// the subclass can read it again.
filer->pushBackItem();
es = Acad::eEndOfFile;
break;
}
}
// At this point, the es variable must contain eEndOfFile,
// either from readResBuf() or from pushbackBackItem(). If
// not, it indicates that an error happened and we should
// return immediately.
//
if (es != Acad::eEndOfFile)
return Acad::eInvalidResBuf;
// Now check to be sure all necessary group codes were
// present.
//
// Mandatory fields:
// - center
// - start point
// - normal
// - number of sides
// - elevation (if version > 1)
short required[] =
{AcDb::kDxfXCoord, AcDb::kDxfXCoord+1, AcDb::kDxfInt32,
AcDb::kDxfNormalX, AcDb::kDxfReal};
for (short i = 0; i < (version>1?4:3); i++) {
if (!fieldsFlags & 0x1) {
filer->setError(Acad::eMissingDxfField,
"\nMissing DXF group code: %d", 2, required[i]);
return Acad::eMissingDxfField;
} else
fieldsFlags >>= 1;
}
mPlaneNormal = planeNormal;
mNumSides = numSides;
mTextStyle = textStyle;
setName(pName);
acutDelString(pName);
if (version==1)
{
//convert data from old format
acdbWcs2Ecs(asDblArray(cen3d),asDblArray(cen3d),
asDblArray(planeNormal),Adesk::kFalse);
mCenter.set(cen3d.x,cen3d.y);
mElevation = cen3d.z;
acdbWcs2Ecs(asDblArray(sp3d),asDblArray(sp3d),
asDblArray(planeNormal),Adesk::kFalse);
mStartPoint.set(sp3d.x,sp3d.y);
assert(mElevation == sp3d.z);
} else {
mCenter = cen2d;
mStartPoint = sp2d;
mElevation = elevation;
}
return es;
}
// Overridding dxfOutFields
Acad::ErrorStatus
CustLine1::dxfOutFields(AcDbDxfFiler* filer ) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = AcDbCurve::dxfOutFields(filer))
!= Acad::eOk)
{
return es;
}
filer->writeItem(AcDb::kDxfSubclass, "CustLine1");
// Object Version
//
Adesk::Int16 version = VERSION;
filer->writeInt16(AcDb::kDxfInt16, version);
filer->writePoint2d(AcDb::kDxfXCoord, mCenter);
filer->writePoint2d(AcDb::kDxfXCoord + 1, mStartPoint);
filer->writeInt32(AcDb::kDxfInt32, mNumSides);
// Always use max precision when writing out the normal.
filer->writeVector3d(AcDb::kDxfNormalX, mPlaneNormal,16);
filer->writeString(AcDb::kDxfText, mpName);
filer->writeItem(AcDb::kDxfHardPointerId, mTextStyle);
filer->writeDouble(AcDb::kDxfReal, mElevation);
return filer->filerStatus();
}
// Overriding AcDbEntity Methods for my CustLine1 entity;
// Overridding subWorldDraw function;
Adesk::Boolean
subWorldDraw(AcGiWorldDraw* wd);
CustLine1::subWorldDraw(AcGiWorldDraw* draw)
{ assertReadEnabled();
{
CustLine1::subWorldDraw(AcGiWorldDraw* draw) {
//m_Line is a member of MyCustomObject
draw->geometry().draw(&m_Line);
}
virtual Adesk::Boolean polyline(const Adesk::UInt32 nbPoints,
const AcGePoint3d* pVertexList,
const AcGeVector3d* pNormal = NULL,
Adesk::LongPtr lBaseSubEntMarker = -1) const = 0;
// Create a point a the source;
AcGePoint3d::AcGePoint3d(const AcGePoint3d& src) : x(src.x), y(src.y), z(src.z)
{ //Operators
AcGePoint3d& src=new AcGePoint3d (x(src.x), y(src.y), z(src.z))
x = 10;
y = 5;
z = x+y;
src=0.5 ; }
virtual void setExtents(AcGePoint3d * pNewExtents) const = 0;
{ AcGePoint3d& set (double x, double y, double z);
AcGePoint3d * pNexExTents = new AcGePoint3d(double x, double y, double z);
double x = 1;
double y = x+1 ;
double z = y+1 ; }
}
}
// Overridding subGetGeomExtents
Acad::ErrorStatus
CustLine1::subGetGeomExtents(AcDbExtents& extents) const;
{ assertReadEnabled();
{ //Insert AcDbExtents methods here
// Min and Max Extents
AcGePoint3d minPoint(1.5) const;
{
minPoint= 1.5;
}
AcGePoint3d maxPoint() const;
{
maxPoint = 7.8;
}
// Set Extents
Acad::ErrorStatus set(const AcGePoint3d& min , const AcGePoint3d& max);
{
min = 10.0,
max = 20.5
return Acad::eOk
}
// Transform Extents
void transformBy(const AcGeMatrix3d& mat);
{
// The components of the matrix3d.
//
double entry[row][column] ;
// operators for transforming the extents
AcGeMatrix3d::operator () (
unsigned int row,
unsigned int column) const
{
row = 4;
colum = 4;
return entry[row][column];
}
}// end of transformBy function
// Mirroring and projecting Extents
static AcGeMatrix3d mirroring (const AcGeLine3d& line);
{ AcGeLine3d Line = new Line ( double x, double y, double z)
double x = 14.0;
double y = 48.0 ;
double z = 17.0 ;
}
static AcGeMatrix3d projection (const AcGePlane& projectionPlane, const AcGeVector3d& projectDir); {}
// Rotating Extants
AcGeMatrix3d rotation (double angle, const AcGeVector3d& axis,
const AcGePoint3d& center = AcGePoint3d::kOrigin);
{
double angle = 45.0;
} //End of rotation extents
}
};
//Overriding subTransformBy;
Acad::ErrorStatus
CustLine1::subTransformBy(const AcGeMatrix3d& xform);
{ assertReadEnabled();
{ // Insert AcGeMatrix3d TransformBy methods here
AcGeMatrix3d();
// The components of the matrix3d.
//
double entry[row][column] ;
// operators for transforming the extents
AcGeMatrix3d::operator () (
unsigned int row,
unsigned int column) const
{
row = 4;
colum = 4;
return entry[row][column];
}
//Multiplication Inverse
AcGeMatrix3d inverse () const;
{
}
//Set Translation
AcGeMatrix3d& setTranslation (const AcGeVector3d& vec);
{
AcGeVector3d v1, v2, v3
v1 =;
v2 = v1+ 1;
v1 = v2 +1;
}
// transformations by rotation and mirroring
static
AcGeMatrix3d rotation (double angle, const AcGeVector3d& axis,
const AcGePoint3d& center
= AcGePoint3d::kOrigin);
{ double angle = 15;
}
static
AcGeMatrix3d scaling (double scaleAll, const AcGePoint3d& center= AcGePoint3d::kOrigin);
{
double scaleAll = ;
}
}//end of assertReadEnabled();
};
// Overriding subGetTransformedCopy
Acad::ErrorStatus
CustLine1::subGetTransformedCopy(const AcGeMatrix3d& xform, AcDbEntity*& ent) const;
{
assertReadEnabled();
// Transform by Multiplication.
{
// Matrix3d constructor
AcGeMatrix3d();
{
double [row][colum];
row = 4 ;
colum = 4 ;
}
// Multiplicative inverse.
//
AcGeMatrix3d& invert(15);
{
}
AcGeMatrix3d inverse(-x) const;
{
};
}
// Multiplication.
AcGeMatrix3d operator * (const AcGeMatrix3d& mat) const;
{
AcGeMatrix3d mat3d;
{
double mat3d = [row][colum];
row = 4 ;
colum = 4 ;
}
AcGeMatrix3d& operator *= (const AcGeMatrix3d& mat);
{
}
}
AcGeMatrix3d& preMultBy (const AcGeMatrix3d& leftSide);
{
leftSide = x-1
}
AcGeMatrix3d& postMultBy (const AcGeMatrix3d& rightSide);
{
rightSide = x+1
}
// Set/retrieve translation.
//
AcGeMatrix3d& setTranslation (const AcGeVector3d& vec);
{
AcGeVector3d vec = new vertice [double x, double y, double z]
vertice1 = (1.0, 2.0, 5.0);
vertice2 = v1*5;
vertice3 = v1+v2;
}
// GetTransformedCopy by mirroring
static
AcGeMatrix3d mirroring (const AcGeLine3d& line);
{
AcGeLine3d line = new line(double x, double y, double z)
double x = 5 ;
double y = 2*x1;
double z = x+y;
}
} //end of assertReadEnabled();
};
// Implementing my Custom Line 1 ( CustLine1) function;
//
AcGePoint3d startPoint() const;
Acad::ErrorStatus CustLine1::setStartPoint(const AcGePoint3d&);
{
AcGePoint3d StartPoint = new StartPoint(x, y, z)
x = 1.0;
y = 1.0;
z = 1.0;
}
AcGePoint3d endPoint() const;
Acad::ErrorStatus CustLine1::setEndPoint(const AcGePoint3d&);
{
AcGePoint3d EndPoint = new EndtPoint(x, y, z)
x = 18.0;
y = 15.0;
z = 13.0;
}
//
Acad::ErrorStatus CustLine1::setThickness(double);
{
double 5.0
Acad::eOk
}
//
AcGeVector3d normal() const;
{
}
//
Acad::ErrorStatus CustLine1::setNormal(const AcGeVector3d&);
{
AcGeVector3d vecNormal1, vecNormal2;
vecNormal1 = (x, y, z);
vecNormal2 = 2*vecNormal1;
}
} // End of Custline1 class
// Overriding curve methods for my CustLine1 entity;
Adesk::Boolean
CustLine1::isClosed() const
{
bool kTrue = true;
}
//
Adesk::Boolean
CustLine1::isPeriodic()const
{
bool kTrue = true;
}
//
Acad::ErrorStatus
CustLine1::getStartParam(double&) const;
{
double getStartParam = 4.0 ;
}
//
Acad::ErrorStatus CustLine1::getEndParam(double&) const;
{
double detEndParam = 8.0
}
//
Acad::ErrorStatus CustLine1::getStartPoint(AcGePoint3d&) const;
{
AcGePoint3d pt3d ( double x, double y, double z);
double x = ;
double y = ;
double z = ;
//
AcGePoint3d& set(double x,double y,double z);
{
AcGePoint3d setx, sety, setz;
setx = ;
sety = ;
setz = ;
}
//
AcGePoint3d& rotateBy(double angle,const AcGeVector3d& vec,const AcGePoint3d& wrtPoint = AcGePoint3d::kOrigin
);
{
};
//
Acad::ErrorStatus
CustLine1::getEndPoint(AcGePoint3d&) const;
{
AcGePoint3d getEndPoint = new getEndPoint( double x, double y, double z)
double x,
double y,
double z
);
};
Acad::ErrorStatus
CustLine1::getPointAtParam(double,AcGePoint3d&) const;
{
AcGePoint3d(
double x,
double y,
double z
);
};
Acad::ErrorStatus
CustLine1::getParamAtPoint(const AcGePoint3d& ,double&) const;
{
AcGePoint3d ParamAtPoint = ( double x, double y, double z)
double x = ;
double y = ;
double z = ;
};
Acad::ErrorStatus
CustLine1::getDistAtParam(double param,double& dist) const;
{
double dist = ;
double param = ;
}
Acad::ErrorStatus
CustLine1::getParamAtDist( double dist,double& param) const;
{
double dist = ;
double param = ;
}
Acad::ErrorStatus CustLine1::getDistAtPoint(const AcGePoint3d&,double&) const;
{ AcGePoint3d DistAtPoint = new DistAtPoint(double x,double y,double z);
double x = ;
double y = ;
double z = ;
}
AcGePoint3d& set(double x,double y,double z);
{
AcGePoint3d setPnt = new SetPnt ( double x, double y, double z)
double x = ;
double y = ;
double z = ;
}
};
Acad::ErrorStatus
CustLine1::getPointAtDist(double, AcGePoint3d&) const;
{
AcGePoint3d NewPntAtDist = new PointAtDist( double x, double y, double z)
double x = ;
double y = ;
double z = ;
}
AcGePoint3d setPnt = new SetPnt( double x, double y, double z)
double x = ;
double y = ;
double z = ;
};
Acad::ErrorStatus
CustLine1::extend(Adesk::Boolean extendStart,const AcGePoint3d& toPoint);
{
AcGePoint3d toPoint = new toPnt( double x, double y, double z)
double x = ;
double y = ;
double z = ;
}
Acad::ErrorStatus
CustLine1::getOrthoProjectedCurve(const AcGePlane&, AcDbCurve*& projCrv) const;
{
}
Acad::ErrorStatus
CustLine1::getProjectedCurve( const AcGePlane&,const AcGeVector3d& projDir,AcDbCurve*& projCrv) const;
{
}
/// Override getOffsetCurvesGivenPlaneNormal for mu CustLine1
Acad::ErrorStatus
CustLine1::getOffsetCurvesGivenPlaneNormal(const AcGeVector3d& normal, double offsetDist, AcDbVoidPtrArray& offsetCurves) const;
{
}
};// end of my CustLine1 function |
|