diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 6a5921e..3589adb 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -2551,7 +2551,7 @@ end --------------------------------------------------------------------- local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) - -- Se variabile globale indica che lo smusso è gi stato fatto, esco + -- Se variabile globale indica che lo smusso è già stato fatto, esco if bMadeChamfer then return 0 end @@ -2565,6 +2565,7 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI end -- ottengo le curve di contorno libero local nAuxId1, nAuxId2, nNumIdAux + local bIsOpenPath = false if bIs3Faces then -- estraggo i percorsi nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) @@ -2575,6 +2576,36 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI else nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) if not nNumIdAux then nNumIdAux = 0 end + -- se non è una curva chiusa bisogna estrarre le sole curve da lavorare + if Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' then + local IdsToMachine = {} + bIsOpenPath = true + local nFirstId, nIdCount = EgtExplodeCurveCompo( nAuxId1) + for i = nFirstId, nFirstId + nIdCount - 1, 1 do + -- se segmento di retta + if EgtGetType( i) == GDB_TY.CRV_LINE then + local _, nEntitiesCount = EgtCurveDomain(i) + for j = 0, nEntitiesCount - 1 do + local ptStart = EgtUP( i, j, GDB_RT.GLOB) + local ptEnd = EgtUP( i, j + 1, GDB_RT.GLOB) + if ( AreSameVectorApprox( vtOrtho, X_AX()) and ( abs( ptStart:getX() - b3Solid:getMax():getX()) < 100 * GEO.EPS_SMALL and abs( ptEnd:getX() - b3Solid:getMax():getX()) < 100 * GEO.EPS_SMALL) or + AreSameVectorApprox( vtOrtho, -X_AX()) and ( abs( ptStart:getX() - b3Solid:getMin():getX()) < 100 * GEO.EPS_SMALL and abs( ptEnd:getX() - b3Solid:getMin():getX()) < 100 * GEO.EPS_SMALL) or + AreSameVectorApprox( vtOrtho, Y_AX()) and ( abs( ptStart:getY() - b3Solid:getMax():getY()) < 100 * GEO.EPS_SMALL and abs( ptEnd:getY() - b3Solid:getMax():getY()) < 100 * GEO.EPS_SMALL) or + AreSameVectorApprox( vtOrtho, -Y_AX()) and ( abs( ptStart:getY() - b3Solid:getMin():getY()) < 100 * GEO.EPS_SMALL and abs( ptEnd:getY() - b3Solid:getMin():getY()) < 100 * GEO.EPS_SMALL) or + AreSameVectorApprox( vtOrtho, Z_AX()) and ( abs( ptStart:getZ() - b3Solid:getMax():getZ()) < 100 * GEO.EPS_SMALL and abs( ptEnd:getZ() - b3Solid:getMax():getZ()) < 100 * GEO.EPS_SMALL) or + AreSameVectorApprox( vtOrtho, -Z_AX()) and ( abs( ptStart:getZ() - b3Solid:getMin():getZ()) < 100 * GEO.EPS_SMALL and abs( ptEnd:getZ() - b3Solid:getMin():getZ()) < 100 * GEO.EPS_SMALL) + ) then + table.insert( IdsToMachine, i) + end + end + else + return 0 + end + end + local ptNear = EgtSurfTmFacetCenter(Proc.Id, 0, GDB_ID.ROOT) + nAuxId1 = EgtCurveCompoByReorder( nAddGrpId, IdsToMachine, ptNear, true, GDB_ID.ROOT) + nNumIdAux = 1 + end end local dExtra = 2 @@ -2594,13 +2625,20 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI end else AuxId = nAuxId1 + i - 1 - vtExtr, _, _ = EgtCurveArea( AuxId) - end - if vtExtr then - if not bIs3Faces then + if bIsOpenPath then + _, vtExtr = EgtCurveIsFlat( AuxId) + else + vtExtr, _, _ = EgtCurveArea( AuxId) + end + if vtExtr then local fFrCurve = EgtGetGlobFrame( AuxId) vtExtr:toGlob( fFrCurve) + if bIsOpenPath and vtExtr * vtOrtho < GEO.EPS_SMALL then + vtExtr = -vtExtr + end end + end + if vtExtr then -- if bIs3Faces and i == nNumIdAux then -- vtExtr = -vtExtr -- end @@ -2844,6 +2882,12 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, local nOk, sErr = MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) if nOk < 0 then return false, sErr end end + -- slot aperta su due lati + elseif Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' then + if nChamfer > 0 then + local nOk, sErr = MakeChamfer( Proc, false, nAddGrpId, rfFac:getVersZ(), b3Solid, nil, dDepthCham) + if nOk < 0 then return false, sErr end + end end if not dDepth then dDepth = dElev end -- Recupero le facce adiacenti alla principale