0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRepMesh / BRepMesh_SphereRangeSplitter.cxx
CommitLineData
7bd071ed 1// Created on: 2016-07-07
2// Copyright (c) 2016 OPEN CASCADE SAS
3// Created by: Oleg AGASHIN
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <BRepMesh_SphereRangeSplitter.hxx>
17#include <GCPnts_TangentialDeflection.hxx>
18
19//=======================================================================
20// Function: GenerateSurfaceNodes
21// Purpose :
22//=======================================================================
23Handle(IMeshData::ListOfPnt2d) BRepMesh_SphereRangeSplitter::GenerateSurfaceNodes(
24 const IMeshTools_Parameters& theParameters) const
25{
26 // Calculate parameters for iteration in V direction
27 Standard_Real aStep = 0.7 * GCPnts_TangentialDeflection::ArcAngularStep(
28 GetDFace()->GetSurface()->Sphere().Radius(), GetDFace()->GetDeflection(),
29 theParameters.Angle, theParameters.MinSize);
30
31 const std::pair<Standard_Real, Standard_Real>* aRange[2] = {
32 &GetRangeV(),
33 &GetRangeU()
34 };
35
36 std::pair<Standard_Real, Standard_Real> aStepAndOffset[2];
37 computeStep(*aRange[0], aStep, aStepAndOffset[0]);
38 computeStep(*aRange[1], aStep, aStepAndOffset[1]);
39
40 const Handle(NCollection_IncAllocator) aTmpAlloc =
41 new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
42 Handle(IMeshData::ListOfPnt2d) aNodes = new IMeshData::ListOfPnt2d(aTmpAlloc);
43
44 const Standard_Real aHalfDu = aStepAndOffset[1].first * 0.5;
45 Standard_Boolean Shift = Standard_False;
46 Standard_Real aPasV = aRange[0]->first + aStepAndOffset[0].first;
47 for (; aPasV < aStepAndOffset[0].second; aPasV += aStepAndOffset[0].first)
48 {
49 Shift = !Shift;
50 const Standard_Real d = (Shift) ? aHalfDu : 0.;
51 Standard_Real aPasU = aRange[1]->first + d;
52 for (; aPasU < aStepAndOffset[1].second; aPasU += aStepAndOffset[1].first)
53 {
54 aNodes->Append(gp_Pnt2d(aPasU, aPasV));
55 }
56 }
57
58 return aNodes;
59}