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 --- .../projects/GreedySpeiche/GreedySpeiche.sln | 20 ++ .../projects/GreedySpeiche/GreedySpeiche.suo | Bin 0 -> 23040 bytes .../GreedySpeiche/GreedySpeiche/DocData.cpp | 43 +++ .../projects/GreedySpeiche/GreedySpeiche/DocData.h | 40 +++ .../projects/GreedySpeiche/GreedySpeiche/Edge.cpp | 112 +++++++ .../projects/GreedySpeiche/GreedySpeiche/Edge.h | 34 ++ .../GreedySpeiche/GreedySpeiche/GreedySpeiche.cpp | 41 +++ .../GreedySpeiche/GreedySpeiche/GreedySpeiche.rc | 101 ++++++ .../GreedySpeiche/GreedySpeiche.vcproj | 289 +++++++++++++++++ .../GreedySpeiche.vcproj.SYNERVA.eisenhauer.user | 65 ++++ .../GreedySpeiche/GreedySpeiche/Resource.h | 16 + .../GreedySpeiche/GreedySpeiche/SpeichenStern.cpp | 132 ++++++++ .../GreedySpeiche/GreedySpeiche/SpeichenStern.h | 19 ++ .../GreedySpeiche/GreedySpeiche/StdAfx.cpp | 27 ++ .../projects/GreedySpeiche/GreedySpeiche/StdAfx.h | 58 ++++ .../GreedySpeiche/GreedySpeiche/acrxEntryPoint.cpp | 347 +++++++++++++++++++++ 16 files changed, 1344 insertions(+) create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.sln create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.suo create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/DocData.cpp create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/DocData.h create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.cpp create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.h create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.cpp create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.rc create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj.SYNERVA.eisenhauer.user create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Resource.h create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.cpp create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.h create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/StdAfx.cpp create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/StdAfx.h create mode 100644 Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/acrxEntryPoint.cpp (limited to 'Master/CGuCAD/projects/GreedySpeiche') diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.sln b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.sln new file mode 100644 index 0000000..d40d8a9 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GreedySpeiche", "GreedySpeiche\GreedySpeiche.vcproj", "{58D48F70-F4A5-442E-A235-78990E779EED}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {58D48F70-F4A5-442E-A235-78990E779EED}.Debug|Win32.ActiveCfg = Debug|Win32 + {58D48F70-F4A5-442E-A235-78990E779EED}.Debug|Win32.Build.0 = Debug|Win32 + {58D48F70-F4A5-442E-A235-78990E779EED}.Release|Win32.ActiveCfg = Release|Win32 + {58D48F70-F4A5-442E-A235-78990E779EED}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.suo b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.suo new file mode 100644 index 0000000..a38be2f Binary files /dev/null and b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche.suo differ diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/DocData.cpp b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/DocData.cpp new file mode 100644 index 0000000..aaeeaf7 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/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/GreedySpeiche/GreedySpeiche/DocData.h b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/DocData.h new file mode 100644 index 0000000..456f3f7 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/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/GreedySpeiche/GreedySpeiche/Edge.cpp b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.cpp new file mode 100644 index 0000000..c5f0b26 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.cpp @@ -0,0 +1,112 @@ +#include "StdAfx.h" +#include "Edge.h" + +Edge::Edge(void) +{ +} + +Edge::Edge(unsigned edgeIdx,AcGePoint3d& startPt,unsigned startPtIdx,AcGePoint3d& endPt,unsigned endPtIdx,EdgeType t) +{ + edgeIndex = edgeIdx; + startNode = AcGePoint3d(startPt); + startNodeIndex = startPtIdx; + endNode = AcGePoint3d(endPt); + endNodeIndex = endPtIdx; + type = t; +} + +Edge::Edge(EdgeType et) +{ + type = et; +} + + +Edge::~Edge(void) +{ +} + +double Edge::getLeavingAngleToXAxis(void) +{ + double angle = atan2(endNode.y - startNode.y , endNode.x - startNode.x); + if(angle < 0.0) { + angle += 2*pi; + } + return angle; +} + +double Edge::getArrivingAngleToXAxis(void) +{ + double angle = atan2(startNode.y - endNode.y , startNode.x - endNode.x); + if(angle < 0.0) { + angle += 2*pi; + } + return angle; +} + +double Edge::getLength(void) +{ + double x = endNode.x - startNode.x; + double y = endNode.y - startNode.y; + return sqrt((x*x)+(y*y)); +} + +bool Edge::intersects(Edge* e) +{ + if(startNodeIndex == e->startNodeIndex || startNodeIndex == e->endNodeIndex + || endNodeIndex == e->startNodeIndex || endNodeIndex == e->endNodeIndex ) { + return false; + } + AcGeVector3d sVec1(startNode.x,startNode.y,0); + AcGeVector3d eVec1(endNode.x,endNode.y,0); + AcGeVector3d sVec2(e->startNode.x,e->startNode.y,0); + AcGeVector3d eVec2(e->endNode.x,e->endNode.y,0); + AcGeVector3d n1 = sVec1.crossProduct(eVec1); + AcGeVector3d n2 = sVec2.crossProduct(eVec2); + AcGeVector3d intersectionPoint = n1.crossProduct(n2); + intersectionPoint.x = intersectionPoint.x / intersectionPoint.z; + intersectionPoint.y = intersectionPoint.y / intersectionPoint.z; + intersectionPoint.z = 1; + if(intersectionPoint.isEqualTo(sVec1) || intersectionPoint.isEqualTo(eVec1) + || intersectionPoint.isEqualTo(sVec2) || intersectionPoint.isEqualTo(eVec2) ) { + return false; + } + //acutPrintf(_T("\nIntersectionpoint: (%f / %f / %f)"),intersectionPoint.x,intersectionPoint.y,intersectionPoint.z); + AcGeVector3d v1(intersectionPoint.x - startNode.x , intersectionPoint.y - startNode.y,0); + AcGeVector3d v2(endNode.x - intersectionPoint.x , endNode.y - intersectionPoint.y,0); + AcGeVector3d v3(intersectionPoint.x - e->startNode.x , intersectionPoint.y - e->startNode.y,0); + AcGeVector3d v4(e->endNode.x - intersectionPoint.x , e->endNode.y - intersectionPoint.y,0); + if(v1.isEqualTo(v2) || v3.isEqualTo(v4) ) { + return false; + } + if( (sign(v1.x) == sign(v2.x)) && (sign(v1.y) == sign(v2.y)) && (sign(v3.x) == sign(v4.x)) && (sign(v3.y) == sign(v4.y) ) ) { + return true; + } else { + acutPrintf(_T("\n------------------------")); + acutPrintf(_T("\nA: [%d;%d] ,B:[%d;%d]"),startNodeIndex,endNodeIndex,e->startNodeIndex,e->endNodeIndex); + acutPrintf(_T("\nV1: (%f / %f / %f)"),v1.x,v1.y,v1.z); + acutPrintf(_T("\nV2: (%f / %f / %f)"),v2.x,v2.y,v2.z); + acutPrintf(_T("\nV3: (%f / %f / %f)"),v3.x,v3.y,v3.z); + acutPrintf(_T("\nV4: (%f / %f / %f)"),v4.x,v4.y,v4.z); + return false; + } +} + +bool Edge::arePointsOnSameSide(AcGePoint3d& p,AcGePoint3d& q) +{ + bool res; + AcGeVector3d N = startNode.asVector().crossProduct(endNode.asVector()); + double pPos = N.dotProduct(p.asVector()); + double qPos = N.dotProduct(q.asVector()); + res = sign(pPos) == sign(qPos); + return res; +} + +bool edgeComp(Edge* a, Edge* b) { + return a->getLength() < b->getLength(); +} + +static int sign (double n) +{ + if (n >= std::numeric_limits::epsilon() ) return 1; + return -1; +} \ No newline at end of file diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.h b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.h new file mode 100644 index 0000000..56025cf --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Edge.h @@ -0,0 +1,34 @@ +#pragma once +#include +#include +static const double pi = 3.141592653589793238462643383279502884197; // Archimedes constant pi + +enum EdgeType { + CONTOUR, INNER, TK//, EMPTY +}; + +class Edge +{ +public: + unsigned edgeIndex; + AcGePoint3d startNode; + unsigned startNodeIndex; + AcGePoint3d endNode; + unsigned endNodeIndex; + EdgeType type; + + Edge(void); + Edge(unsigned,AcGePoint3d&,unsigned,AcGePoint3d&,unsigned,EdgeType); + Edge(EdgeType); + + ~Edge(void); + + double getLeavingAngleToXAxis(void); + double getArrivingAngleToXAxis(void); + double getLength(void); + bool intersects(Edge*); + bool arePointsOnSameSide(AcGePoint3d&,AcGePoint3d&); +}; + +bool edgeComp(Edge* a, Edge* b); +int sign(double); \ No newline at end of file diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.cpp b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.cpp new file mode 100644 index 0000000..66a42ec --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.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. +// + +//----------------------------------------------------------------------------- +//- GreedySpeiche.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/GreedySpeiche/GreedySpeiche/GreedySpeiche.rc b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.rc new file mode 100644 index 0000000..c8ef56e --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.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", "GreedySpeiche ObjectARX application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "GreedySpeiche\0" + VALUE "LegalCopyright", "Copyright © 2002\0" + VALUE "OriginalFilename", "CGCAD_seiGreedySpeiche.arx\0" + VALUE "ProductName", "GreedySpeiche 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 "GreedySpeiche" +END + + + +///////////////////////////////////////////////////////////////////////////// + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj new file mode 100644 index 0000000..366aaad --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj.SYNERVA.eisenhauer.user b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj.SYNERVA.eisenhauer.user new file mode 100644 index 0000000..e82dc15 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/GreedySpeiche.vcproj.SYNERVA.eisenhauer.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Resource.h b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Resource.h new file mode 100644 index 0000000..dd09807 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by GreedySpeiche.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/GreedySpeiche/GreedySpeiche/SpeichenStern.cpp b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.cpp new file mode 100644 index 0000000..4a9e443 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.cpp @@ -0,0 +1,132 @@ +#include "StdAfx.h" +#include "SpeichenStern.h" + +SpeichenStern::SpeichenStern(void) +{ +} + +SpeichenStern::~SpeichenStern(void) +{ +} + + +bool SpeichenStern::blockContourEdge(AcGePoint3d& node, Edge* e) +{ + bool res = true; + double startBlockAngle = atan2(e->startNode.y - node.y , e->startNode.x - node.x); + if(startBlockAngle < 0.0) { + startBlockAngle += 2*pi; + } + double endBlockAngle = atan2(e->endNode.y - node.y , e->endNode.x - node.x); + if(endBlockAngle < 0.0) { + endBlockAngle += 2*pi; + } + acutPrintf(_T("\nStart block angle: %f, end block angle: %f"),startBlockAngle*180/pi,endBlockAngle*180/pi); + SpeichenStern* pStart = getSpeichenSternForAngle(startBlockAngle); + acutPrintf(_T("\npStart: %f, typ: %d"),pStart->startAngle*180/pi,pStart->blockingEdge->type); + SpeichenStern* pEnd = getSpeichenSternForAngle(endBlockAngle); + acutPrintf(_T("\npEnd: %f, typ: %d"),pEnd->startAngle*180/pi,pEnd->blockingEdge->type); + if(pEnd = pStart->pNext) { + if(startBlockAngle > endBlockAngle) { + acutPrintf(_T("\nFall A")); + SpeichenStern* s = new SpeichenStern(); + s->startAngle = endBlockAngle; + s->blockingEdge = new Edge(TK); + pStart->blockingEdge = e; + SpeichenStern* s2 = new SpeichenStern(); + s2->blockingEdge = e; + s2->startAngle = startBlockAngle; + s->pNext = s2; + s2->pNext = pEnd; + pStart->pNext=s; + } else { + acutPrintf(_T("\nFall B")); + SpeichenStern* s= new SpeichenStern(); + s->startAngle = startBlockAngle; + s->blockingEdge = e; + if(pEnd->startAngle != endBlockAngle) { + acutPrintf(_T("\nFall B1")); + if(pEnd->blockingEdge->type == TK) { + acutPrintf(_T("\nFall B1A")); + SpeichenStern* s2= new SpeichenStern(); + s2->startAngle = endBlockAngle; + s2->blockingEdge = new Edge(TK); + s->pNext=s2; + s2->pNext=pEnd; + pStart->pNext=s; + } else { + acutPrintf(_T("\nFall B1B")); + s->pNext=pEnd; + pStart->pNext=s; + } + } else { + acutPrintf(_T("\nFall B2")); + s->pNext=pEnd; + pStart->pNext=s; + } + + } + }else { + acutPrintf(_T("\nAngle included by Edge [%d,%d] from %f to %f is blocked by multiple SpeichenSterne"),e->startNodeIndex,e->endNodeIndex,startBlockAngle*180/pi,endBlockAngle*180/pi); + } + dump(); + return res; +} + +SpeichenStern* SpeichenStern::getSpeichenSternForAngle(double angle) +{ + SpeichenStern* res = this; + if(this != this->pNext ) { + SpeichenStern* pStart = this; + SpeichenStern* pEnd = pStart->pNext; + while(pEnd != this) { + if(angle > pStart->startAngle && angle < pEnd->startAngle) { + res = pStart; + break; + } else { + pStart = pEnd; + pEnd = pEnd->pNext; + } + } + } + return res; +} + +bool SpeichenStern::isAngleValid(Edge* e) +{ + bool res = false; + double edgeAngle = e->getLeavingAngleToXAxis(); + SpeichenStern* s = getSpeichenSternForAngle(edgeAngle); + switch(s->blockingEdge->type) { +// case EMPTY: return true; + case TK: return false; + case INNER: // fall through + case CONTOUR: { + if(s->blockingEdge->intersects(e) ) { + return false; + } else { + return true; + } + } + default: break; + } + return res; +} + +void SpeichenStern::dump() +{ + SpeichenStern* pNextDump = this->pNext; + if( (blockingEdge->type == INNER) || (blockingEdge->type == CONTOUR) ) { + acutPrintf(_T("\nSpeichenStern startangle: %f, blockingEdgeType: %d [%d,%d]"),(startAngle*180.0)/pi,blockingEdge->type,blockingEdge->startNodeIndex,blockingEdge->endNodeIndex); + } else { + acutPrintf(_T("\nSpeichenStern startangle: %f, blockingEdgeType: %d"),(startAngle*180.0)/pi,blockingEdge->type); + } + while(pNextDump != this) { + if( (pNextDump->blockingEdge->type == INNER) || (pNextDump->blockingEdge->type == CONTOUR) ) { + acutPrintf(_T("\nSpeichenStern startangle: %f, blockingEdgeType: %d [%d,%d]"),(pNextDump->startAngle*180.0)/pi,pNextDump->blockingEdge->type,pNextDump->blockingEdge->startNodeIndex,pNextDump->blockingEdge->endNodeIndex); + } else { + acutPrintf(_T("\nSpeichenStern startangle: %f, blockingEdgeType: %d"),(pNextDump->startAngle*180.0)/pi,pNextDump->blockingEdge->type); + } + pNextDump = pNextDump->pNext; + } +} \ No newline at end of file diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.h b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.h new file mode 100644 index 0000000..642e927 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/SpeichenStern.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Edge.h" + +class SpeichenStern +{ +public: + double startAngle; + SpeichenStern* pNext; + Edge* blockingEdge; + + SpeichenStern(void); + ~SpeichenStern(void); + + bool blockContourEdge(AcGePoint3d&,Edge*); + bool isAngleValid(Edge*); + void dump(); + SpeichenStern* getSpeichenSternForAngle(double); +}; diff --git a/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/StdAfx.cpp b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/StdAfx.cpp new file mode 100644 index 0000000..afd4d88 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/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/GreedySpeiche/GreedySpeiche/StdAfx.h b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/StdAfx.h new file mode 100644 index 0000000..55926f2 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/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/GreedySpeiche/GreedySpeiche/acrxEntryPoint.cpp b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/acrxEntryPoint.cpp new file mode 100644 index 0000000..b2d01b4 --- /dev/null +++ b/Master/CGuCAD/projects/GreedySpeiche/GreedySpeiche/acrxEntryPoint.cpp @@ -0,0 +1,347 @@ +// (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 "SpeichenStern.h" + +// Definitions +#define TRIANG_LAYER _T("TRIANG") + +// Global variables +Edge* tk = new Edge(TK); +//Edge* empty = new Edge(EMPTY); + +//----------------------------------------------------------------------------- +#define szRDS _RXST("CGCAD_sei") + +//----------------------------------------------------------------------------- +//----- ObjectARX EntryPoint +class CGreedySpeicheApp : public AcRxArxApp { + +public: + CGreedySpeicheApp () : 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_seiGreedySpeiche._GreedySpeiche command (do not rename) + static void CGCAD_seiGreedySpeiche_GreedySpeiche(void) + { + AcDbPolyline* pPolyline = NULL; + + acdbTransactionManager->startTransaction(); + int res = selectPolyline(pPolyline); + if(res != RTNORM) { + acutPrintf(_T("\nError selecting polyline")); + acdbTransactionManager->abortTransaction(); + return; + } else { + acutPrintf(_T("\nPolyline has %d Vertices"),pPolyline->numVerts()); + } + res = createTriangLayer(); + if(res != RTNORM) { + acutPrintf(_T("\nError creating TRIANG layer")); + acdbTransactionManager->abortTransaction(); + return; + } + res = GreedySpeiche(pPolyline); + if(res != RTNORM) { + acutPrintf(_T("\nError in GreedySpeiche")); + acdbTransactionManager->abortTransaction(); + return; + } + acdbTransactionManager->endTransaction(); + } + + static int GreedySpeiche(AcDbPolyline*& pPolyline) + { + std::vector speichenSterne; + std::vector kanten; + std::list kantenPool; + + int res = initSpeichenSterne(pPolyline,speichenSterne,kanten); + if(res != RTNORM) { + acutPrintf(_T("\nError in initSpeichenSterne")); + return res; + } + //for(unsigned i=0;idump(); + //} + + res = generiereKantenPool(pPolyline,kantenPool); + acutPrintf(_T("\n--------------KantenPool--------------------")); + for(std::list::iterator i = kantenPool.begin(); i != kantenPool.end(); i++) { + Edge* e = *i; + acutPrintf(_T("\nKante: %d, [%d,%d], Length: %f"),e->edgeIndex,e->startNodeIndex,e->endNodeIndex,e->getLength()); + } + acutPrintf(_T("\n--------------------------------------------")); + + for(std::list::iterator i = kantenPool.begin(); i != kantenPool.end(); i++) { + Edge* e = *i; + bool res = speichenSterne[e->startNodeIndex]->isAngleValid(e); + if(res) + { + acutPrintf(_T("\nKante: %d, [%d,%d] gültig"),e->edgeIndex,e->startNodeIndex,e->endNodeIndex,e->getLength()); + for(unsigned j=0;jstartNodeIndex) && (j!=e->endNodeIndex) ) { + SpeichenStern* s = speichenSterne[j]; + AcGePoint3d p; + pPolyline->getPointAt(j,p); + acutPrintf(_T("\nFüge Kante [%d,%d] in Speichenstern für Knoten %d ein"),e->startNodeIndex,e->endNodeIndex,j); + //s->insertEdge(p,e); + //acutPrintf(_T("\nSpeichenStern-Nr: %d"),j); + //s->dump(); + } + } + kanten.push_back(e); + } + else + { + acutPrintf(_T("\nKante: %d, [%d,%d] ungültig"),e->edgeIndex,e->startNodeIndex,e->endNodeIndex,e->getLength()); + } + } + + for(unsigned i=0;idump(); + } + for(unsigned i=0;istartNode,kanten[i]->endNode); + pLine->setLayer(TRIANG_LAYER); + addObject((AcDbEntity*&) pLine); + } + return RTNORM; + } + + static int generiereKantenPool(AcDbPolyline*& pPolyline,std::list& kantenPool) { + unsigned N = pPolyline->numVerts(); + unsigned edgeCounter = N; + AcGePoint3d p; + AcGePoint3d q; + for(unsigned i=0; igetPointAt(i,p); + pPolyline->getPointAt(j,q); + Edge* e = new Edge(edgeCounter++,p,i,q,j,INNER); + kantenPool.push_back(e); + } + } + kantenPool.sort(edgeComp); + return RTNORM; + } + + static int initSpeichenSterne(AcDbPolyline*& pPolyline, std::vector & speichenSterne, std::vector kanten) { + AcGePoint3d p; + AcGePoint3d q; + Edge* e = NULL; + SpeichenStern* s = NULL; + for(unsigned i=0;inumVerts()-1;i++) { + pPolyline->getPointAt(i,p); + pPolyline->getPointAt(i+1,q); + e = new Edge(i,p,i,q,i+1,CONTOUR); + kanten.push_back(e); + + s = new SpeichenStern(); + s->startAngle=0.0; + s->blockingEdge=tk; + s->pNext = s; + speichenSterne.push_back(s); + } + + pPolyline->getPointAt(pPolyline->numVerts()-1,p); + pPolyline->getPointAt(0,q); + e = new Edge(pPolyline->numVerts()-1,p,pPolyline->numVerts()-1,q,0,CONTOUR); + kanten.push_back(e); + + s = new SpeichenStern(); + s->startAngle=0.0; + s->blockingEdge=tk; + s->pNext = s; + speichenSterne.push_back(s); + + int res = initContourEdges(pPolyline,speichenSterne,kanten); + + return RTNORM; + } + static int initContourEdges(AcDbPolyline*& pPolyline, std::vector & speichenSterne, std::vector kanten) + { + for(unsigned i=0;igetPointAt(i,p); + for(unsigned j=0;jstartNodeIndex && i!=e->endNodeIndex) { + acutPrintf(_T("\nContour [%d,%d], SpeichenStern: %d"),e->startNodeIndex ,e->endNodeIndex,i); + s->blockContourEdge(p,e); + } + } + } + + return RTNORM; + } + + static 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; + } + static int selectPolyline(AcDbPolyline *&pPolyline) { + ads_name objName; + AcDbEntity* pEnt = NULL; + AcDbObjectId objId = AcDbObjectId::kNull; + int res = RTNORM; + ads_point pickPoint; + res = acedEntSel(_T("\nPlease select polyline"),objName,pickPoint); + + if (res != RTNORM) { + acutPrintf(_T("\nError selecting entity")); + return res; + } + if (Acad::eOk != acdbGetObjectId(objId,objName)) { + acutPrintf(_T("\nCould not fetch objid for face")); + res = -1; + return res; + } + if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,objId,AcDb::kForRead) != Acad::eOk) { + acutPrintf(_T("\nCould not get Object")); + res = -1; + return res; + } + if ( pEnt->isKindOf(AcDbPolyline::desc()) ) { + acutPrintf(_T("\nObject is a Polyline")); + pPolyline = AcDbPolyline::cast(pEnt); + } + return res; + } + static int createTriangLayer() { + AcDbLayerTable *pLayerTable = NULL; + + acdbTransactionManager->startTransaction(); + Acad::ErrorStatus res = acdbTransactionManager->getObject((AcDbObject*&) pLayerTable,curDoc()->database()->layerTableId(),AcDb::kForRead); + + AcDbLayerTableRecord *pTriangLayerTableRecord = NULL; + + if (!pLayerTable->has(TRIANG_LAYER)) { + acutPrintf(_T("\nCreating TRIANG Layer")); + pLayerTable->upgradeOpen(); + pTriangLayerTableRecord = new AcDbLayerTableRecord; + pTriangLayerTableRecord->setName(TRIANG_LAYER); + AcCmColor polyColor; + polyColor.setRGB(0,0,255); + pTriangLayerTableRecord->setColor(polyColor); + pTriangLayerTableRecord->setIsLocked(false); + pTriangLayerTableRecord->setIsFrozen(false); + pTriangLayerTableRecord->setIsOff(false); + pTriangLayerTableRecord->setIsHidden(false); + if ( Acad::eOk != pLayerTable->add(pTriangLayerTableRecord) ) { + acutPrintf(_T("\nError adding TRIANG Layer")); + acdbTransactionManager->abortTransaction(); + return 2; + } + acdbTransactionManager->addNewlyCreatedDBRObject(pTriangLayerTableRecord); + } else { + acutPrintf(_T("\nTRIANG Layer already exists")); + } + acdbTransactionManager->endTransaction(); + return RTNORM; + } +} ; + +//----------------------------------------------------------------------------- +IMPLEMENT_ARX_ENTRYPOINT(CGreedySpeicheApp) + +ACED_ARXCOMMAND_ENTRY_AUTO(CGreedySpeicheApp, CGCAD_seiGreedySpeiche, _GreedySpeiche, GreedySpeiche, ACRX_CMD_MODAL, NULL) -- cgit v1.2.3