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/Prakt4/Prakt4.sln | 20 ++ Master/CGuCAD/projects/Prakt4/Prakt4.suo | Bin 0 -> 24576 bytes Master/CGuCAD/projects/Prakt4/Prakt4/DocData.cpp | 43 +++ Master/CGuCAD/projects/Prakt4/Prakt4/DocData.h | 40 +++ .../CGuCAD/projects/Prakt4/Prakt4/LinePPForm.cpp | 16 ++ Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.h | 13 + .../projects/Prakt4/Prakt4/PlaneParamForm.cpp | 122 +++++++++ .../CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.h | 31 +++ Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.cpp | 41 +++ Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.rc | 101 +++++++ Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj | 297 +++++++++++++++++++++ .../Prakt4/Prakt4.vcproj.SYNERVA.eisenhauer.user | 65 +++++ Master/CGuCAD/projects/Prakt4/Prakt4/Resource.h | 16 ++ Master/CGuCAD/projects/Prakt4/Prakt4/StdAfx.cpp | 27 ++ Master/CGuCAD/projects/Prakt4/Prakt4/StdAfx.h | 58 ++++ Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.cpp | 121 +++++++++ Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.h | 40 +++ .../projects/Prakt4/Prakt4/acrxEntryPoint.cpp | 263 ++++++++++++++++++ 18 files changed, 1314 insertions(+) create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4.sln create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4.suo create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/DocData.cpp create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/DocData.h create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.cpp create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.h create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.cpp create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.h create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.cpp create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.rc create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj.SYNERVA.eisenhauer.user create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Resource.h create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/StdAfx.cpp create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/StdAfx.h create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.cpp create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.h create mode 100644 Master/CGuCAD/projects/Prakt4/Prakt4/acrxEntryPoint.cpp (limited to 'Master/CGuCAD/projects/Prakt4') diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4.sln b/Master/CGuCAD/projects/Prakt4/Prakt4.sln new file mode 100644 index 0000000..4598e94 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Prakt4", "Prakt4\Prakt4.vcproj", "{23366317-7432-4240-B729-A781F56987C1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {23366317-7432-4240-B729-A781F56987C1}.Debug|Win32.ActiveCfg = Debug|Win32 + {23366317-7432-4240-B729-A781F56987C1}.Debug|Win32.Build.0 = Debug|Win32 + {23366317-7432-4240-B729-A781F56987C1}.Release|Win32.ActiveCfg = Release|Win32 + {23366317-7432-4240-B729-A781F56987C1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4.suo b/Master/CGuCAD/projects/Prakt4/Prakt4.suo new file mode 100644 index 0000000..4e100db Binary files /dev/null and b/Master/CGuCAD/projects/Prakt4/Prakt4.suo differ diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/DocData.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/DocData.cpp new file mode 100644 index 0000000..aaeeaf7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/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/Prakt4/Prakt4/DocData.h b/Master/CGuCAD/projects/Prakt4/Prakt4/DocData.h new file mode 100644 index 0000000..456f3f7 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/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/Prakt4/Prakt4/LinePPForm.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.cpp new file mode 100644 index 0000000..1c17e97 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.cpp @@ -0,0 +1,16 @@ +#include "StdAfx.h" +#include "LinePPForm.h" + +LinePPForm::LinePPForm(void) +{ +} +LinePPForm::LinePPForm(const int idxP, const AcGePoint3d& p,const int idxQ, const AcGePoint3d& q) +{ + P = *(new Vector4D(p)); + iP = idxP; + Q = *(new Vector4D(q)); + iQ= idxQ; +} +LinePPForm::~LinePPForm(void) +{ +} diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.h b/Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.h new file mode 100644 index 0000000..534a439 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/LinePPForm.h @@ -0,0 +1,13 @@ +#pragma once +#include "Vector4D.h" +class LinePPForm +{ +public: + LinePPForm(void); + LinePPForm(const int,const AcGePoint3d&,const int, const AcGePoint3d&); + ~LinePPForm(void); + Vector4D P; + Vector4D Q; + int iP; + int iQ; +}; diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.cpp new file mode 100644 index 0000000..9481d74 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.cpp @@ -0,0 +1,122 @@ +#include "StdAfx.h" +#include "PlaneParamForm.h" + +int sign (double n) +{ + if (n >= std::numeric_limits::epsilon() ) return 1; + return -1; +} + +PlaneParamForm::PlaneParamForm(const AcDbFace * f) +{ + AcGePoint3d p; + f->getVertexAt(0,p); + P = Vector4D(p); + f->getVertexAt(1,p); + R = Vector4D(p)-P; + f->getVertexAt(2,p); + S = Vector4D(p)-P; + N = getNormalVector(); +} + +PlaneParamForm::PlaneParamForm(void) +{ +} + +PlaneParamForm::~PlaneParamForm(void) +{ +} + +Vector4D PlaneParamForm::getNormalVector() +{ + return Vector4D::extCrossProduct(P,R,S); +} +bool PlaneParamForm::arePointsOnSameSide(const AcGeVector3d & p1, const AcGeVector3d & p2) { + return arePointsOnSameSide(Vector4D(p1),Vector4D(p2)); +} + +bool PlaneParamForm::arePointsOnSameSide(const Vector4D & p1, const Vector4D & p2) +{ + long double tmp = (N.dotProduct(p1) * N.dotProduct(p2)); + return tmp > 0; +} +Vector4D PlaneParamForm::getIntersectionPointWithLine(const AcGeVector3d & P, const AcGeVector3d & Q) +{ + return getIntersectionPointWithLine(Vector4D(P),Vector4D(Q)); +} + +Vector4D PlaneParamForm::getIntersectionPointWithLine(const Vector4D &P, const Vector4D &Q) +{ + Vector4D *Rg = new Vector4D(Q); + Vector4D P1(P); + Vector4D Q1(Q); + if ( !Rg->isDirectionVector() ) { + Rg = new Vector4D(Q1-P1); + } + long double rs = - ( (N.dotProduct(P) ) / (N.dotProduct(*Rg)) ); + return (P1 + ((*Rg) * rs)).homogenize(); +} +std::vector PlaneParamForm::getIntersectingLines(const AcDbFace* f) +{ + std::vector res; + AcGePoint3d p0; + AcGePoint3d p1; + AcGePoint3d p2; + AcGePoint3d p3; + f->getVertexAt(0,p0); + f->getVertexAt(1,p1); + f->getVertexAt(2,p2); + f->getVertexAt(3,p3); + if(!arePointsOnSameSide(p0,p1)) { + res.push_back(new LinePPForm(0,p0,1,p1)); + } + if(!arePointsOnSameSide(p1,p2)) { + res.push_back(new LinePPForm(1,p1,2,p2)); + } + if(!arePointsOnSameSide(p2,p3)) { + res.push_back(new LinePPForm(2,p2,3,p3)); + } + if(!arePointsOnSameSide(p3,p0)) { + res.push_back(new LinePPForm(3,p3,0,p0)); + } + /* + acutPrintf(_T("\nFound %d intersection lines"),res.size()); + for(int i=0;i0); +} +Vector4D PlaneParamForm::getIntersectionPointWithLine(const LinePPForm*& line) +{ + return this->getIntersectionPointWithLine(line->P,line->Q); +} +std::vector PlaneParamForm::getPointsAbove(const AcDbFace * pFace) +{ + std::vector res; + AcGePoint3d p; + for(int i=0;i<4;i++) { + pFace->getVertexAt(i,p); + if(isPointAbove(p.asVector())) { + res.push_back(p); + } + } + return res; +} \ No newline at end of file diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.h b/Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.h new file mode 100644 index 0000000..c475f26 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/PlaneParamForm.h @@ -0,0 +1,31 @@ +#pragma once + +#ifndef PLANE_PARAMFORM +#define PLANE_PARAMFORM +#include "Vector4D.h" +#include "LinePPForm.h" +#include +#endif + +class PlaneParamForm +{ +public: + PlaneParamForm(void); + PlaneParamForm(const AcDbFace*); + ~PlaneParamForm(void); + Vector4D P; + Vector4D R; + Vector4D S; + Vector4D N; + Vector4D getNormalVector(); + Vector4D getHNFNormalVector(); + bool arePointsOnSameSide(const AcGeVector3d&, const AcGeVector3d& ); + bool arePointsOnSameSide(const Vector4D&, const Vector4D& ); + Vector4D getIntersectionPointWithLine(const Vector4D&, const Vector4D&); + Vector4D getIntersectionPointWithLine(const AcGeVector3d&, const AcGeVector3d&); + Vector4D getIntersectionPointWithLine(const LinePPForm*&); + std::vector getIntersectingLines(const AcDbFace*); + bool isPointAbove(const Vector4D&); + bool isPointAbove(const AcGeVector3d&); + std::vector getPointsAbove(const AcDbFace*); +}; diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.cpp new file mode 100644 index 0000000..51e0650 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.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. +// + +//----------------------------------------------------------------------------- +//- Prakt4.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/Prakt4/Prakt4/Prakt4.rc b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.rc new file mode 100644 index 0000000..31bc097 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.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", "Prakt4 ObjectARX application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "Prakt4\0" + VALUE "LegalCopyright", "Copyright © 2002\0" + VALUE "OriginalFilename", "CGCAD_seiPrakt4.arx\0" + VALUE "ProductName", "Prakt4 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 "Prakt4" +END + + + +///////////////////////////////////////////////////////////////////////////// + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj new file mode 100644 index 0000000..7f89b5d --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj.SYNERVA.eisenhauer.user b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj.SYNERVA.eisenhauer.user new file mode 100644 index 0000000..e82dc15 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Prakt4.vcproj.SYNERVA.eisenhauer.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/Resource.h b/Master/CGuCAD/projects/Prakt4/Prakt4/Resource.h new file mode 100644 index 0000000..5cf4bef --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Prakt4.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/Prakt4/Prakt4/StdAfx.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/StdAfx.cpp new file mode 100644 index 0000000..afd4d88 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/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/Prakt4/Prakt4/StdAfx.h b/Master/CGuCAD/projects/Prakt4/Prakt4/StdAfx.h new file mode 100644 index 0000000..55926f2 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/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/Prakt4/Prakt4/Vector4D.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.cpp new file mode 100644 index 0000000..9737f44 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.cpp @@ -0,0 +1,121 @@ +#include "StdAfx.h" +#include "Vector4D.h" +#include "cmath" + +Vector4D::Vector4D(void) +{ +} + +Vector4D::~Vector4D(void) +{ +} +Vector4D::Vector4D(const AcGePoint3d& p) +{ + AcGeVector3d v = p.asVector(); + x = v.x; + y = v.y; + z = v.z; + w = 1; +} +Vector4D::Vector4D(const AcGeVector3d& v) +{ + x = v.x; + y = v.y; + z = v.z; + w = 1; +} + + +Vector4D::Vector4D(const Vector4D & v) { + x = v.x; + y = v.y; + z = v.z; + w = v.w; +} +Vector4D::Vector4D(const double& nx,const double& ny,const double& nz,const double& nw) +{ + this->x=nx; + this->y=ny; + this->z=nz; + this->w=nw; +} +Vector4D Vector4D::normalize() +{ + double len = length(); + Vector4D h; + h.x = x/len; + h.y = y/len; + h.z = z/len; + h.w = w/len; + return h; +} +long double Vector4D::length() +{ + return std::sqrt(x*x+y*y+z*z); +} +Vector4D Vector4D::homogenize() +{ + Vector4D h; + h.x = x/w; + h.y = y/w; + h.z = z/w; + h.w = 1; + return h; +} +long double Vector4D::dotProduct(const Vector4D& other) +{ + long double res = ( (x*(other.x)) + (y*(other.y)) + (z*(other.z)) + (w*(other.w)) ); + return res; +} +Vector4D Vector4D::operator -(const Vector4D & other) +{ + Vector4D h; + h.x = x - other.x; + h.y = y - other.y; + h.z = z - other.z; + h.w = w - other.w; + return h; +} + +Vector4D Vector4D::operator +(const Vector4D & other) +{ + Vector4D h; + h.x = x + other.x; + h.y = y + other.y; + h.z = z + other.z; + h.w = w + other.w; + return h; +} + +Vector4D& Vector4D::operator =(const Vector4D & other) +{ + x = other.x; + y = other.y; + z = other.z; + w = other.w; + return *this; +} + +Vector4D Vector4D::operator *(const long double& d) +{ + Vector4D res; + res.x = x * d; + res.y = y * d; + res.z = z * d; + res.w = w * d; + return res; +} + +bool Vector4D::isDirectionVector() +{ + return z == 0; +} + +AcGePoint3d Vector4D::asPoint3d() +{ + AcGePoint3d p; + p.x = x; + p.y = y; + p.z = z; + return p; +} \ No newline at end of file diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.h b/Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.h new file mode 100644 index 0000000..8f7d7ff --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/Vector4D.h @@ -0,0 +1,40 @@ +#pragma once + +#ifndef VECTROR4D +#define VECTOR4D +#endif + +class Vector4D +{ +public: + Vector4D(void); + Vector4D(const Vector4D&); + Vector4D(const AcGeVector3d&); + Vector4D(const AcGePoint3d&); + Vector4D(const double&,const double&,const double&,const double&); + ~Vector4D(void); + long double x; + long double y; + long double z; + long double w; + Vector4D normalize(void); + Vector4D homogenize(void); + long double dotProduct(const Vector4D&); + long double length(void); + Vector4D operator-(const Vector4D&); + Vector4D operator+(const Vector4D&); + Vector4D operator*(const long double &); + Vector4D& operator=(const Vector4D&); + bool isDirectionVector(); + AcGePoint3d asPoint3d(); + + static Vector4D Vector4D::extCrossProduct(const Vector4D & p,const Vector4D & r,const Vector4D & s) + { + Vector4D res; + res.x = (r.y*s.z) - (r.z*s.y); + res.y = -1 * ( (r.x*s.z) - (r.z*s.x) ); + res.z = (r.x*s.y) - (r.y*s.x); + res.w = -1 * ( p.x*( (r.y*s.z)-(r.z*s.y) ) -p.y*( (r.x*s.z)-(r.z*s.x) ) + p.z*( (r.x*s.y)-(r.y*s.x) ) ); + return res; + } +}; diff --git a/Master/CGuCAD/projects/Prakt4/Prakt4/acrxEntryPoint.cpp b/Master/CGuCAD/projects/Prakt4/Prakt4/acrxEntryPoint.cpp new file mode 100644 index 0000000..eb36811 --- /dev/null +++ b/Master/CGuCAD/projects/Prakt4/Prakt4/acrxEntryPoint.cpp @@ -0,0 +1,263 @@ +// (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 "PlaneParamForm.h" + +//----------------------------------------------------------------------------- +#define szRDS _RXST("CGCAD_sei") + +//----------------------------------------------------------------------------- +//----- ObjectARX EntryPoint +class CPrakt4App : public AcRxArxApp { + +public: + CPrakt4App () : 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_seiPrakt4._cutFacettes command (do not rename) + static void CGCAD_seiPrakt4_cutFacettes(void) + { + // Add your code for command CGCAD_seiPrakt4._cutFacettes here + AcDbFace* baseFace = NULL; + AcDbFace* cutFace = NULL; + + acdbTransactionManager->startTransaction(); + int res = selectFace(1,baseFace); + if(res != RTNORM) { + acutPrintf(_T("\nError selecting base face")); + acdbTransactionManager->abortTransaction(); + return; + } + res = selectFace(2,cutFace); + if(res != RTNORM) { + acutPrintf(_T("\nError selecting cut face")); + acdbTransactionManager->abortTransaction(); + return; + } + + PlaneParamForm basePlane(baseFace); + std::vector pointsAbove = basePlane.getPointsAbove(cutFace); + acutPrintf(_T("\n%d Points of cutface above base plane"),pointsAbove.size()); + if( (pointsAbove.size() == 0) || (pointsAbove.size() == 4) ) { + acutPrintf(_T("\n%d Points of cutface above base plane"),pointsAbove.size()); + acutPrintf(_T("\nNothing to do... Exiting")); + acdbTransactionManager->abortTransaction(); + return; + }else if(pointsAbove.size() != 2) { + bring2PointsAboveBasePlane(basePlane,cutFace,pointsAbove); + } + std::vector lines = basePlane.getIntersectingLines(cutFace); + + for(int i=0;iupgradeOpen(); + if(basePlane.isPointAbove(lines[i]->P)) { + /* + AcGePoint3d o; + cutFace->getVertexAt(lines[i]->iQ,o); + acutPrintf(_T("\nReplacing Old[%f/%f/%f] with New[%f/%f/%f/%f]"),o.x,o.y,o.z,iPoint.x,iPoint.y,iPoint.z,iPoint.w); + */ + cutFace->setVertexAt(lines[i]->iQ,iPoint.asPoint3d()); + } else { + /* + AcGePoint3d o; + cutFace->getVertexAt(lines[i]->iP,o); + acutPrintf(_T("\nReplacing Old[%f/%f/%f] with New[%f/%f/%f/%f]"),o.x,o.y,o.z,iPoint.x,iPoint.y,iPoint.z,iPoint.w); + */ + cutFace->setVertexAt(lines[i]->iP,iPoint.asPoint3d()); + } + cutFace->downgradeOpen(); + } + acdbTransactionManager->endTransaction(); + } + + static void bring2PointsAboveBasePlane(PlaneParamForm & plane,AcDbFace * pFace,std::vector& pointsAbove) + { + Adesk::UInt16 idx1; + Adesk::UInt16 idx2; + getIdenticalPoints(pFace,idx1,idx2); + if(pointsAbove.size() == 1) { + setFacePointAt(pFace,idx1,pointsAbove[0]); + } else if ( pointsAbove.size() == 3){ + AcGePoint3d p; + for(Adesk::UInt16 i = 0; i<4;i++) { + pFace->getVertexAt(i,p); + if(! (plane.isPointAbove(p.asVector())) ) { + setFacePointAt(pFace,idx1,p); + break; + } + } + } + + } + + static void getIdenticalPoints(AcDbFace * pFace,Adesk::UInt16& idx1,Adesk::UInt16& idx2) + { + AcGePoint3d p0; + AcGePoint3d p1; + AcGePoint3d p2; + AcGePoint3d p3; + pFace->getVertexAt(0,p0); + pFace->getVertexAt(1,p1); + pFace->getVertexAt(2,p2); + pFace->getVertexAt(3,p3); + if(p0 == p1) { + idx1=0; + idx2=1; + } else if(p0 == p2) { + idx1=0; + idx2=2; + } else if(p0 == p3) { + idx1=0; + idx2=3; + } else if(p1 == p2) { + idx1=1; + idx2=2; + } else if(p1 == p3) { + idx1=1; + idx2=3; + } else if(p2 == p3) { + idx1=2; + idx2=3; + } + } + + static void setFacePointAt(AcDbFace *& pFace, const Adesk::UInt16& idx, const AcGePoint3d& point) + { + pFace->upgradeOpen(); + pFace->setVertexAt(idx,point); + pFace->downgradeOpen(); + } + static int selectFace(int faceNr, AcDbFace *&pFace) { + ads_name objName; + AcDbEntity* pEnt = NULL; + AcDbObjectId objId = AcDbObjectId::kNull; + int res = RTNORM; + ads_point pickPoint; + if(faceNr == 1) { + res = acedEntSel(_T("\nPlease select base face"),objName,pickPoint); + } else if(faceNr==2){ + res = acedEntSel(_T("\nPlease select face to cut"),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(AcDbFace::desc()) ) { + acutPrintf(_T("\nObject is a Face")); + pFace = AcDbFace::cast(pEnt); + } + return res; + } + + 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; + } + +} ; + +//----------------------------------------------------------------------------- +IMPLEMENT_ARX_ENTRYPOINT(CPrakt4App) + +ACED_ARXCOMMAND_ENTRY_AUTO(CPrakt4App, CGCAD_seiPrakt4, _cutFacettes, cutFacettes, ACRX_CMD_MODAL, NULL) -- cgit v1.2.3