//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : VolZmap.h Data : 22.01.15 Versione : 1.6a4 // Contenuto : Dichiarazione della classe Volume Zmap. // // // // Modifiche : 22.01.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include "ObjGraphicsMgr.h" #include "DllMain.h" #include "GeoObjRW.h" #include "CurveLine.h" #include "CurveArc.h" #include "CurveComposite.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkPoint3d.h" #include "/EgtDev/Include/EGkVector3d.h" #include "/EgtDev/Include/ENkPolynomialRoots.h" //---------------------------------------------------------------------------- class VolZmap : public IVolZmap, public IGeoObjRW { public : // IGeoObj virtual ~VolZmap( void) ; virtual VolZmap* Clone( void) const ; virtual GeoObjType GetType( void) const ; virtual bool IsValid( void) const { return ( m_nStatus == OK) ; } virtual const std::string& GetTitle( void) const ; virtual bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const ; virtual bool GetLocalBBox( BBox3d& b3Loc, int nFlag = BBF_STANDARD) const ; virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const ; virtual bool Translate( const Vector3d& vtMove) ; virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) { double dAngRad = dAngDeg * DEGTORAD ; return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ; virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ; virtual bool ToGlob( const Frame3d& frRef) ; virtual bool ToLoc( const Frame3d& frRef) ; virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ; virtual void SetObjGraphics( IObjGraphics* pOGr) { m_OGrMgr.SetObjGraphics( pOGr) ; } virtual IObjGraphics* GetObjGraphics( void) { return m_OGrMgr.GetObjGraphics() ; } virtual const IObjGraphics* GetObjGraphics( void) const { return m_OGrMgr.GetObjGraphics() ; } virtual void SetTempProp( int nProp) { m_nTempProp = nProp ; } virtual int GetTempProp( void) { return m_nTempProp ; } public : // IVolZmap bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool CreateMap( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dPrec) ; bool CreateMapFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double dPrec) ; bool GetAllTriangles( TRIA3DLIST& lstTria) const override ; bool GetDexelLines( int nDir, int nPos1, int nPos2, POLYLINELIST& lstPL) const override ; bool SetTolerances( double dLinTol, double dAngTolDeg = 90) override ; bool SetStdTool( const std::string& pToolName, double dH, double dR, double dCornR) override ; bool SetAdvTool( const std::string& pToolName, double dH, double dR, double dTipH, double dTipR, double dCornR) override ; bool SetGenTool( const std::string& pToolName, const ICurveComposite* pToolOutline) override ; bool MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d& ptPe, const Vector3d& vtDe) override ; bool Deepness( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) override ; bool BBoxZmapIntersection( const Frame3d& frBBox, const Point3d& ptMax) override ; bool SubtractIntervals( unsigned int nI, unsigned int nJ, double dMin, double dMax) ; bool SubtractIntervals( const Point3d& ptP, double dMin, double dMax) ; bool AddIntervals( unsigned int nI, unsigned int nJ, double dMin, double dMax) ; bool AddIntervals( const Point3d& ptP, double dMin, double dMax) ; public : // IGeoObjRW virtual int GetNgeId( void) const ; virtual bool Save( NgeWriter& ngeOut) const ; virtual bool Load( NgeReader& ngeIn) ; public : VolZmap( void) ; VolZmap( const VolZmap& stSrc) { if ( ! CopyFrom( stSrc)) LOG_ERROR( GetEGkLogger(), "VolZmap : copy constructor error") } VolZmap& operator =( const VolZmap& stSrc) { if ( ! CopyFrom( stSrc)) LOG_ERROR( GetEGkLogger(), "VolZmap : copy error") return *this ; } private : enum ToolType { GenericTool = 0, // generico da profilo -> usare SetTool CylindricalMill = 1, // cilindrica BallEndMill = 2, // sferica BullNoseMill = 3, // naso di toro ConusMill = 4} ; // con parte terminale conica private : bool CopyFrom( const VolZmap& clSrc) ; bool GetChunkPrisms( int nPos1, int nPos2, int nDim1, int nDim2, int nDimChk, TRIA3DLIST& lstTria) const ; bool CalcChunkPrisms( int nPos1, int nPos2, int nDim1, int nDim2, TRIA3DLIST& lstTria) const ; bool CalcDexelPrisms( int nPos1, int nPos2, TRIA3DLIST& lstTria) const ; bool AddDexelSideFace( int nPos, int nPosAdj, const Point3d& ptP, const Point3d& ptQ, const Vector3d& vtZ, const Vector3d& vtNorm, TRIA3DLIST& lstTria) const ; // frese: cylindrical, ball-end, bull-nose e conus // Versore utensile parallelo all'asse Z // Fori bool DrillingZ( const Point3d & ptLs, const Point3d & ptLe, const Vector3d & vtToolDir) ; bool CBTDrillZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool ConusDrillingZ( const Point3d ptLs, const Point3d ptLe, const Vector3d vtToolDir) ; // Tagli orizzontali bool MillingPerpZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool CBTMillingPerpZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool ConusPerpZ( const Point3d ptLs, const Point3d ptLe, const Vector3d vtToolDir) ; inline bool GetMinMaxZSw( const Point3d ptO, unsigned int nStartI, unsigned int nEndI, unsigned int nStartJ, unsigned int nEndJ, double dMinZ, double dMaxZ, double dMinRad, double dMaxRad, double dDir, double dDeltaZ) ; inline bool GetMinMaxZDr( const Point3d ptO, unsigned int nStartI, unsigned int nEndI, unsigned int nStartJ, unsigned int nEndJ, double dMinZ, double dMaxZ, double dMinRad, double dMaxRad, double dDir, double dDeltaZ) ; inline bool GetMinMaxZ( unsigned int nI, unsigned int nJ, double dZCutBase, double dDeltaZ, double dSqDist, const Vector3d& vtToolDir) ; // generico 3 assi bool MillingZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool CBMillingZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool ConusMillingZDr( const Point3d ptLs, const Point3d ptLe, const Vector3d vtToolDir) ; bool ConusMillingZSw( const Point3d ptLs, const Point3d ptLe, const Vector3d vtToolDir) ; inline bool GetMinMaxZGen( unsigned int nI, unsigned int nJ, double dProj, double dSqd, double dLenPath, double dZheight, double dDelta, const Vector3d& vtToolDir) ; // Versore utensile nel piano XY // DeltaZ = 0 bool DrillingXY( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool CBTDrillXY( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool ConusDrillingXY( const Point3d ptLs, const Point3d ptLe, const Vector3d vtToolDir) ; bool MillingPerpXY( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool CBTPerpXY( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool ConusPerpXY( const Point3d ptLs, const Point3d ptLe, const Vector3d vtToolDir) ; bool MillingXYPlaneGen( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool PlaneGenCylBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool ConusPlaneGen( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; inline bool GetMinMaxXY( unsigned int nI, unsigned int nJ, double dProj, double dZheight, double dSqD, double dPathPerp, double dPathPar, double dScProd) ; inline bool GetMMPlaneGenCyl( unsigned int i, unsigned int j, double dZ, double dLen1, double dLen2, double dProj1, double dProj2) ; inline bool GetMMPlaneGenBall( unsigned int i, unsigned int j, double dZ, double dLen1, double dLen2, Point3d ptIxy, Vector3d vtMove, Vector3d vtV1, Vector3d vtV2) ; // DeltaZ != 0 bool MillingXYVert( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYLongVert( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool XYLongVertCylBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool XYLongVertConus( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXY( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYCyl( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYConus( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYPlus( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYPlusCyl( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYPlusBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingXYPlusConus( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; // Virtual milling per componenti elementari // Versore utensile parallelo all'asse Z // Movimento parallelo al versore utensile bool DrillZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; // Componenti bool LongCylV( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dRad) ; bool LongConusV( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad) ; // Angolo generico fra movimento e versore utensile bool MillZ( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; // Componenti bool MillCylV( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dRad) ; bool MillConusV( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad) ; // Direzione generica del versore utensile // Movimento parallelo al versore utensile bool Drilling( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool DrillingGT( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; // Componenti elementari degli untensili bool LongBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dRad) ; bool LongCyl( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dRad) ; bool LongConus( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad) ; // Angolo generico fra movimento e versore utensile bool Milling( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; bool MillingGT( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir) ; // Componenti elementari degli utensili bool MillCyl( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dRad) ; bool MillCyl2( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dRad) ; bool MillBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dRad) ; bool MillConus( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad) ; bool MillConusAux( const Point3d& ptI, const Point3d& ptF, const Vector3d& vtV1, const Vector3d& vtV2, const Vector3d& vtV3, unsigned int & nStI, unsigned int & nStJ, unsigned int & nEnI, unsigned int & nEnJ, double dHei, double dMaxRad, double dMinRad, double dCoef) ; // Traslazioni bool Ball( const Point3d& ptLs, const Point3d& ptLe, double dRad) ; // Sottrazione per tridexel bool ZDrillingCB( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir) ; // Bounding Box inline bool BoundingBox( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV1, const Vector3d& vtV2, unsigned int & nStI, unsigned int & nStJ, unsigned int & nEnI, unsigned int & nEnJ) ; inline bool BoundingBox( unsigned int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV1, const Vector3d& vtV2, unsigned int & nStI, unsigned int & nStJ, unsigned int & nEnI, unsigned int & nEnJ) ; inline bool BoundingBox( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV1, const Vector3d& vtV2) ; inline bool BBoxComponent( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV1, const Vector3d& vtV2, unsigned int & nStI, unsigned int & nStJ, unsigned int & nEnI, unsigned int & nEnJ, double dRad, double dTipRad, double dHei) ; inline bool BBoxComponent( unsigned int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV1, const Vector3d& vtV2, unsigned int & nStI, unsigned int & nStJ, unsigned int & nEnI, unsigned int & nEnJ, double dRad, double dTipRad, double dHei) ; bool IsAPointInside( const Point3d& ptP) ; bool IsThereMat( unsigned int nI, unsigned int nJ, double dZ) ; bool LineParallelepipedIntersection( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptE1, const Point3d& ptE2, double& dt1, double& dt2) ; bool LineParallelepipedIntersection( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptEnd, double& dt1, double& dt2) ; bool IntersectALineZMapBBox( const Point3d& ptP, const Vector3d& vtV, Point3d& ptFirst, Point3d& ptLast) ; bool LineDexelIntersection( const Point3d& ptP, const Vector3d& vtV, unsigned int nI, unsigned int nJ, double& dOutMatFirst, double& dInMat, double& dOutMatLast) ; bool BBoxZmapIntersection( const Frame3d& frBBoxFrame, const BBox3d& bbBox) ; private : enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; private : ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto Status m_nStatus ; // stato int m_nTempProp ; // proprietà temporanea Frame3d m_LocalFrame ; Frame3d m_LocalFrame2 ; Frame3d m_LocalFrame3 ; double m_dStep ; unsigned int m_nNx ; // i = 0, 1, ..., m_nNx - 1 unsigned int m_nNy ; // j = 0, 1, ..., m_nNy - 1 unsigned int m_nNx2 ; unsigned int m_nNy2 ; unsigned int m_nNx3 ; unsigned int m_nNy3 ; unsigned int m_nDim ; unsigned int m_nDim2 ; unsigned int m_nDim3 ; double m_dMinZ ; double m_dMaxZ ; double m_dMinZ2 ; double m_dMaxZ2 ; double m_dMinZ3 ; double m_dMaxZ3 ; std::vector > m_ZValues ; std::vector > m_ZValues2 ; std::vector > m_ZValues3 ; double m_dLinTol ; double m_dAngTolDeg ; std::string m_sToolName ; unsigned int m_nToolType ; CurveComposite m_ToolOutline ; CurveComposite m_ToolArcLineApprox ; double m_dHeight ; double m_dTipHeight ; double m_dRadius ; double m_dRCorner ; double m_dTipRadius ; } ; //----------------------------------------------------------------------------- inline VolZmap* CreateBasicVolZmap( void) { return (static_cast( CreateGeoObj( VOL_ZMAP))) ; } inline VolZmap* CloneBasicVolZmap( const IGeoObj* pGObj) { if ( pGObj == nullptr || pGObj->GetType() != VOL_ZMAP) return nullptr ; return (static_cast(pGObj->Clone())) ; } inline const VolZmap* GetBasicVolZmap( const IGeoObj* pGObj) { if ( pGObj == nullptr || pGObj->GetType() != VOL_ZMAP) return nullptr ; return (static_cast(pGObj)) ; } inline VolZmap* GetBasicVolZmap( IGeoObj* pGObj) { if ( pGObj == nullptr || pGObj->GetType() != VOL_ZMAP) return nullptr ; return (static_cast(pGObj)) ; }