1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <ShapeUpgrade_SplitSurfaceArea.ixx>
19 #include <TColStd_HSequenceOfReal.hxx>
20 #include <GeomAdaptor_Surface.hxx>
22 //=======================================================================
23 //function : ShapeUpgrade_SplitSurfaceArea
25 //=======================================================================
27 ShapeUpgrade_SplitSurfaceArea::ShapeUpgrade_SplitSurfaceArea():
28 ShapeUpgrade_SplitSurface()
33 //=======================================================================
36 //=======================================================================
38 void ShapeUpgrade_SplitSurfaceArea::Compute(const Standard_Boolean /*Segment*/)
43 GeomAdaptor_Surface ads(mySurface,myUSplitValues->Value(1),myUSplitValues->Value(2),
44 myVSplitValues->Value(1),myVSplitValues->Value(2));
45 Standard_Real aKoefU = ads.UResolution(1.);
46 Standard_Real aKoefV = ads.VResolution(1.);
51 Standard_Real aUSize = fabs(myUSplitValues->Value(2) - myUSplitValues->Value(1))/aKoefU;
52 Standard_Real aVSize = fabs(myVSplitValues->Value(2) - myVSplitValues->Value(1))/aKoefV;
53 Standard_Real aNbUV = aUSize/aVSize;
54 Handle(TColStd_HSequenceOfReal) aFirstSplit = (aNbUV <1. ? myVSplitValues : myUSplitValues);
55 Handle(TColStd_HSequenceOfReal) aSecondSplit = (aNbUV <1. ? myUSplitValues : myVSplitValues);
59 Standard_Integer nbSplitF = (aNbUV >= myNbParts ? myNbParts : RealToInt(ceil(sqrt(myNbParts*ceil(aNbUV)))));
60 Standard_Integer nbSplitS = (aNbUV >= myNbParts ? 0 : RealToInt(ceil((Standard_Real)myNbParts/(Standard_Real)nbSplitF)));
65 Standard_Real aStep = (aFirstSplit->Value(2) - aFirstSplit->Value(1))/nbSplitF;
66 Standard_Real aPrevPar = aFirstSplit->Value(1);
67 Standard_Integer i =1;
68 for( ; i < nbSplitF; i++) {
69 Standard_Real aNextPar = aPrevPar + aStep;
70 aFirstSplit->InsertBefore(i+1,aNextPar);
75 aStep = (aSecondSplit->Value(2) - aSecondSplit->Value(1))/nbSplitS;
76 aPrevPar = aSecondSplit->Value(1);
77 for(i =1 ; i < nbSplitS; i++) {
78 Standard_Real aNextPar = aPrevPar + aStep;
79 aSecondSplit->InsertBefore(i+1,aNextPar);