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/Prakt3/Prakt3.sln | 20 + Master/CGuCAD/projects/Prakt3/Prakt3.suo | Bin 0 -> 14336 bytes Master/CGuCAD/projects/Prakt3/Prakt3/DocData.cpp | 43 ++ Master/CGuCAD/projects/Prakt3/Prakt3/DocData.h | 40 ++ Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.cpp | 41 ++ Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.rc | 101 +++++ Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj | 273 +++++++++++++ .../Prakt3/Prakt3.vcproj.SYNERVA.eisenhauer.user | 65 +++ Master/CGuCAD/projects/Prakt3/Prakt3/Resource.h | 16 + Master/CGuCAD/projects/Prakt3/Prakt3/StdAfx.cpp | 27 ++ Master/CGuCAD/projects/Prakt3/Prakt3/StdAfx.h | 58 +++ .../projects/Prakt3/Prakt3/acrxEntryPoint.cpp | 439 +++++++++++++++++++++ 12 files changed, 1123 insertions(+) create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3.sln create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3.suo create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/DocData.cpp create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/DocData.h create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.cpp create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.rc create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj.SYNERVA.eisenhauer.user create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/Resource.h create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/StdAfx.cpp create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/StdAfx.h create mode 100644 Master/CGuCAD/projects/Prakt3/Prakt3/acrxEntryPoint.cpp (limited to 'Master/CGuCAD/projects/Prakt3') diff --git a/Master/CGuCAD/projects/Prakt3/Prakt3.sln b/Master/CGuCAD/projects/Prakt3/Prakt3.sln new file mode 100644 index 0000000..057c5be --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Prakt3", "Prakt3\Prakt3.vcproj", "{DA66148E-37B5-4078-92E8-274378E3772C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA66148E-37B5-4078-92E8-274378E3772C}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA66148E-37B5-4078-92E8-274378E3772C}.Debug|Win32.Build.0 = Debug|Win32 + {DA66148E-37B5-4078-92E8-274378E3772C}.Release|Win32.ActiveCfg = Release|Win32 + {DA66148E-37B5-4078-92E8-274378E3772C}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Master/CGuCAD/projects/Prakt3/Prakt3.suo b/Master/CGuCAD/projects/Prakt3/Prakt3.suo new file mode 100644 index 0000000..c794858 Binary files /dev/null and b/Master/CGuCAD/projects/Prakt3/Prakt3.suo differ diff --git a/Master/CGuCAD/projects/Prakt3/Prakt3/DocData.cpp b/Master/CGuCAD/projects/Prakt3/Prakt3/DocData.cpp new file mode 100644 index 0000000..aaeeaf7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/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/Prakt3/Prakt3/DocData.h b/Master/CGuCAD/projects/Prakt3/Prakt3/DocData.h new file mode 100644 index 0000000..456f3f7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/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/Prakt3/Prakt3/Prakt3.cpp b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.cpp new file mode 100644 index 0000000..d516ff2 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.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. +// + +//----------------------------------------------------------------------------- +//- Prakt3.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/Prakt3/Prakt3/Prakt3.rc b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.rc new file mode 100644 index 0000000..8568868 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.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", "Prakt3 ObjectARX application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "Prakt3\0" + VALUE "LegalCopyright", "Copyright © 2002\0" + VALUE "OriginalFilename", "CGCAD_seiPrakt3.arx\0" + VALUE "ProductName", "Prakt3 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 "Prakt3" +END + + + +///////////////////////////////////////////////////////////////////////////// + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj new file mode 100644 index 0000000..bd224ac --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj.SYNERVA.eisenhauer.user b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj.SYNERVA.eisenhauer.user new file mode 100644 index 0000000..e82dc15 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/Prakt3.vcproj.SYNERVA.eisenhauer.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/Prakt3/Prakt3/Resource.h b/Master/CGuCAD/projects/Prakt3/Prakt3/Resource.h new file mode 100644 index 0000000..aa09e8b --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Prakt3.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/Prakt3/Prakt3/StdAfx.cpp b/Master/CGuCAD/projects/Prakt3/Prakt3/StdAfx.cpp new file mode 100644 index 0000000..afd4d88 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/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/Prakt3/Prakt3/StdAfx.h b/Master/CGuCAD/projects/Prakt3/Prakt3/StdAfx.h new file mode 100644 index 0000000..55926f2 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/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/Prakt3/Prakt3/acrxEntryPoint.cpp b/Master/CGuCAD/projects/Prakt3/Prakt3/acrxEntryPoint.cpp new file mode 100644 index 0000000..b67bb89 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt3/Prakt3/acrxEntryPoint.cpp @@ -0,0 +1,439 @@ +// (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 +#include + +//----------------------------------------------------------------------------- +#define szRDS _RXST("CGCAD_sei") + +int select2Lines(AcDbLine*&,AcDbLine*&,ads_point&,ads_point&); +int calcNormVertex(const AcDbLine*,AcGeVector3d&); +int calcNormVertex(const AcGePoint3d&,const AcGePoint3d&,AcGeVector3d&); +int calcDirVertex(const AcDbLine*,AcGeVector3d&); +int calcDirVertex(const AcGePoint3d&,const AcGePoint3d&,AcGeVector3d&); +int calcIntersectionPoint(const AcDbLine*,const AcDbLine*, AcGePoint3d&); +int calcCrossProduct(const AcGeVector3d&,const AcGeVector3d&,AcGeVector3d&); +int addObject(AcDbEntity*&); +int calcDistance(const AcDbLine*,const AcGePoint3d&,double&); +double vertexLength(const AcGeVector3d&); +void checkParallelity(const AcGeVector3d&,const AcGeVector3d&); +int changeStartEndPoint(AcDbLine*); +int markStartEndPoint(AcDbLine*); +int checkLineOrientation(AcDbLine*, const AcGePoint3d&); +int setLineStartEndPoint(AcDbLine*,const AcGePoint3d&,const AcGePoint3d&); +int sign (double ); + +// global variables +AcDbLine* pLine1 = NULL; +AcDbLine* pLine2 = NULL; +AcGePoint3d intersectionPoint; +static const double pi = 3.141592653589793238462643383279502884197; // Archimedes constant pi +bool linesParallel = false; + +//----------------------------------------------------------------------------- +//----- ObjectARX EntryPoint +class CPrakt3App : public AcRxArxApp { + +public: + CPrakt3App () : 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_seiPrakt3._roundLines command (do not rename) + static void CGCAD_seiPrakt3_roundLines(void) + { + ads_real radius; + int res = RTNORM; + res = acedGetReal(_T("\nPlease enter radius for rounding: "),&radius); + acdbTransactionManager->startTransaction(); + CGCAD_seiPrakt3_cutLines(); + if(linesParallel) { + acutPrintf(_T("\nLines are parallel, aborting roundLines.")); + acdbTransactionManager->abortTransaction(); + return; + } + if (pLine1 == NULL || pLine2 == NULL) { + acutPrintf(_T("\nError getting lines")); + acdbTransactionManager->abortTransaction(); + return; + } + AcGeVector3d dirVertex1; + AcGeVector3d dirVertex2; + calcDirVertex(pLine1,dirVertex1); + calcDirVertex(pLine2,dirVertex2); + + double dirVertScalarProd = dirVertex1.dotProduct(dirVertex2); + double alpha = std::acos( dirVertScalarProd / ( vertexLength(dirVertex1) * vertexLength(dirVertex2) ) ); + //acutPrintf(_T("\nAngle between lines: %0.4f"),alpha); + double beta = pi-pi/2-alpha/2; + //acutPrintf(_T("\nBeta: %0.4f"),beta); + //acutPrintf(_T("\nSum: %0.4f"),pi/2+alpha/2+beta); + //double b = radius / std::sin(alpha/2); + double a = (radius * std::sin(beta)) / std::sin(alpha/2); + acutPrintf(_T("\nLength a: %0.4f"),a); + //acutPrintf(_T("\nLength b: %0.4f"),b); + ads_point T1; + ads_point T2; + T1[0] = intersectionPoint.x + a * (dirVertex1.x / dirVertex1.length()); + T1[1] = intersectionPoint.y + a * (dirVertex1.y / dirVertex1.length()); + T1[2] = 1; + T2[0] = intersectionPoint.x + a * (dirVertex2.x / dirVertex2.length()); + T2[1] = intersectionPoint.y + a * (dirVertex2.y / dirVertex2.length()); + T2[2] = 1; + AcGePoint3d newStartPoint1(T1[0],T1[1],T1[2]); + AcGePoint3d newStartPoint2(T2[0],T2[1],T2[2]); + + if ( (newStartPoint1.distanceTo(pLine1->endPoint()) < a) || (newStartPoint2.distanceTo(pLine2->endPoint()) < a) ) { + acutPrintf(_T("\nRadius to big!")); + acdbTransactionManager->abortTransaction(); + return; + } + pLine1->setStartPoint(newStartPoint1); + pLine2->setStartPoint(newStartPoint2); + markStartEndPoint(pLine1); + markStartEndPoint(pLine2); + //acutPrintf(_T("\nT1: %0.4f,%0.4f,%0.4f"),T1[0],T1[1],T1[2]); + //acutPrintf(_T("\nT2: %0.4f,%0.4f,%0.4f"),T2[0],T2[1],T2[2]); + + double dist = 0.0; + calcDistance(pLine1,pLine2->startPoint(),dist); + acutPrintf(_T("\nDistance: %f\n"),dist); + struct resbuf *cmd; + if (dist > 0.0) { + cmd=acutBuildList(RTSTR,_T("_arc"),RTPOINT,T2,RTSTR,_T("_e"),RTPOINT,T1,RTSTR,_T("_r"),RTREAL,radius,0); + } else { + cmd=acutBuildList(RTSTR,_T("_arc"),RTPOINT,T1,RTSTR,_T("_e"),RTPOINT,T2,RTSTR,_T("_r"),RTREAL,radius,0); + } + acedCmd(cmd); + acedCommand(RTNONE); + acutRelRb(cmd); + acdbTransactionManager->endTransaction(); + return; + } + + // - CGCAD_seiPrakt3._cutLines command (do not rename) + static void CGCAD_seiPrakt3_cutLines(void) + { + // Add your code for command CGCAD_seiPrakt3._cutLines here + ads_point pickPoint1; + ads_point pickPoint2; + + double dist = 0.0; + int res = RTNORM ; + + acdbTransactionManager->startTransaction(); + res = select2Lines(pLine1,pLine2,pickPoint1,pickPoint2); + //acutPrintf(_T("\nAfter select: %d"),res); + if (RTNORM != res) { + acdbTransactionManager->abortTransaction(); + acutPrintf(_T("\nError selecting 2 Lines: Error %d"),res); + return; + } + AcGePoint3d line1StartPt = pLine1->startPoint(); + AcGePoint3d line1EndPt = pLine1->endPoint(); + acutPrintf(_T("\nLine 1: (%f,%f) (%f,%f)"),line1StartPt.x,line1StartPt.y,line1EndPt.x,line1EndPt.y); + AcGePoint3d line2StartPt = pLine2->startPoint(); + AcGePoint3d line2EndPt = pLine2->endPoint(); + acutPrintf(_T("\nLine 2: (%f,%f) (%f,%f)"),line2StartPt.x,line2StartPt.y,line2EndPt.x,line2EndPt.y); + + AcGeVector3d dirVertex1; + AcGeVector3d dirVertex2; + calcDirVertex(pLine1,dirVertex1); + calcDirVertex(pLine2,dirVertex2); + checkParallelity(dirVertex1,dirVertex2); + + if(linesParallel) { + acutPrintf(_T("\nLines are parallel, aborting cutLines.")); + acdbTransactionManager->abortTransaction(); + return; + } + + pLine1->upgradeOpen(); + pLine2->upgradeOpen(); + + calcIntersectionPoint(pLine1,pLine2,intersectionPoint); + acutPrintf(_T("\nIntersectionpoint: (%f / %f / %f)"),intersectionPoint.x,intersectionPoint.y,intersectionPoint.z); + + AcGePoint3d pPoint1(pickPoint1[0],pickPoint1[1],pickPoint1[2]); + AcGePoint3d pPoint2(pickPoint2[0],pickPoint2[1],pickPoint2[2]); + + setLineStartEndPoint(pLine1,pPoint1,intersectionPoint); + setLineStartEndPoint(pLine2,pPoint2,intersectionPoint); + acdbTransactionManager->endTransaction(); + } +} ; + +int addObject(AcDbEntity*& pEnt) { + AcDbBlockTable* pBlockTable = NULL; + AcDbObjectId newObjId = AcDbObjectId::kNull; + AcDbBlockTableRecord* pBlockTableRecord = NULL; + 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; + } + if( Acad::eOk != pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead) ) { + acdbTransactionManager->abortTransaction(); + pBlockTableRecord->close(); + acutPrintf(_T("\nError opening Block Table Record. Exiting")); + return -1; + } + if (Acad::eOk != pBlockTableRecord->upgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + pBlockTableRecord->close(); + acutPrintf(_T("\nError opening Block Table Record for write. Exiting")); + return -1; + } + if ( Acad::eOk != pBlockTableRecord->appendAcDbEntity(newObjId, pEnt)) { + acdbTransactionManager->abortTransaction(); + pBlockTableRecord->close(); + acutPrintf(_T("\nError adding entity to Block Table Record. Exiting")); + return -1; + } + if (Acad::eOk != pBlockTableRecord->downgradeOpen() ) { + acdbTransactionManager->abortTransaction(); + pBlockTableRecord->close(); + acutPrintf(_T("\nError downgrading Block Table Record for read. Exiting")); + return -1; + } + + if ( Acad::eOk != acdbTransactionManager->addNewlyCreatedDBRObject(pEnt) ) { + acdbTransactionManager->abortTransaction(); + pBlockTableRecord->close(); + acutPrintf(_T("\nError adding new entity to TransactionManager. Exiting")); + return -1; + } + pBlockTableRecord->close(); + return 0; +} + +int calcNormVertex(const AcDbLine* pLine,AcGeVector3d& normVertex) { + return calcNormVertex(pLine->startPoint(),pLine->endPoint(),normVertex); +} +int calcNormVertex(const AcGePoint3d& p1,const AcGePoint3d& p2,AcGeVector3d& normVertex) { + AcGeVector3d vertex1; + vertex1.x = p1.x; + vertex1.y = p1.y; + vertex1.z = 1; + AcGeVector3d vertex2; + vertex2.x = p2.x; + vertex2.y = p2.y; + vertex2.z = 1; + return calcCrossProduct(vertex1,vertex2,normVertex); +} + +int calcDirVertex(const AcDbLine* pLine,AcGeVector3d& dirVertex) { + calcDirVertex(pLine->startPoint(),pLine->endPoint(),dirVertex); + return 0; +} + +int calcIntersectionPoint(const AcDbLine* pLine1, const AcDbLine* pLine2, AcGePoint3d& intersectionPoint) { + AcGeVector3d normVertex1; + AcGeVector3d normVertex2; + AcGeVector3d resVertex; + calcNormVertex(pLine1,normVertex1); + calcNormVertex(pLine2,normVertex2); + calcCrossProduct(normVertex1,normVertex2,resVertex); + intersectionPoint.x = resVertex.x / resVertex.z; + intersectionPoint.y = resVertex.y / resVertex.z; + intersectionPoint.z = 1; + return 0; +} +int calcCrossProduct(const AcGeVector3d& pVertex1, const AcGeVector3d& pVertex2, AcGeVector3d& crossProduct) { + crossProduct = pVertex1.crossProduct(pVertex2); + return 0; +} +int calcDistance(const AcDbLine* pLine,const AcGePoint3d& p,double& dist) { + AcGeVector3d normVertex; + calcNormVertex(pLine,normVertex); + dist = normVertex.x * p.x + normVertex.y * p.y + normVertex.z * p.z; + return 0; +} +double vertexLength(const AcGeVector3d& v) { + return std::sqrt((v.x*v.x)+(v.y*v.y)); +} +int changeStartEndPoint(AcDbLine* pLine) { + AcGePoint3d tmp; + tmp = pLine->startPoint(); + pLine->setStartPoint(pLine->endPoint()); + pLine->setEndPoint(tmp); + return 0; +} +int markStartEndPoint(AcDbLine* pLine) { + AcGeVector3d z(0,0,1); + AcCmColor col; + AcDbCircle* pCirlce = new AcDbCircle(pLine->startPoint(),z,10); + col.setRGB(0,255,0); + pCirlce->setColor(col); + addObject((AcDbEntity*&) pCirlce); + pCirlce = new AcDbCircle(pLine->endPoint(),z,10); + col.setRGB(255,0,0); + pCirlce->setColor(col); + addObject((AcDbEntity*&) pCirlce); + return 0; +} + +int setLineStartEndPoint(AcDbLine* pLine,const AcGePoint3d& pickPoint,const AcGePoint3d& intersectionPoint) { + // make sure startpoint and endpoint have right orientation + // start point is nearest to intersection point + checkLineOrientation(pLine,intersectionPoint); + + AcGePoint3d startPoint = pLine->startPoint(); + AcGePoint3d endPoint = pLine->endPoint(); + AcGePoint3d tmp; + AcGeVector3d normSI; + calcNormVertex(startPoint,intersectionPoint,normSI); + AcGeVector3d normIE; + calcNormVertex(intersectionPoint,endPoint,normIE); + + // intersection point is between startpoint and endpoint + if ( (sign(normSI.x) == sign(normIE.x)) && (sign(normSI.y) == sign(normIE.y)) ) { + //acutPrintf(_T("\nintersection point is between startpoint and endpoint")); + + // evaluate pickpoint + AcGeVector3d normSP; + AcGeVector3d normPI; + calcNormVertex(startPoint,pickPoint,normSP); + calcNormVertex(pickPoint,intersectionPoint,normPI); + if((sign(normSP.x) == sign(normPI.x)) && (sign(normSP.y) == sign(normPI.y))) { + // acutPrintf(_T("\npickpoint is between startpoint and intersectionpoint")); + pLine->setStartPoint(intersectionPoint); + pLine->setEndPoint(startPoint); + } else { + // acutPrintf(_T("\npickpoint is not between startpoint and intersectionpoint")); + pLine->setStartPoint(intersectionPoint); + } + } + // intersection point is not between startpoint and endpoint + else { + // acutPrintf(_T("\nintersection point is not between startpoint and endpoint")); + pLine->setStartPoint(intersectionPoint); + } + return 0; +} +int checkLineOrientation(AcDbLine* pLine, const AcGePoint3d& intersectionPoint) { + if (pLine->endPoint().distanceTo(intersectionPoint) < pLine->startPoint().distanceTo(intersectionPoint) ) { + changeStartEndPoint(pLine); + } + return 0; +} + +void checkParallelity(const AcGeVector3d& vertex1,const AcGeVector3d& vertex2) { + double par = std::abs(vertex1.x*vertex2.y - vertex1.y*vertex2.x); + linesParallel = (par <= std::numeric_limits::epsilon()); +} + +int calcDirVertex(const AcGePoint3d& p,const AcGePoint3d& q,AcGeVector3d& dir) { + dir.x = q.x - p.x; + dir.y = q.y - p.y; + dir.z = 0; + return 0; +} +int sign (double n) +{ + if (n >= std::numeric_limits::epsilon() ) return 1; + return -1; +} +int select2Lines(AcDbLine *&pLine1,AcDbLine *&pLine2,ads_point& pickPoint1,ads_point& pickPoint2) { + ads_name objName; + AcDbEntity* pEnt = NULL; + AcDbObjectId objId = AcDbObjectId::kNull; + int res = RTNORM; + res = acedEntSel(_T("\nPlease select first line"),objName,pickPoint1); + if (res != RTNORM) { + acutPrintf(_T("\nError selecting entity 1")); + return res; + } + if (Acad::eOk != acdbGetObjectId(objId,objName)) { + acutPrintf(_T("\nCould not fetch objid for first line")); + res = -1; + return res; + } + if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,objId,AcDb::kForRead) != Acad::eOk) { + acutPrintf(_T("\nCould not get Object 1")); + res = -1; + return res; + } + if ( pEnt->isKindOf(AcDbLine::desc()) ) { + acutPrintf(_T("\nObject 1 is a Line")); + pLine1 = AcDbLine::cast(pEnt); + } + + res = acedEntSel(_T("\nPlease select second line"),objName,pickPoint2); + if (res != RTNORM) { + acutPrintf(_T("\nError selecting entity 2")); + return res; + } + if (Acad::eOk != acdbGetObjectId(objId,objName)) { + acutPrintf(_T("\nCould not fet objid for second line")); + res = -1; + return res; + } + if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,objId,AcDb::kForRead) != Acad::eOk) { + acutPrintf(_T("\nCould not get Object 2")); + res = -1; + return res; + } + if ( pEnt->isKindOf(AcDbLine::desc()) ) { + acutPrintf(_T("\nObject 2 is a Line")); + pLine2 = AcDbLine::cast(pEnt); + return res; + } + return res; +} + + +//----------------------------------------------------------------------------- +IMPLEMENT_ARX_ENTRYPOINT(CPrakt3App) + +ACED_ARXCOMMAND_ENTRY_AUTO(CPrakt3App, CGCAD_seiPrakt3, _roundLines, roundLines, ACRX_CMD_MODAL, NULL) +ACED_ARXCOMMAND_ENTRY_AUTO(CPrakt3App, CGCAD_seiPrakt3, _cutLines, cutLines, ACRX_CMD_MODAL, NULL) -- cgit v1.2.3