1 // Created on: 2016-07-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BRepMesh_ConeRangeSplitter.hxx>
17 #include <GCPnts_TangentialDeflection.hxx>
19 //=======================================================================
20 // Function: GenerateSurfaceNodes
22 //=======================================================================
23 Handle(IMeshData::ListOfPnt2d) BRepMesh_ConeRangeSplitter::GenerateSurfaceNodes(
24 const IMeshTools_Parameters& theParameters) const
26 const std::pair<Standard_Real, Standard_Real>& aRangeU = GetRangeU();
27 const std::pair<Standard_Real, Standard_Real>& aRangeV = GetRangeV();
29 gp_Cone aCone = GetDFace()->GetSurface()->Cone();
30 Standard_Real aRefR = aCone.RefRadius();
31 Standard_Real aSAng = aCone.SemiAngle();
32 Standard_Real aRadius = Max(Abs(aRefR + aRangeV.first * Sin(aSAng)),
33 Abs(aRefR + aRangeV.second * Sin(aSAng)));
35 Standard_Real Dv, Du = GCPnts_TangentialDeflection::ArcAngularStep(
36 aRadius, GetDFace()->GetDeflection(),
37 theParameters.Angle, theParameters.MinSize);
39 const Standard_Real aDiffU = aRangeU.second - aRangeU.first;
40 const Standard_Real aDiffV = aRangeV.second - aRangeV.first;
41 Standard_Integer nbU = (Standard_Integer) (aDiffU / Du);
42 Standard_Integer nbV = (Standard_Integer) (nbU * (aDiffV) / (aDiffU * aRadius));
43 Du = aDiffU / (nbU + 1);
44 Dv = aDiffV / (nbV + 1);
46 const Handle(NCollection_IncAllocator) aTmpAlloc =
47 new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
48 Handle(IMeshData::ListOfPnt2d) aNodes = new IMeshData::ListOfPnt2d(aTmpAlloc);
50 const Standard_Real aPasMaxV = aRangeV.second - Dv*0.5;
51 const Standard_Real aPasMaxU = aRangeU.second - Du*0.5;
52 for (Standard_Real aPasV = aRangeV.first + Dv; aPasV < aPasMaxV; aPasV += Dv)
54 for (Standard_Real aPasU = aRangeU.first + Du; aPasU < aPasMaxU; aPasU += Du)
56 aNodes->Append(gp_Pnt2d(aPasU, aPasV));