EgtGeomKernel 1.3a1 : primo salvatraggio.
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtGeomKernel", "EgtGeomKernel.vcxproj", "{9A98A202-2853-454A-84CA-DCD1714176C9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9A98A202-2853-454A-84CA-DCD1714176C9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9A98A202-2853-454A-84CA-DCD1714176C9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9A98A202-2853-454A-84CA-DCD1714176C9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9A98A202-2853-454A-84CA-DCD1714176C9}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9A98A202-2853-454A-84CA-DCD1714176C9}</ProjectGuid>
|
||||
<RootNamespace>EgtGeomKernel</RootNamespace>
|
||||
<Keyword>MFCDLLProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>$(ProjectName)D$(PlatformArchitecture)</TargetName>
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;I_AM_EGK;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0410</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\
|
||||
copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\
|
||||
copy $(TargetPath) \EgtProg\Dll</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;I_AM_EGK;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0410</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\
|
||||
copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\
|
||||
copy $(TargetPath) \EgtProg\Dll</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EgtGeomKernelDll.cpp" />
|
||||
<ClCompile Include="Frame3d.cpp" />
|
||||
<ClCompile Include="Point3d.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Vector3d.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Include\EGkFrame3d.h" />
|
||||
<ClInclude Include="..\Include\EGkGeoConst.h" />
|
||||
<ClInclude Include="..\Include\EGkPoint3d.h" />
|
||||
<ClInclude Include="..\Include\EGkVector3d.h" />
|
||||
<ClInclude Include="..\Include\EgtTrace.h" />
|
||||
<ClInclude Include="EgtGeomKernelDll.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="File di origine">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="File di intestazione">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="File di risorse">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EgtGeomKernelDll.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Point3d.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Vector3d.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Frame3d.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EgtGeomKernelDll.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgtTrace.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkFrame3d.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkGeoConst.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkPoint3d.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkVector3d.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
<Filter>File di risorse</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EgtGeomKernelDll.cpp Data : 20.11.13 Versione : 1.3a1
|
||||
// Contenuto : Inizializzazione della DLL.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 16.11.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include <windows.h>
|
||||
#include <\EgtDev\Include\EgtTrace.h>
|
||||
|
||||
//--------------------------- Macro -------------------------------------------
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" int APIENTRY
|
||||
DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
|
||||
if ( dwReason == DLL_PROCESS_ATTACH) {
|
||||
EGT_TRACE( "EgtGeomKernel.Dll Initializing!\n") ;
|
||||
}
|
||||
else if ( dwReason == DLL_PROCESS_DETACH) {
|
||||
EGT_TRACE( "EgtGeomKernel.Dll Terminating!\n") ;
|
||||
}
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EgtGeomKernelDll.h Data : 20.11.13 Versione : 1.3a1
|
||||
// Contenuto : Dichiarazione per modulo EgtGeomKernelDll.cpp.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 04.01.12 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//--------------------------- Prototipi ---------------------------------------
|
||||
// DllMain é già dichiarata in header di sistema
|
||||
//HMODULE GetDllModule( void) ;
|
||||
//HINSTANCE GetResourceInstance( void) ;
|
||||
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Frame3d.cpp Data : 20.11.13 Versione : 1.3a1
|
||||
// Contenuto : Funzioni della classe Riferimento 3d.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "\EgtDev\Include\EGkGeoConst.h"
|
||||
#include "\EgtDev\Include\EGkFrame3d.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Frame3d::Frame3d( void)
|
||||
{
|
||||
Reset() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Set( const Point3d& ptOrig, const Vector3d& vtDirX,
|
||||
const Vector3d& vtDirY, const Vector3d& vtDirZ)
|
||||
{
|
||||
double dOrtXY ;
|
||||
double dOrtYZ ;
|
||||
double dOrtZX ;
|
||||
double dRight ;
|
||||
Vector3d vtTmp ;
|
||||
|
||||
|
||||
// lo inizializzo come errato
|
||||
m_nType = ERR ;
|
||||
m_nZType = ERR ;
|
||||
|
||||
// assegnazione dell'origine e delle direzioni
|
||||
m_ptOrig = ptOrig ;
|
||||
m_vtVersX = vtDirX ;
|
||||
m_vtVersY = vtDirY ;
|
||||
m_vtVersZ = vtDirZ ;
|
||||
|
||||
// se le direzioni non sono normalizzabili, errore
|
||||
if ( ! m_vtVersX.Normalize() ||
|
||||
! m_vtVersY.Normalize() ||
|
||||
! m_vtVersZ.Normalize())
|
||||
return false ;
|
||||
|
||||
// verifica della ortogonalità dei versori e del senso destrorso
|
||||
dOrtXY = m_vtVersX * m_vtVersY ;
|
||||
dOrtYZ = m_vtVersY * m_vtVersZ ;
|
||||
dOrtZX = m_vtVersZ * m_vtVersX ;
|
||||
vtTmp = m_vtVersX ^ m_vtVersY ;
|
||||
dRight = vtTmp * m_vtVersZ ;
|
||||
if ( fabs( dOrtXY) > EPS_ZERO ||
|
||||
fabs( dOrtYZ) > EPS_ZERO ||
|
||||
fabs( dOrtZX) > EPS_ZERO ||
|
||||
dRight < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// ne determino il tipo
|
||||
CalculateType() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Set( const Point3d& ptOrig, const Point3d& ptOnX, const Point3d& ptNearY)
|
||||
{
|
||||
Vector3d vtDirX ;
|
||||
Vector3d vtDirY ;
|
||||
Vector3d vtDirZ ;
|
||||
Vector3d vtTemp ;
|
||||
|
||||
|
||||
// calcolo il vettore che rappresenta l'asse X del piano
|
||||
vtDirX = ptOnX - ptOrig ;
|
||||
// calcolo il vettore che rappresenta un asse nel piano
|
||||
vtTemp = ptNearY - ptOrig ;
|
||||
// alcolo il vettore dell'asse Z
|
||||
vtDirZ = vtDirX ^ vtTemp ;
|
||||
// calcolo il vettore dell'asse Y
|
||||
vtDirY = vtDirZ ^ vtDirX ;
|
||||
|
||||
return Set( ptOrig, vtDirX, vtDirY, vtDirZ) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Set( const Point3d& ptOrig, Type nType)
|
||||
{
|
||||
// origine
|
||||
m_ptOrig = ptOrig ;
|
||||
// orientamento
|
||||
switch ( nType) {
|
||||
case TOP :
|
||||
m_nType = m_nZType ;
|
||||
m_vtVersX.Set( 1, 0, 0) ;
|
||||
m_vtVersY.Set( 0, 1, 0) ;
|
||||
m_vtVersZ.Set( 0, 0, 1) ;
|
||||
break ;
|
||||
case BOTTOM :
|
||||
m_nType = BOTTOM ;
|
||||
m_vtVersX.Set( 1, 0, 0) ;
|
||||
m_vtVersY.Set( 0, -1, 0) ;
|
||||
m_vtVersZ.Set( 0, 0, -1) ;
|
||||
break ;
|
||||
case FRONT :
|
||||
m_nType = FRONT ;
|
||||
m_vtVersX.Set( 1, 0, 0) ;
|
||||
m_vtVersY.Set( 0, 0, 1) ;
|
||||
m_vtVersZ.Set( 0, -1, 0) ;
|
||||
break ;
|
||||
case BACK :
|
||||
m_nType = BACK ;
|
||||
m_vtVersX.Set( -1, 0, 0) ;
|
||||
m_vtVersY.Set( 0, 0, 1) ;
|
||||
m_vtVersZ.Set( 0, 1, 0) ;
|
||||
break ;
|
||||
case LEFT :
|
||||
m_nType = LEFT ;
|
||||
m_vtVersX.Set( 0, -1, 0) ;
|
||||
m_vtVersY.Set( 0, 0, 1) ;
|
||||
m_vtVersZ.Set( -1, 0, 0) ;
|
||||
break ;
|
||||
case RIGHT :
|
||||
m_nType = RIGHT ;
|
||||
m_vtVersX.Set( 0, 1, 0) ;
|
||||
m_vtVersY.Set( 0, 0, 1) ;
|
||||
m_vtVersZ.Set( 1, 0, 0) ;
|
||||
break ;
|
||||
default :
|
||||
m_nType = ERR ;
|
||||
break ;
|
||||
}
|
||||
// orientamento di Z coincide con quello generale
|
||||
m_nZType = m_nType ;
|
||||
|
||||
return ( m_nType != ERR) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Reset( void)
|
||||
{
|
||||
m_nType = TOP ;
|
||||
m_nZType = TOP ;
|
||||
m_ptOrig.Set( 0, 0, 0) ;
|
||||
m_vtVersX.Set( 1, 0, 0) ;
|
||||
m_vtVersY.Set( 0, 1, 0) ;
|
||||
m_vtVersZ.Set( 0, 0, 1) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Frame3d::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
// verifico validità riferimento
|
||||
if ( m_nType == ERR)
|
||||
return ;
|
||||
|
||||
// eseguo la traslazione
|
||||
m_ptOrig.Translate( vtMove) ;
|
||||
|
||||
// il tipo non cambia (dipende dall'orientamento e non dalla posizione)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{
|
||||
double dCosAng ;
|
||||
double dSinAng ;
|
||||
|
||||
|
||||
// verifico validità riferimento
|
||||
if ( m_nType == ERR)
|
||||
return false ;
|
||||
|
||||
// calcolo seno e coseno dell'angolo di rotazione
|
||||
dCosAng = cos( dAngRad) ;
|
||||
dSinAng = sin( dAngRad) ;
|
||||
|
||||
// controllo solo la prima rotazione, per le altre è lo stesso
|
||||
if ( ! m_ptOrig.Rotate( ptAx, vtAx, dCosAng, dSinAng)) {
|
||||
m_nType = ERR ;
|
||||
m_nZType = ERR ;
|
||||
return false ;
|
||||
}
|
||||
m_vtVersX.Rotate( vtAx, dCosAng, dSinAng) ;
|
||||
m_vtVersY.Rotate( vtAx, dCosAng, dSinAng) ;
|
||||
m_vtVersZ.Rotate( vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// ricalcolo il tipo
|
||||
CalculateType() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
// verifico validità deu frame
|
||||
if ( GetType() == ERR || frRef.GetType() == ERR)
|
||||
return false ;
|
||||
|
||||
// eseguo la trasformazione
|
||||
m_ptOrig.ToGlob( frRef) ;
|
||||
m_vtVersX.ToGlob( frRef) ;
|
||||
m_vtVersY.ToGlob( frRef) ;
|
||||
m_vtVersZ.ToGlob( frRef) ;
|
||||
|
||||
// ricalcolo il tipo
|
||||
CalculateType() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
// verifico validità dei frame
|
||||
if ( GetType() == ERR || frRef.GetType() == ERR)
|
||||
return false ;
|
||||
|
||||
// eseguo la trasformazione
|
||||
m_ptOrig.ToLoc( frRef) ;
|
||||
m_vtVersX.ToLoc( frRef) ;
|
||||
m_vtVersY.ToLoc( frRef) ;
|
||||
m_vtVersZ.ToLoc( frRef) ;
|
||||
|
||||
// ricalcolo il tipo
|
||||
CalculateType() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Frame3d::CalculateType( void)
|
||||
{
|
||||
// riferimento errato
|
||||
m_nType = ERR ;
|
||||
m_nZType = ERR ;
|
||||
|
||||
// se la Zloc non ha componenti x e y globali allora é diretta come Zglob
|
||||
if ( fabs( m_vtVersZ.x) < EPS_ZERO && fabs( m_vtVersZ.y) < EPS_ZERO) {
|
||||
// se inoltre ha lo stesso verso di Zglob
|
||||
if ( m_vtVersZ.z > 0)
|
||||
m_nZType = TOP ;
|
||||
else
|
||||
m_nZType = BOTTOM ;
|
||||
// se la Xloc coincide con Xglob Type coincide con ZType
|
||||
if ( fabs( m_vtVersX.y) < EPS_ZERO && fabs( m_vtVersX.z) < EPS_ZERO &&
|
||||
m_vtVersX.x > 0)
|
||||
m_nType = m_nZType ;
|
||||
else
|
||||
m_nType = GEN ;
|
||||
}
|
||||
|
||||
// se la Zloc non ha componenti y e z globali allora é diretta come Xglob
|
||||
else if ( fabs( m_vtVersZ.y) < EPS_ZERO && fabs( m_vtVersZ.z) < EPS_ZERO) {
|
||||
// se inoltre ha lo stesso verso di Xglob
|
||||
if ( m_vtVersZ.x > 0)
|
||||
m_nZType = RIGHT ;
|
||||
else
|
||||
m_nZType = LEFT ;
|
||||
// se la Yloc coincide con Zglob Type coincide con ZType
|
||||
if ( fabs( m_vtVersY.x) < EPS_ZERO && fabs( m_vtVersY.y) < EPS_ZERO &&
|
||||
m_vtVersY.z > 0)
|
||||
m_nType = m_nZType ;
|
||||
else
|
||||
m_nType = GEN ;
|
||||
}
|
||||
|
||||
// se la Zloc non ha componenti z e x globali allora é diretta come Yglob
|
||||
else if ( fabs( m_vtVersZ.z) < EPS_ZERO && fabs( m_vtVersZ.x) < EPS_ZERO) {
|
||||
// se inoltre ha lo stesso verso di Yglob
|
||||
if ( m_vtVersZ.y > 0)
|
||||
m_nZType = BACK ;
|
||||
else
|
||||
m_nZType = FRONT ;
|
||||
// se la Yloc coincide con Zglob Type coincide con ZType
|
||||
if ( fabs( m_vtVersY.x) < EPS_ZERO && fabs( m_vtVersY.y) < EPS_ZERO &&
|
||||
m_vtVersY.z > 0)
|
||||
m_nType = m_nZType ;
|
||||
else
|
||||
m_nType = GEN ;
|
||||
}
|
||||
|
||||
// altrimenti é generico
|
||||
else {
|
||||
m_nZType = GEN ;
|
||||
m_nType = GEN ;
|
||||
}
|
||||
}
|
||||
+650
@@ -0,0 +1,650 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GeomDB.cpp Data : 08.04.13 Versione : 1.1c1
|
||||
// Contenuto : Implementazione della classe GeomDB.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
#include "GeoConst.h"
|
||||
#include "GeomDB.h"
|
||||
#include "GdbObjFactory.h"
|
||||
#include "GeoObjTypeFun.h"
|
||||
#include "Scan.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// GeomDB
|
||||
//----------------------------------------------------------------------------
|
||||
GeomDB::GeomDB( void)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeomDB::~GeomDB( void)
|
||||
{
|
||||
Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Init( void)
|
||||
{
|
||||
// imposto numero minimo buckets di m_GdbNameMap
|
||||
m_GdbNameMap.rehash( 128) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Clear( void)
|
||||
{
|
||||
PGDBO_LIST::iterator Iter ;
|
||||
|
||||
|
||||
// ciclo di pulizia
|
||||
for ( Iter = m_GeomDB.begin() ; Iter != m_GeomDB.end() ; Iter++)
|
||||
delete (*Iter) ;
|
||||
|
||||
m_GeomDB.clear() ;
|
||||
m_GdbNameMap.clear() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Load( std::ifstream& osIn)
|
||||
{
|
||||
bool bOk ;
|
||||
bool bEnd ;
|
||||
CScan TheScanner ;
|
||||
|
||||
|
||||
// inizializzo lo scanner
|
||||
if ( ! TheScanner.Initialize( osIn)) {
|
||||
cout << "GeomDbLoad : Error on Init " << endl ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// leggo l'intestazione
|
||||
if ( ! LoadStart( TheScanner)) {
|
||||
cout << "GeomDbLoad : Error on line " << TheScanner.GetCurrLineNbr() << endl ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// ciclo di lettura degli oggetti
|
||||
bOk = true ;
|
||||
do {
|
||||
if ( ! LoadOneObject( TheScanner, bEnd)) {
|
||||
bOk = false ;
|
||||
cout << "GeomDbLoad : Error on line " << TheScanner.GetCurrLineNbr() << endl ;
|
||||
}
|
||||
} while ( ! bEnd) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::LoadStart( CScan& TheScanner)
|
||||
{
|
||||
string sLine ;
|
||||
|
||||
|
||||
// recupero la prima linea
|
||||
if ( ! TheScanner.GetLine( sLine))
|
||||
return false ;
|
||||
|
||||
// deve essere l'intestazione
|
||||
if ( sLine != "START")
|
||||
return false ;
|
||||
|
||||
// recupero la riga successiva
|
||||
if ( ! TheScanner.GetLine( sLine))
|
||||
return false ;
|
||||
|
||||
// leggo i parametri
|
||||
// TODO
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::LoadOneObject( CScan& TheScanner, bool& bEnd)
|
||||
{
|
||||
string sLine ;
|
||||
GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero la prossima linea (con il tipo di oggetto)
|
||||
if ( ! TheScanner.GetLine( sLine)) {
|
||||
bEnd = true ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se fine
|
||||
if ( sLine == "END") {
|
||||
bEnd = true ;
|
||||
}
|
||||
// altrimenti oggetto
|
||||
else {
|
||||
bEnd = false ;
|
||||
// creo l'oggetto
|
||||
pGObj = GDBOBJ_CREATE( sLine) ;
|
||||
if ( pGObj == nullptr)
|
||||
return false ;
|
||||
// ne leggo i dati e lo inserisco nel DB
|
||||
if ( ! pGObj->Load( TheScanner) ||
|
||||
! AddToGeomDB( pGObj)) {
|
||||
delete pGObj ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Save( std::ofstream& osOut)
|
||||
{
|
||||
bool bOk ;
|
||||
PGDBO_LIST::iterator Iter ;
|
||||
|
||||
|
||||
bOk = true ;
|
||||
// intestazione
|
||||
osOut << "START" << endl ;
|
||||
osOut << "GeomDB,1.2a3" << endl ;
|
||||
// ciclo di scrittura degli oggetti
|
||||
for ( Iter = m_GeomDB.begin() ; Iter != m_GeomDB.end() ; ++Iter) {
|
||||
// oggetto geometrico
|
||||
if ( ! (*Iter)->Save( osOut))
|
||||
bOk = false ;
|
||||
}
|
||||
// terminazione
|
||||
osOut << "END" << endl ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::ExistsGdbObj( const std::string& sName)
|
||||
{
|
||||
STRPGDBO_UMAP::const_iterator Iter ;
|
||||
|
||||
|
||||
Iter = m_GdbNameMap.find( sName) ;
|
||||
return ( Iter != m_GdbNameMap.end()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GdbObj*
|
||||
GeomDB::GetGdbObj( const std::string& sName)
|
||||
{
|
||||
STRPGDBO_UMAP::const_iterator Iter ;
|
||||
|
||||
|
||||
Iter = m_GdbNameMap.find( sName) ;
|
||||
if ( Iter != m_GdbNameMap.end())
|
||||
return Iter->second ;
|
||||
else
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddToGeomDB( GdbObj* pGObj)
|
||||
{
|
||||
// verifico validità oggetto puntato
|
||||
if ( pGObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifica validità e unicità del nome
|
||||
if ( pGObj->m_sName.length() == 0 || ExistsGdbObj( pGObj->m_sName))
|
||||
return false ;
|
||||
|
||||
// inserisco in lista principale
|
||||
m_GeomDB.push_back( pGObj) ;
|
||||
|
||||
// inserisco in mappa nomi
|
||||
m_GdbNameMap[ pGObj->m_sName] = pGObj ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddVector( const string& sName, const Vector3d& Vect)
|
||||
{
|
||||
GdbVector3d* pGVect ;
|
||||
|
||||
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
return false ;
|
||||
// alloco oggetto
|
||||
pGVect = new(nothrow) GdbVector3d ;
|
||||
if ( pGVect == nullptr)
|
||||
return false ;
|
||||
// assegno nome
|
||||
pGVect->m_sName = sName ;
|
||||
// assegno dati
|
||||
pGVect->m_gvV.Set( Vect) ;
|
||||
// inserisco nel DB
|
||||
if ( ! AddToGeomDB( pGVect)) {
|
||||
delete pGVect ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddPoint( const string& sName, const Point3d& Pnt)
|
||||
{
|
||||
GdbPoint3d* pGPnt ;
|
||||
|
||||
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
return false ;
|
||||
// alloco oggetto
|
||||
pGPnt = new(nothrow) GdbPoint3d ;
|
||||
if ( pGPnt == nullptr)
|
||||
return false ;
|
||||
// assegno nome
|
||||
pGPnt->m_sName = sName ;
|
||||
// assegno dati
|
||||
pGPnt->m_gpP.Set( Pnt) ;
|
||||
// inserisco nel DB
|
||||
if ( ! AddToGeomDB( pGPnt)) {
|
||||
delete pGPnt ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddCurveLine( const string& sName, const CurveLine& CrvLine)
|
||||
{
|
||||
GdbCurveLine* pGdbCL ;
|
||||
|
||||
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
return false ;
|
||||
// verifico validità dati geometrici
|
||||
if ( ! CrvLine.IsValid())
|
||||
return false ;
|
||||
// allocazione oggetto
|
||||
pGdbCL = new(nothrow) GdbCurveLine ;
|
||||
if ( pGdbCL == nullptr)
|
||||
return false ;
|
||||
// assegnazione nome
|
||||
pGdbCL->m_sName = sName ;
|
||||
// assegnazione dati
|
||||
pGdbCL->m_ln = CrvLine ;
|
||||
// inserimento nel DB
|
||||
if ( ! AddToGeomDB( pGdbCL)) {
|
||||
delete pGdbCL ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddCurveArc( const string& sName, const CurveArc& CrvArc)
|
||||
{
|
||||
GdbCurveArc* pGdbCA ;
|
||||
|
||||
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
return false ;
|
||||
// verifico validità dati geometrici
|
||||
if ( ! CrvArc.IsValid())
|
||||
return false ;
|
||||
// alloco oggetto
|
||||
pGdbCA = new(nothrow) GdbCurveArc ;
|
||||
if ( pGdbCA == nullptr)
|
||||
return false ;
|
||||
// assegno nome
|
||||
pGdbCA->m_sName = sName ;
|
||||
// assegno dati
|
||||
pGdbCA->m_ar = CrvArc ;
|
||||
// inserisco nel DB
|
||||
if ( ! AddToGeomDB( pGdbCA)) {
|
||||
delete pGdbCA ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddCurveBez( const string& sName, const CurveBezier& CrvBez)
|
||||
{
|
||||
GdbCurveBezier* pGdbCB ;
|
||||
|
||||
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
return false ;
|
||||
// verifico validità dati geometrici
|
||||
if ( ! CrvBez.IsValid())
|
||||
return false ;
|
||||
// allocazione oggetto
|
||||
pGdbCB = new(nothrow) GdbCurveBezier ;
|
||||
if ( pGdbCB == nullptr)
|
||||
return false ;
|
||||
// assegnazione nome
|
||||
pGdbCB->m_sName = sName ;
|
||||
// assegnamento dati
|
||||
pGdbCB->m_bz = CrvBez ;
|
||||
// inserimento nel DB
|
||||
if ( ! AddToGeomDB( pGdbCB)) {
|
||||
delete pGdbCB ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddCurveCompo( const string& sName, const CurveComposite& CrvCompo)
|
||||
{
|
||||
GdbCurveComposite* pGdbCC ;
|
||||
|
||||
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
return false ;
|
||||
// verifico validità dati geometrici
|
||||
if ( ! CrvCompo.IsValid())
|
||||
return false ;
|
||||
// allocazione oggetto
|
||||
pGdbCC = new(nothrow) GdbCurveComposite ;
|
||||
if ( pGdbCC == nullptr)
|
||||
return false ;
|
||||
// assegnazione nome
|
||||
pGdbCC->m_sName = sName ;
|
||||
// assegnamento dati
|
||||
pGdbCC->m_cc = CrvCompo ;
|
||||
// inserimento nel DB
|
||||
if ( ! AddToGeomDB( pGdbCC)) {
|
||||
delete pGdbCC ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoObjType
|
||||
GeomDB::GetObjType( const std::string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr)
|
||||
return GEO_NONE ;
|
||||
// ne identifico il tipo
|
||||
return pGObj->GetType() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const GeoVector3d*
|
||||
GeomDB::GetGeoVector3d( const string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto e ne verifico il tipo
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr || pGObj->GetType() != GEO_VECT3D)
|
||||
return nullptr ;
|
||||
|
||||
// assegno il vettore per riferimento
|
||||
return &(static_cast<const GdbVector3d*>(pGObj))->m_gvV ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const Vector3d*
|
||||
GeomDB::GetVector( const string& sName)
|
||||
{
|
||||
return &( GetGeoVector3d( sName)->m_vtV) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const GeoPoint3d*
|
||||
GeomDB::GetGeoPoint3d( const string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto e ne verifico il tipo
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr || pGObj->GetType() != GEO_PNT3D)
|
||||
return nullptr ;
|
||||
|
||||
// assegno il punto per riferimento
|
||||
return &(static_cast<const GdbPoint3d*>(pGObj))->m_gpP ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const Point3d*
|
||||
GeomDB::GetPoint( const string& sName)
|
||||
{
|
||||
return &( GetGeoPoint3d( sName)->m_ptP) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const CurveLine*
|
||||
GeomDB::GetCurveLine( const string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto e ne verifico il tipo
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr || pGObj->GetType() != CRV_LINE)
|
||||
return nullptr ;
|
||||
|
||||
// assegno la linea per riferimento
|
||||
return &(static_cast<const GdbCurveLine*>(pGObj))->m_ln ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const CurveArc*
|
||||
GeomDB::GetCurveArc( const string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto e ne verifico il tipo
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr || pGObj->GetType() != CRV_ARC)
|
||||
return nullptr ;
|
||||
|
||||
// assegno l'arco per riferimento
|
||||
return &(static_cast<const GdbCurveArc*>(pGObj))->m_ar ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const CurveBezier*
|
||||
GeomDB::GetCurveBez( const string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto e ne verifico il tipo
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr || pGObj->GetType() != CRV_BEZ)
|
||||
return nullptr ;
|
||||
|
||||
// assegno la curva di Bezier per riferimento
|
||||
return &(static_cast<const GdbCurveBezier*>(pGObj))->m_bz ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const CurveComposite*
|
||||
GeomDB::GetCurveCompo( const std::string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto e ne verifico il tipo
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr || pGObj->GetType() != CRV_COMPO)
|
||||
return nullptr ;
|
||||
|
||||
// assegno la curva di Bezier per riferimento
|
||||
return &(static_cast<const GdbCurveComposite*>(pGObj))->m_cc ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const Curve*
|
||||
GeomDB::GetCurve( const string& sName)
|
||||
{
|
||||
const GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// ritorno il puntatore alla curva (oppure nullptr se non è una curva)
|
||||
return ::GetCurve( pGObj->GetGeoObj()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Copy( const string& sNameSou, const string& sNameDest)
|
||||
{
|
||||
GdbObj* pGdoSou ;
|
||||
GdbObj* pGdoDest ;
|
||||
|
||||
|
||||
// verifico esistenza del sorgente
|
||||
if ( ( pGdoSou = GetGdbObj( sNameSou)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo la copia
|
||||
if ( ( pGdoDest = pGdoSou->Clone()) == nullptr)
|
||||
return false ;
|
||||
|
||||
// assegno il nuovo nome
|
||||
pGdoDest->m_sName = sNameDest ;
|
||||
|
||||
// inserisco nel DB
|
||||
if ( ! AddToGeomDB( pGdoDest)) {
|
||||
delete pGdoDest ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Erase( const string& sName)
|
||||
{
|
||||
PGDBO_LIST::iterator Iter ;
|
||||
|
||||
|
||||
// elimino da mappa dei nomi
|
||||
m_GdbNameMap.erase( sName) ;
|
||||
|
||||
// elimino da lista principale
|
||||
for ( Iter = m_GeomDB.begin() ; Iter != m_GeomDB.end() ; Iter++) {
|
||||
// se oggetto cercato
|
||||
if ( (*Iter)->m_sName == sName) {
|
||||
// lo disalloco (distruttore virtuale)
|
||||
delete( (*Iter)) ;
|
||||
// lo tolgo dalla lista
|
||||
m_GeomDB.erase( Iter) ;
|
||||
// esco
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Translate( const string& sName, const Vector3d& vtMove)
|
||||
{
|
||||
GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
return pGObj->Translate( vtMove) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Rotate( const string& sName, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{
|
||||
GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
return pGObj->Rotate( ptAx, vtAx, dAngDeg * DEGTORAD) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Scale( const string& sName, const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
return pGObj->Scale( ptCen, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Mirror( const string& sName, const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
GdbObj* pGObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGObj = GetGdbObj( sName)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
return pGObj->Mirror( ptOn, vtNorm) ;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalS
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GeomDB.h Data : 08.04.13 Versione : 1.1c1
|
||||
// Contenuto : Dichiarazione della classe GeomDB.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "GdbObj.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
typedef std::list< GdbObj*> PGDBO_LIST ;
|
||||
typedef std::unordered_map< std::string, GdbObj*> STRPGDBO_UMAP ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CScan ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class GeomDB
|
||||
{
|
||||
public :
|
||||
GeomDB( void) ;
|
||||
~GeomDB( void) ;
|
||||
bool Init( void) ;
|
||||
bool Clear( void) ;
|
||||
bool Load( std::ifstream& osIn) ;
|
||||
bool Save( std::ofstream& osOut) ;
|
||||
bool ExistsGdbObj( const std::string& sName) ;
|
||||
bool AddVector( const std::string& sName, const Vector3d& Vect) ;
|
||||
bool AddPoint( const std::string& sName, const Point3d& Pnt) ;
|
||||
bool AddCurveLine( const std::string& sName, const CurveLine& CrvLine) ;
|
||||
bool AddCurveArc( const std::string& sName, const CurveArc& CrvArc) ;
|
||||
bool AddCurveBez( const std::string& sName, const CurveBezier& CrvBez) ;
|
||||
bool AddCurveCompo( const std::string& sName, const CurveComposite& CrvCompo) ;
|
||||
GeoObjType GetObjType( const std::string& sName) ;
|
||||
const GeoVector3d* GetGeoVector3d( const std::string& sName) ;
|
||||
const Vector3d* GetVector( const std::string& sName) ;
|
||||
const GeoPoint3d* GetGeoPoint3d( const std::string& sName) ;
|
||||
const Point3d* GetPoint( const std::string& sName) ;
|
||||
const CurveLine* GetCurveLine( const std::string& sName) ;
|
||||
const CurveArc* GetCurveArc( const std::string& sName) ;
|
||||
const CurveBezier* GetCurveBez( const std::string& sName) ;
|
||||
const CurveComposite* GetCurveCompo( const std::string& sName) ;
|
||||
const Curve* GetCurve( const std::string& sName) ;
|
||||
bool Copy( const std::string& sNameSou, const std::string& sNameDest) ;
|
||||
bool Erase( const std::string& sName) ;
|
||||
bool Translate( const std::string& sName, const Vector3d& vtMove) ;
|
||||
bool Rotate( const std::string& sName, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) ;
|
||||
bool Scale( const std::string& sName, const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
bool Mirror( const std::string& sName, const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
|
||||
private :
|
||||
GdbObj* GetGdbObj( const std::string& sName) ;
|
||||
bool AddToGeomDB( GdbObj* pGObj) ;
|
||||
bool LoadStart( CScan& TheScanner) ;
|
||||
bool LoadOneObject( CScan& TheScanner, bool& bEnd) ;
|
||||
|
||||
private :
|
||||
PGDBO_LIST m_GeomDB ; // lista principale, proprietaria degli oggetti
|
||||
STRPGDBO_UMAP m_GdbNameMap ; // map basato sui nomi
|
||||
} ;
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Point3d.cpp Data : 20.11.13 Versione : 1.3a1
|
||||
// Contenuto : Funzioni della classe Punto 3d.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 04.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "\EgtDev\Include\EGkPoint3d.h"
|
||||
#include "\EgtDev\Include\EGkFrame3d.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Traslazione
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Point3d::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
*this = *this + vtMove ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dall'asse al punto
|
||||
vtDiff = *this - ptAx ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// rotazione del vettore
|
||||
if ( ! vtDiff.Rotate( vtAx, dCosAng, dSinAng))
|
||||
return false ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this = ptAx + vtDiff ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Scalatura non uniforme
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Scale( const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dal centro al punto
|
||||
vtDiff = *this - ptCen ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// scalatura del vettore
|
||||
if ( ! vtDiff.Scale( dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this = ptCen + vtDiff ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Specchiatura
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dal riferimento al punto
|
||||
vtDiff = *this - ptOn ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// specchiatura del vettore
|
||||
if ( ! vtDiff.Mirror( vtNorm))
|
||||
return false ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this = ptOn + vtDiff ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal riferimento al globale
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
Point3d ptT( x, y, z) ;
|
||||
|
||||
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// eseguo trasformazione
|
||||
x = ptT.x * frRef.VersX().x + ptT.y * frRef.VersY().x + ptT.z * frRef.VersZ().x + frRef.Orig().x ;
|
||||
y = ptT.x * frRef.VersX().y + ptT.y * frRef.VersY().y + ptT.z * frRef.VersZ().y + frRef.Orig().y ;
|
||||
z = ptT.x * frRef.VersX().z + ptT.y * frRef.VersY().z + ptT.z * frRef.VersZ().z + frRef.Orig().z ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal globale al riferimento
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
Vector3d vtT( x - frRef.Orig().x, y - frRef.Orig().y, z - frRef.Orig().z) ;
|
||||
|
||||
x = vtT.x * frRef.VersX().x + vtT.y * frRef.VersX().y + vtT.z * frRef.VersX().z ;
|
||||
y = vtT.x * frRef.VersY().x + vtT.y * frRef.VersY().y + vtT.z * frRef.VersY().z ;
|
||||
z = vtT.x * frRef.VersZ().x + vtT.y * frRef.VersZ().y + vtT.z * frRef.VersZ().z ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by EgtGeometry.rc
|
||||
//
|
||||
|
||||
// Valori predefiniti successivi per i nuovi oggetti
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NEXT_RESOURCE_VALUE 2000
|
||||
#define _APS_NEXT_CONTROL_VALUE 2000
|
||||
#define _APS_NEXT_SYMED_VALUE 2000
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#endif
|
||||
#endif
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Vector3d.cpp Data : 20.11.13 Versione : 1.3a1
|
||||
// Contenuto : Funzioni della classe Vettore 3d.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 04.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "\EgtDev\Include\EGkGeoConst.h"
|
||||
#include "\EgtDev\Include\EGkVector3d.h"
|
||||
#include "\EgtDev\Include\EGKFrame3d.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Definizione a partire da coordinate sferiche
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Vector3d::FromSpherical( double dLen, double dAngVertDeg, double dAngOrizzDeg)
|
||||
{
|
||||
double dAngVertRad ;
|
||||
double dAngOrizzRad ;
|
||||
double dSinAngVert ;
|
||||
|
||||
|
||||
dAngVertRad = dAngVertDeg * DEGTORAD ;
|
||||
dAngOrizzRad = dAngOrizzDeg * DEGTORAD ;
|
||||
dSinAngVert = sin( dAngVertRad) ;
|
||||
x = dLen * dSinAngVert * cos( dAngOrizzRad) ;
|
||||
y = dLen * dSinAngVert * sin( dAngOrizzRad) ;
|
||||
z = dLen * cos( dAngVertRad) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Definizione a partire da coordinate polari
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Vector3d::FromPolar( double dLen, double dAngDeg)
|
||||
{
|
||||
double dAngRad ;
|
||||
|
||||
|
||||
dAngRad = dAngDeg * DEGTORAD ;
|
||||
x = dLen * cos( dAngRad) ;
|
||||
y = dLen * sin( dAngRad) ;
|
||||
z = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Quadrato della lunghezza di un vettore
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
Vector3d::LenSq( void) const
|
||||
{
|
||||
return ( x * x + y * y + z * z) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Lunghezza di un vettore
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
Vector3d::Len( void) const
|
||||
{
|
||||
if ( fabs( y) < EPS_ZERO && fabs( z) < EPS_ZERO)
|
||||
return fabs( x) ;
|
||||
if ( fabs( z) < EPS_ZERO && fabs( x) < EPS_ZERO)
|
||||
return fabs( y) ;
|
||||
if ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO)
|
||||
return fabs( z) ;
|
||||
|
||||
return sqrt( x * x + y * y + z * z) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Ritorna la rappresentazione in coordinate sferiche
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Vector3d::ToSpherical( double* pdLen, double* pdAngVertDeg, double* pdAngOrizzDeg) const
|
||||
{
|
||||
double dLen ;
|
||||
double dAngVertDeg ;
|
||||
double dAngOrizzDeg ;
|
||||
|
||||
|
||||
// lunghezza
|
||||
dLen = Len() ;
|
||||
|
||||
// se vettore nullo
|
||||
if ( dLen < EPS_ZERO) {
|
||||
dAngVertDeg = 0 ;
|
||||
dAngOrizzDeg = 0 ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// se diretto come Z
|
||||
if ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO) {
|
||||
dAngVertDeg = (( z > 0) ? 0 : 180) ;
|
||||
dAngOrizzDeg = 0 ;
|
||||
}
|
||||
// se altrimenti nel piano XY
|
||||
else if ( fabs( z) < EPS_ZERO) {
|
||||
dAngVertDeg = 90.0 ;
|
||||
dAngOrizzDeg = atan2( y, x) * RADTODEG ;
|
||||
if ( dAngOrizzDeg < 0)
|
||||
dAngOrizzDeg += 360 ;
|
||||
}
|
||||
// caso generico
|
||||
else {
|
||||
dAngVertDeg = acos( z / dLen) * RADTODEG ;
|
||||
dAngOrizzDeg = atan2( y, x) * RADTODEG ;
|
||||
if ( dAngOrizzDeg < 0)
|
||||
dAngOrizzDeg += 360 ;
|
||||
}
|
||||
}
|
||||
|
||||
// ritorno i valori
|
||||
if ( pdLen != nullptr)
|
||||
*pdLen = dLen ;
|
||||
if ( pdAngVertDeg != nullptr)
|
||||
*pdAngVertDeg = dAngVertDeg ;
|
||||
if ( pdAngOrizzDeg != nullptr)
|
||||
*pdAngOrizzDeg = dAngOrizzDeg ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Normalizzazione di un vettore (trasformazione in versore)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Normalize( void)
|
||||
{
|
||||
double dSqLen ;
|
||||
double dLen ;
|
||||
|
||||
|
||||
// se già normalizzato, ok
|
||||
dSqLen = x * x + y * y + z * z ;
|
||||
if ( fabs( 1.0 - dSqLen) < ( 2 * EPS_ZERO))
|
||||
return true ;
|
||||
|
||||
// se troppo piccolo, errore
|
||||
if ( fabs( dSqLen) < ( EPS_SMALL * EPS_SMALL))
|
||||
return false ;
|
||||
|
||||
// eseguo la normalizzazione
|
||||
dLen = sqrt( dSqLen) ;
|
||||
*this = *this / dLen ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Rotate( const Vector3d& vtAx, double dAngRad)
|
||||
{
|
||||
return Rotate( vtAx, cos( dAngRad), sin( dAngRad)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Rotate( const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
double dCompPar ;
|
||||
Vector3d vtDirAx ;
|
||||
Vector3d vtCompPar ;
|
||||
Vector3d vtCompPerp ;
|
||||
Vector3d vtPerp2 ;
|
||||
Vector3d vtNewCompPerpX ;
|
||||
Vector3d vtNewCompPerpY ;
|
||||
Vector3d vtNewCompPerp ;
|
||||
|
||||
|
||||
// ricavo versore asse di rotazione
|
||||
vtDirAx = vtAx ;
|
||||
if ( ! vtDirAx.Normalize())
|
||||
return false ;
|
||||
|
||||
// separazione del vettore nelle componenti parallela e perp. asse
|
||||
dCompPar = *this * vtDirAx ;
|
||||
vtCompPar = vtDirAx * dCompPar ;
|
||||
vtCompPerp = *this - vtCompPar ;
|
||||
// calcolo vettore perp. componente perp. e asse
|
||||
vtPerp2 = vtDirAx ^ vtCompPerp ;
|
||||
// calcolo componenti perp. del vettore ruotato
|
||||
vtNewCompPerpX = dCosAng * vtCompPerp ;
|
||||
vtNewCompPerpY = dSinAng * vtPerp2 ;
|
||||
vtNewCompPerp = vtNewCompPerpX + vtNewCompPerpY ;
|
||||
// calcolo del vettore ruotato
|
||||
*this = vtCompPar + vtNewCompPerp ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Scalatura non uniforme
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Scale( double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
x *= dCoeffX ;
|
||||
y *= dCoeffY ;
|
||||
z *= dCoeffZ ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Specchiatura
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Mirror( const Vector3d& vtNorm)
|
||||
{
|
||||
double dCompNorm ;
|
||||
Vector3d vtDirNorm ;
|
||||
|
||||
|
||||
// ricavo versore normale al piano di simmetria
|
||||
vtDirNorm = vtNorm ;
|
||||
if ( ! vtDirNorm.Normalize())
|
||||
return false ;
|
||||
|
||||
// calcolo la componente parallela alla normale
|
||||
dCompNorm = *this * vtDirNorm ;
|
||||
|
||||
// il simmetrico è il vettore originale meno il doppio della componente parallela
|
||||
*this = *this - 2 * dCompNorm * vtDirNorm ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal riferimento al globale
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
Vector3d vtT( x, y, z) ;
|
||||
|
||||
x = vtT.x * frRef.VersX().x + vtT.y * frRef.VersY().x + vtT.z * frRef.VersZ().x ;
|
||||
y = vtT.x * frRef.VersX().y + vtT.y * frRef.VersY().y + vtT.z * frRef.VersZ().y ;
|
||||
z = vtT.x * frRef.VersX().z + vtT.y * frRef.VersY().z + vtT.z * frRef.VersZ().z ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal globale al riferimento
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
Vector3d vtT( x, y, z) ;
|
||||
|
||||
x = vtT.x * frRef.VersX().x + vtT.y * frRef.VersX().y + vtT.z * frRef.VersX().z ;
|
||||
y = vtT.x * frRef.VersY().x + vtT.y * frRef.VersY().y + vtT.z * frRef.VersY().z ;
|
||||
z = vtT.x * frRef.VersZ().x + vtT.y * frRef.VersZ().y + vtT.z * frRef.VersZ().z ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// stdafx.cpp : file di origine che include solo le inclusioni standard
|
||||
// EgtGeometry.pch sarà l'intestazione precompilata
|
||||
// stdafx.obj conterrà le informazioni sui tipi precompilati
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// stdafx.h : file di inclusione per file di inclusione di sistema standard
|
||||
// o file di inclusione specifici del progetto utilizzati di frequente, ma
|
||||
// modificati raramente
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WINVER 0x0601
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#define _WIN32_IE 0x0800
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
// in Debug riconoscimento memory leakage
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
// in Debug controllo iteratori
|
||||
#ifdef _DEBUG
|
||||
#define _SECURE_SCL 1
|
||||
#else
|
||||
#define _SECURE_SCL 0
|
||||
#endif
|
||||
Reference in New Issue
Block a user