From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Master/CGuCAD/projects/Prakt2/Prakt2.sln | 20 + Master/CGuCAD/projects/Prakt2/Prakt2.suo | Bin 0 -> 11264 bytes Master/CGuCAD/projects/Prakt2/Prakt2/DocData.cpp | 43 ++ Master/CGuCAD/projects/Prakt2/Prakt2/DocData.h | 40 ++ Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.cpp | 41 ++ Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.rc | 101 ++++ Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj | 273 ++++++++++ .../Prakt2/Prakt2.vcproj.SYNERVA.eisenhauer.user | 65 +++ Master/CGuCAD/projects/Prakt2/Prakt2/Resource.h | 16 + Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.cpp | 27 + Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.h | 58 +++ .../projects/Prakt2/Prakt2/acrxEntryPoint.cpp | 548 +++++++++++++++++++++ 12 files changed, 1232 insertions(+) create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2.sln create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2.suo create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/DocData.cpp create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/DocData.h create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.cpp create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.rc create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj.SYNERVA.eisenhauer.user create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/Resource.h create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.cpp create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.h create mode 100644 Master/CGuCAD/projects/Prakt2/Prakt2/acrxEntryPoint.cpp (limited to 'Master/CGuCAD/projects/Prakt2') diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2.sln b/Master/CGuCAD/projects/Prakt2/Prakt2.sln new file mode 100644 index 0000000..1238da0 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Prakt2", "Prakt2\Prakt2.vcproj", "{348027A3-E648-4FCB-B15F-120EDB7CDB8A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {348027A3-E648-4FCB-B15F-120EDB7CDB8A}.Debug|Win32.ActiveCfg = Debug|Win32 + {348027A3-E648-4FCB-B15F-120EDB7CDB8A}.Debug|Win32.Build.0 = Debug|Win32 + {348027A3-E648-4FCB-B15F-120EDB7CDB8A}.Release|Win32.ActiveCfg = Release|Win32 + {348027A3-E648-4FCB-B15F-120EDB7CDB8A}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2.suo b/Master/CGuCAD/projects/Prakt2/Prakt2.suo new file mode 100644 index 0000000..74b5bf9 Binary files /dev/null and b/Master/CGuCAD/projects/Prakt2/Prakt2.suo differ diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/DocData.cpp b/Master/CGuCAD/projects/Prakt2/Prakt2/DocData.cpp new file mode 100644 index 0000000..aaeeaf7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/DocData.cpp @@ -0,0 +1,43 @@ +// (C) Copyright 2002-2007 by Autodesk, Inc. +// +// Permission to use, copy, modify, and distribute this software in +// object code form for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both that copyright notice and the limited warranty and +// restricted rights notice below appear in all supporting +// documentation. +// +// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. +// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF +// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. +// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE +// UNINTERRUPTED OR ERROR FREE. +// +// Use, duplication, or disclosure by the U.S. Government is subject to +// restrictions set forth in FAR 52.227-19 (Commercial Computer +// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) +// (Rights in Technical Data and Computer Software), as applicable. +// + +//----------------------------------------------------------------------------- +//----- DocData.cpp : Implementation file +//----------------------------------------------------------------------------- +#include "StdAfx.h" + +//----------------------------------------------------------------------------- +//----- The one and only document manager object. You can use the DocVars object to retrieve +//----- document specific data throughout your application +AcApDataManager DocVars ; + +//----------------------------------------------------------------------------- +//----- Implementation of the document data class. +CDocData::CDocData () { +} + +//----------------------------------------------------------------------------- +CDocData::CDocData (const CDocData &data) { +} + +//----------------------------------------------------------------------------- +CDocData::~CDocData () { +} diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/DocData.h b/Master/CGuCAD/projects/Prakt2/Prakt2/DocData.h new file mode 100644 index 0000000..456f3f7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/DocData.h @@ -0,0 +1,40 @@ +// (C) Copyright 2002-2007 by Autodesk, Inc. +// +// Permission to use, copy, modify, and distribute this software in +// object code form for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both that copyright notice and the limited warranty and +// restricted rights notice below appear in all supporting +// documentation. +// +// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. +// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF +// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. +// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE +// UNINTERRUPTED OR ERROR FREE. +// +// Use, duplication, or disclosure by the U.S. Government is subject to +// restrictions set forth in FAR 52.227-19 (Commercial Computer +// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) +// (Rights in Technical Data and Computer Software), as applicable. +// + +//----------------------------------------------------------------------------- +//----- DocData.h : include file for document specific data. An instance of this +//----- class is automatically created and managed by the AsdkDataManager class. +//----- See the AsdkDmgr.h / DocData.cpp for more datails +//----------------------------------------------------------------------------- +#pragma once + +//----------------------------------------------------------------------------- +//----- Here you can store the document / database related data. +class CDocData { + + //----- TODO: here you can add your variables + +public: + CDocData () ; + CDocData (const CDocData &data) ; + ~CDocData () ; + +} ; diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.cpp b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.cpp new file mode 100644 index 0000000..bff7959 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.cpp @@ -0,0 +1,41 @@ +// (C) Copyright 2002-2007 by Autodesk, Inc. +// +// Permission to use, copy, modify, and distribute this software in +// object code form for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both that copyright notice and the limited warranty and +// restricted rights notice below appear in all supporting +// documentation. +// +// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. +// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF +// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. +// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE +// UNINTERRUPTED OR ERROR FREE. +// +// Use, duplication, or disclosure by the U.S. Government is subject to +// restrictions set forth in FAR 52.227-19 (Commercial Computer +// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) +// (Rights in Technical Data and Computer Software), as applicable. +// + +//----------------------------------------------------------------------------- +//- Prakt2.cpp : Initialization functions +//----------------------------------------------------------------------------- +#include "StdAfx.h" +#include "resource.h" + +//----------------------------------------------------------------------------- +//- DLL Entry Point +extern "C" +BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { + //- Remove this if you use lpReserved + UNREFERENCED_PARAMETER(lpReserved) ; + + if ( dwReason == DLL_PROCESS_ATTACH ) { + _hdllInstance =hInstance ; + } else if ( dwReason == DLL_PROCESS_DETACH ) { + } + return (TRUE) ; +} + diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.rc b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.rc new file mode 100644 index 0000000..b67580a --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.rc @@ -0,0 +1,101 @@ +//Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Prakt2 ObjectARX application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "Prakt2\0" + VALUE "LegalCopyright", "Copyright © 2002\0" + VALUE "OriginalFilename", "CGCAD_seiPrakt2.arx\0" + VALUE "ProductName", "Prakt2 Application\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END + +#endif // !_MAC + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "Prakt2" +END + + + +///////////////////////////////////////////////////////////////////////////// + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj new file mode 100644 index 0000000..c82dfb7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj.SYNERVA.eisenhauer.user b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj.SYNERVA.eisenhauer.user new file mode 100644 index 0000000..e82dc15 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/Prakt2.vcproj.SYNERVA.eisenhauer.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/Resource.h b/Master/CGuCAD/projects/Prakt2/Prakt2/Resource.h new file mode 100644 index 0000000..9d4a05f --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Prakt2.rc +// +#define IDS_PROJNAME 100 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 100 +#define _APS_NEXT_SYMED_VALUE 102 +#endif +#endif diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.cpp b/Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.cpp new file mode 100644 index 0000000..afd4d88 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.cpp @@ -0,0 +1,27 @@ +// (C) Copyright 2002-2007 by Autodesk, Inc. +// +// Permission to use, copy, modify, and distribute this software in +// object code form for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both that copyright notice and the limited warranty and +// restricted rights notice below appear in all supporting +// documentation. +// +// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. +// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF +// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. +// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE +// UNINTERRUPTED OR ERROR FREE. +// +// Use, duplication, or disclosure by the U.S. Government is subject to +// restrictions set forth in FAR 52.227-19 (Commercial Computer +// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) +// (Rights in Technical Data and Computer Software), as applicable. +// + +//----------------------------------------------------------------------------- +//------ StdAfx.cpp : source file that includes just the standard includes +//------ StdAfx.pch will be the pre-compiled header +//------ StdAfx.obj will contain the pre-compiled type information +//----------------------------------------------------------------------------- +#include "StdAfx.h" diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.h b/Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.h new file mode 100644 index 0000000..55926f2 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/StdAfx.h @@ -0,0 +1,58 @@ +// (C) Copyright 2002-2007 by Autodesk, Inc. +// +// Permission to use, copy, modify, and distribute this software in +// object code form for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both that copyright notice and the limited warranty and +// restricted rights notice below appear in all supporting +// documentation. +// +// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. +// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF +// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. +// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE +// UNINTERRUPTED OR ERROR FREE. +// +// Use, duplication, or disclosure by the U.S. Government is subject to +// restrictions set forth in FAR 52.227-19 (Commercial Computer +// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) +// (Rights in Technical Data and Computer Software), as applicable. +// + +//----------------------------------------------------------------------------- +//- StdAfx.h : include file for standard system include files, +//- or project specific include files that are used frequently, +//- but are changed infrequently +//----------------------------------------------------------------------------- +#pragma once + +#pragma pack (push, 8) +#pragma warning(disable: 4786 4996) +//#pragma warning(disable: 4098) + +//----------------------------------------------------------------------------- +#include + +//- ObjectARX and OMF headers needs this +#include + +//----------------------------------------------------------------------------- +//- Include ObjectDBX/ObjectARX headers +//- Uncomment one of the following lines to bring a given library in your project. +//#define _BREP_SUPPORT_ //- Support for the BRep API +//#define _HLR_SUPPORT_ //- Support for the Hidden Line Removal API +//#define _AMODELER_SUPPORT_ //- Support for the AModeler API +//#define _ASE_SUPPORT_ //- Support for the ASI/ASE API +//#define _RENDER_SUPPORT_ //- Support for the AutoCAD Render API +//#define _ARX_CUSTOM_DRAG_N_DROP_ //- Support for the ObjectARX Drag'n Drop API +//#define _INC_LEAGACY_HEADERS_ //- Include legacy headers in this project +#include "arxHeaders.h" + +//----------------------------------------------------------------------------- +#include "DocData.h" //- Your document specific data class holder + +//- Declare it as an extern here so that it becomes available in all modules +extern AcApDataManager DocVars ; + +#pragma pack (pop) + diff --git a/Master/CGuCAD/projects/Prakt2/Prakt2/acrxEntryPoint.cpp b/Master/CGuCAD/projects/Prakt2/Prakt2/acrxEntryPoint.cpp new file mode 100644 index 0000000..1ae2fdc --- /dev/null +++ b/Master/CGuCAD/projects/Prakt2/Prakt2/acrxEntryPoint.cpp @@ -0,0 +1,548 @@ +// (C) Copyright 2002-2007 by Autodesk, Inc. +// +// Permission to use, copy, modify, and distribute this software in +// object code form for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both that copyright notice and the limited warranty and +// restricted rights notice below appear in all supporting +// documentation. +// +// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. +// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF +// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. +// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE +// UNINTERRUPTED OR ERROR FREE. +// +// Use, duplication, or disclosure by the U.S. Government is subject to +// restrictions set forth in FAR 52.227-19 (Commercial Computer +// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) +// (Rights in Technical Data and Computer Software), as applicable. +// + +//----------------------------------------------------------------------------- +//----- acrxEntryPoint.cpp +//----------------------------------------------------------------------------- +#include "StdAfx.h" +#include "resource.h" +#include + +//----------------------------------------------------------------------------- +#define szRDS _RXST("CGCAD_sei") + +// Global +#define CIRCLE_LAYER _T("kreise") +#define POLYGON_LAYER _T("substitut") +#define POLYLINE_LAYER _T("pline") +static const double pi = 3.141592653589793238462643383279502884197; // Archimedes constant pi + +// Prototypes +int createLayers(); +int processCircles(ads_real); +int processArcs(ads_real); +int createPoly(ads_real,AcGePoint3d,double); +int createPolyForArc(ads_real,AcDbArc*); +int calculateAngleAndNumber(const ads_real&, const double&, double &,int&); +int createPline(const AcGePoint3d&,const double&,const double&, const int&); +int createSegLines(const AcGePoint3d&,const double&,const double&, const int&); +int movePlinesToPlineLayer(); +//----------------------------------------------------------------------------- +//----- ObjectARX EntryPoint +class CPrakt2App : public AcRxArxApp { + +public: + CPrakt2App () : AcRxArxApp () {} + + virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) { + // TODO: Load dependencies here + + // You *must* call On_kInitAppMsg here + AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ; + + // TODO: Add your initialization code here + + return (retCode) ; + } + + virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) { + // TODO: Add your code here + + // You *must* call On_kUnloadAppMsg here + AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ; + + // TODO: Unload dependencies here + + return (retCode) ; + } + + virtual void RegisterServerComponents () { + } + + + // - CGCAD_seiPrakt2.ctopoly command (do not rename) + static void CGCAD_seiPrakt2ctopoly(void) + { + ads_real maxErrorPercentage; + if(RTNORM != acedGetReal(_T("Please enter max. error bulge:"),&maxErrorPercentage)) { + acutPrintf(_T("\nError reading bulge. Exiting.")); + return; + } + createLayers(); + processCircles(maxErrorPercentage); + processArcs(maxErrorPercentage); + movePlinesToPlineLayer(); + } +} ; + +//----------------------------------------------------------------------------- +IMPLEMENT_ARX_ENTRYPOINT(CPrakt2App) + +ACED_ARXCOMMAND_ENTRY_AUTO(CPrakt2App, CGCAD_seiPrakt2, ctopoly, ktoviel, ACRX_CMD_MODAL, NULL) + +int createLayers() { + AcDbLayerTable *pLayerTable = NULL; + + acdbTransactionManager->startTransaction(); + Acad::ErrorStatus res = acdbTransactionManager->getObject((AcDbObject*&) pLayerTable,curDoc()->database()->layerTableId(),AcDb::kForRead); + + AcDbLayerTableRecord *pCircleLayerTableRecord = NULL; + AcDbLayerTableRecord *pPolyLayerTableRecord = NULL; + AcDbLayerTableRecord *pPlineLayerTableRecord = NULL; + if (!pLayerTable->has(POLYGON_LAYER)) { + acutPrintf(_T("\nCreating Polygon Layer")); + pLayerTable->upgradeOpen(); + pPolyLayerTableRecord = new AcDbLayerTableRecord; + pPolyLayerTableRecord->setName(POLYGON_LAYER); + AcCmColor polyColor; + polyColor.setRGB(255,0,0); + pPolyLayerTableRecord->setColor(polyColor); + pPolyLayerTableRecord->setIsLocked(false); + pPolyLayerTableRecord->setIsFrozen(false); + pPolyLayerTableRecord->setIsOff(false); + pPolyLayerTableRecord->setIsHidden(false); + if ( Acad::eOk != pLayerTable->add(pPolyLayerTableRecord) ) { + acutPrintf(_T("\nError adding Polygon Layer")); + acdbTransactionManager->abortTransaction(); + return 2; + } + acdbTransactionManager->addNewlyCreatedDBRObject(pPolyLayerTableRecord); + } else { + acutPrintf(_T("\nPolygon Layer already exists")); + } + if (!pLayerTable->has(CIRCLE_LAYER)) { + acutPrintf(_T("\nCreating Circle Layer")); + pLayerTable->upgradeOpen(); + pCircleLayerTableRecord = new AcDbLayerTableRecord; + pCircleLayerTableRecord->setName(CIRCLE_LAYER); + AcCmColor circleColor; + circleColor.setRGB(0,255,0); + pCircleLayerTableRecord->setColor(circleColor); + pCircleLayerTableRecord->setIsLocked(false); + pCircleLayerTableRecord->setIsFrozen(false); + pCircleLayerTableRecord->setIsOff(false); + pCircleLayerTableRecord->setIsHidden(false); + if ( Acad::eOk != pLayerTable->add(pCircleLayerTableRecord) ) { + acutPrintf(_T("\nError adding Circle Layer")); + acdbTransactionManager->abortTransaction(); + return 2; + } + acdbTransactionManager->addNewlyCreatedDBRObject(pCircleLayerTableRecord); + } else { + acutPrintf(_T("\nCircle Layer already exists")); + } + if (!pLayerTable->has(POLYLINE_LAYER)) { + acutPrintf(_T("\nCreating Pline Layer")); + pLayerTable->upgradeOpen(); + pPlineLayerTableRecord = new AcDbLayerTableRecord; + pPlineLayerTableRecord->setName(POLYLINE_LAYER); + AcCmColor plineColor; + plineColor.setRGB(0,0,255); + pPlineLayerTableRecord->setColor(plineColor); + pPlineLayerTableRecord->setIsLocked(false); + pPlineLayerTableRecord->setIsFrozen(false); + pPlineLayerTableRecord->setIsOff(false); + pPlineLayerTableRecord->setIsHidden(false); + if ( Acad::eOk != pLayerTable->add(pPlineLayerTableRecord) ) { + acutPrintf(_T("\nError adding Pline Layer")); + acdbTransactionManager->abortTransaction(); + return 2; + } + acdbTransactionManager->addNewlyCreatedDBRObject(pPlineLayerTableRecord); + } else { + acutPrintf(_T("\nPline Layer already exists")); + } + acdbTransactionManager->endTransaction(); + return 0; +} + +int processCircles(ads_real bulge) { + // Construct the filter + struct resbuf eb1; + eb1.restype = 0; + // Entity name + eb1.resval.rstring = _T("CIRCLE"); + eb1.rbnext = NULL; + // Select All Circles + ads_name ss; + AcDbEntity* pEnt = NULL; + ads_name ent; + AcDbObjectId id = AcDbObjectId::kNull; + if (acedSSGet(_T("X"), NULL, NULL, &eb1, ss) != RTNORM) { + // Free the resbuf + acutRelRb(&eb1); + acutPrintf(_T("\nError doing selection. Exiting")); + return 1; + } + // Get the length (how many entities were selected) + long length = 0; + if ((acedSSLength( ss, &length ) != RTNORM) || (length == 0)) { + acutPrintf(_T("\nNo circles selected"),length); + acedSSFree( ss ); + return 1; + } + acutPrintf(_T("\nSelected %d circles"),length); + acdbTransactionManager->startTransaction(); + // Walk through the selection set and open each entity + for (long i = 0; i < length; i++) { + if (acedSSName(ss,i,ent) != RTNORM) + continue; + if (acdbGetObjectId(id,ent) != Acad::eOk) + continue; + if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,id,AcDb::kForWrite) != Acad::eOk) { + continue; + } + int res = wcscmp( pEnt->layer(), CIRCLE_LAYER ); + if ( res != 0) { + if(pEnt->setLayer(CIRCLE_LAYER) != Acad::eOk) { + acutPrintf(_T("\nError moving Circle to Circle Layer")); + continue; + } + AcDbCircle* circle = (AcDbCircle*) pEnt; + createPoly(bulge,circle->center(),circle->radius()); + } + } + acdbTransactionManager->endTransaction(); + // Free selection + acedSSFree( ss ); + return 0; +} + +int processArcs(ads_real bulge) { + // Construct the filter + struct resbuf eb1; + eb1.restype = 0; + // Entity name + eb1.resval.rstring = _T("ARC"); + eb1.rbnext = NULL; + // Select All Circles + ads_name ss; + AcDbEntity* pEnt = NULL; + ads_name ent; + AcDbObjectId id = AcDbObjectId::kNull; + if (acedSSGet(_T("X"), NULL, NULL, &eb1, ss) != RTNORM) { + // Free the resbuf + acutRelRb(&eb1); + acutPrintf(_T("\nError doing selection. Exiting")); + return 1; + } + // Get the length (how many entities were selected) + long length = 0; + if ((acedSSLength( ss, &length ) != RTNORM) || (length == 0)) { + acutPrintf(_T("\nNo Arcs selected"),length); + acedSSFree( ss ); + return 1; + } + acutPrintf(_T("\nSelected %d arcs"),length); + acdbTransactionManager->startTransaction(); + // Walk through the selection set and open each entity + for (long i = 0; i < length; i++) { + if (acedSSName(ss,i,ent) != RTNORM) + continue; + if (acdbGetObjectId(id,ent) != Acad::eOk) + continue; + if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,id,AcDb::kForWrite) != Acad::eOk) { + continue; + } + if (wcscmp(pEnt->layer(),CIRCLE_LAYER) != 0) { + AcDbArc* arc = (AcDbArc*) pEnt; + if (-1 != createPolyForArc(bulge,arc) ) { + if(pEnt->setLayer(CIRCLE_LAYER) != Acad::eOk) { + acutPrintf(_T("\nError moving Arc to Circle Layer")); + continue; + } + } + } + } + acdbTransactionManager->endTransaction(); + // Free selection + acedSSFree( ss ); + return 0; +} +int createPolyForArc(ads_real max_bulge,AcDbArc* arc) { + int numberOfCorners = 0; + double startAngle = arc->startAngle(); + acutPrintf(_T("\narc start angle: %f"),startAngle); + double endAngle = arc->endAngle(); + acutPrintf(_T("\narc end angle: %f"),endAngle); + if (startAngle > endAngle) { + double tmp = startAngle; + startAngle = endAngle; + endAngle = tmp; + } + double arcAngle = endAngle - startAngle; + acutPrintf(_T("\narc angle: %f"),arcAngle); + long double alpha_star = std::acos((100-max_bulge)/100)*2; + acutPrintf(_T("\nalpha* is: %f"),alpha_star); + //long double n_star = 2*pi/alpha_star; + long double n_star = arcAngle/alpha_star; + acutPrintf(_T("\nn* is: %f"),n_star); + numberOfCorners = (int) ceil(n_star); + acutPrintf(_T("\nn is: %d"),numberOfCorners); + double alpha = (arcAngle) / numberOfCorners; + if ( alpha_star > arcAngle) { + acutPrintf(_T("\nAlpha greater arc angle: alpha=%f arcAngle=%f"),alpha,arcAngle); + return -1; + } + double actAngle = startAngle; + AcDbBlockTable* pBlockTable = NULL; + acdbTransactionManager->startTransaction(); + Acad::ErrorStatus res = acdbTransactionManager->getObject((AcDbObject*&) pBlockTable,curDoc()->database()->blockTableId(),AcDb::kForRead); + if (res != Acad::eOk) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table. Exiting")); + return -1; + } + AcDbBlockTableRecord* pBlockTableRecord = NULL; + if( Acad::eOk != pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead) ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table Record. Exiting")); + return -1; + } + double radius = arc->radius(); + AcGePoint3d center = arc->center(); + AcGePoint3d startPoint; + AcGePoint3d endPoint; + for(int i=0; i < numberOfCorners; i++) { + if (i==0) { + startPoint.x = radius * std::cos(startAngle) + center.x; + startPoint.y = radius * std::sin(startAngle) + center.y; + startPoint.z = 0.0; + } else { + startPoint.x = endPoint.x; + startPoint.y = endPoint.y; + } + actAngle += alpha; + endPoint.x = radius * std::cos(actAngle) + center.x; + endPoint.y = radius * std::sin(actAngle) + center.y; + endPoint.z = 0.0; + AcDbLine* pNewLine = new AcDbLine(startPoint,endPoint); + pNewLine->setLayer(POLYGON_LAYER); + + AcDbObjectId newLineId = AcDbObjectId::kNull; + if (Acad::eOk != pBlockTableRecord->upgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table Record for write: %d time. Exiting"),i); + return -1; + } + if ( Acad::eOk != pBlockTableRecord->appendAcDbEntity(newLineId, pNewLine)) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError adding line %d to Block Table Record. Exiting"),i); + return -1; + } + if (Acad::eOk != pBlockTableRecord->downgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError downgrading Block Table Record for read: %d time. Exiting"),i); + return -1; + } + + if ( Acad::eOk != acdbTransactionManager->addNewlyCreatedDBRObject(pNewLine) ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError adding new Line &d to TransactionManager. Exiting"),i); + return -1; + } + } + acdbTransactionManager->endTransaction(); + pBlockTableRecord->close(); + + return 0; +} + +int createPoly(ads_real max_bulge,AcGePoint3d center,double radius) { + int n = 0; + double alpha; + calculateAngleAndNumber(max_bulge,radius,alpha,n); + acutPrintf(_T("\ncenter* is: %f,%f,%f"),center.x,center.y,center.z); + + //createPline(center,radius,alpha,n); + createSegLines(center,radius,alpha,n); + return 0; +} +int calculateAngleAndNumber(const ads_real& max_bulge, const double& radius, double & alpha, int & numberOfCorners) { + long double alpha_star = std::acos((100-max_bulge)/100)*2; + acutPrintf(_T("\nalpha* is: %f"),alpha_star); + long double n_star = 2*pi/alpha_star; + acutPrintf(_T("\nn* is: %f"),n_star); + numberOfCorners = (int) ceil(n_star); + acutPrintf(_T("\nn is: %d"),numberOfCorners); + alpha = (2*pi) / numberOfCorners; + return 0; +} +int createPline(const AcGePoint3d& center,const double& radius, const double& alpha, const int& numberOfCorners) { + double actAngle = alpha; + ads_point pt; + pt[0]=center.x+radius; + pt[1]=center.y; + pt[2]=center.z; + struct resbuf *myCom; + myCom = acutBuildList(RTSTR,_T("_pline"),RTPOINT,pt,0); + acedCmd(myCom); + for (int i = 1; istartTransaction(); + Acad::ErrorStatus res = acdbTransactionManager->getObject((AcDbObject*&) pBlockTable,curDoc()->database()->blockTableId(),AcDb::kForRead); + if (res != Acad::eOk) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table. Exiting")); + return -1; + } + ads_real x = radius * std::cos(alpha) + center.x; + ads_real y = radius * std::sin(alpha) + center.y; + ads_real z = 0.0; + AcGePoint3d startPoint(center.x+radius,center.y,center.z); + AcGePoint3d endPoint(x,y,z); + AcDbLine* pline = new AcDbLine(startPoint,endPoint); + pline->setLayer(POLYGON_LAYER); + + AcDbBlockTableRecord* pBlockTableRecord = NULL; + if( Acad::eOk != pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead) ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table Record. Exiting")); + return -1; + } + // Using ModelSpace pointer we can add our brand new line + AcDbObjectId lineId = AcDbObjectId::kNull; + if (Acad::eOk != pBlockTableRecord->upgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table Record first time for write. Exiting")); + return -1; + } + if ( Acad::eOk != pBlockTableRecord->appendAcDbEntity(lineId, pline)) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError adding first line to Block Table Record. Exiting")); + return -1; + } + if (Acad::eOk != pBlockTableRecord->downgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError downgrading Block Table Record first time for read. Exiting")); + return -1; + } + if ( Acad::eOk != acdbTransactionManager->addNewlyCreatedDBRObject(pline) ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError adding first Line to TransactionManager. Exiting")); + return -1; + } + + for(int i=1; i < numberOfCorners; i++) { + AcGePoint3d newStartPoint; + newStartPoint.x = endPoint.x; + newStartPoint.y = endPoint.y; + newStartPoint.z = endPoint.z; + actAngle +=alpha; + acutPrintf(_T("\nangle is: %f"),actAngle); + endPoint.x = radius * std::cos(actAngle) + center.x; + endPoint.y = radius * std::sin(actAngle) + center.y; + endPoint.z = 0.0; + AcDbLine* pNewLine = new AcDbLine(newStartPoint,endPoint); + pNewLine->setLayer(POLYGON_LAYER); + + AcDbObjectId newLineId = AcDbObjectId::kNull; + if (Acad::eOk != pBlockTableRecord->upgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError opening Block Table Record for write: %d time. Exiting"),i); + return -1; + } + if ( Acad::eOk != pBlockTableRecord->appendAcDbEntity(newLineId, pNewLine)) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError adding line %d to Block Table Record. Exiting"),i); + return -1; + } + if (Acad::eOk != pBlockTableRecord->downgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError downgrading Block Table Record for read: %d time. Exiting"),i); + return -1; + } + + if ( Acad::eOk != acdbTransactionManager->addNewlyCreatedDBRObject(pNewLine) ) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError adding new Line &d to TransactionManager. Exiting"),i); + return -1; + } + } + acdbTransactionManager->endTransaction(); + pBlockTableRecord->close(); + return 0; +} +int movePlinesToPlineLayer() { + // Construct the filter + struct resbuf eb1; + eb1.restype = 0; + // Entity name + eb1.resval.rstring = _T("*POLYLINE"); + eb1.rbnext = NULL; + // Select All Circles + ads_name ss; + AcDbEntity* pEnt = NULL; + ads_name ent; + AcDbObjectId id = AcDbObjectId::kNull; + if (acedSSGet(_T("X"), NULL, NULL, &eb1, ss) != RTNORM) { + // Free the resbuf + acutRelRb(&eb1); + acutPrintf(_T("\nError doing selection. Exiting")); + return 1; + } + // Get the length (how many entities were selected) + long length = 0; + if ((acedSSLength( ss, &length ) != RTNORM) || (length == 0)) { + acutPrintf(_T("\nNo Plines selected"),length); + acedSSFree( ss ); + return 1; + } + acutPrintf(_T("\nSelected %d Plines"),length); + acdbTransactionManager->startTransaction(); + // Walk through the selection set and open each entity + for (long i = 0; i < length; i++) { + if (acedSSName(ss,i,ent) != RTNORM) + continue; + if (acdbGetObjectId(id,ent) != Acad::eOk) + continue; + if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,id,AcDb::kForWrite) != Acad::eOk) { + continue; + } + if(pEnt->setLayer(POLYLINE_LAYER) != Acad::eOk) { + acutPrintf(_T("\nError moving Pline %d to Plines Layer"),i); + continue; + } + } + acdbTransactionManager->endTransaction(); + // Free selection + acedSSFree( ss ); + return 0; +} \ No newline at end of file -- cgit v1.2.3