mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
87
src/IGESConvGeom/IGESConvGeom.cdl
Executable file
87
src/IGESConvGeom/IGESConvGeom.cdl
Executable file
@@ -0,0 +1,87 @@
|
||||
-- File: IGESConvGeom.cdl
|
||||
-- Created: Thu Sep 1 15:31:13 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
package IGESConvGeom
|
||||
|
||||
---Purpose : This package is intended to gather geometric conversion which
|
||||
-- are not immediate but can be used for several purposes :
|
||||
-- mainly, standard conversion to and from CasCade geometric and
|
||||
-- topologic data, and adaptations of IGES files as required
|
||||
-- (as replacing Spline entities to BSpline equivalents).
|
||||
|
||||
uses Standard, gp, TColgp, Geom, Geom2d, IGESGeom
|
||||
|
||||
is
|
||||
|
||||
class GeomBuilder;
|
||||
---Purpose : basic tool to build curves from IGESGeom (arrays of points,
|
||||
-- Transformations, evaluation of points in a datum)
|
||||
|
||||
SplineCurveFromIGES
|
||||
(igesent : SplineCurve from IGESGeom;
|
||||
epscoef, epsgeom : Real;
|
||||
result : out mutable BSplineCurve from Geom)
|
||||
returns Integer;
|
||||
---Purpose : Converts a SplineCurve from IGES to a BSplineCurve from CasCade
|
||||
-- <epscoef> gives tolerance to consider coefficient to be nul
|
||||
-- <epsgeom> gives tolerance to consider poles to be equal
|
||||
-- The returned value is a status with these possible values :
|
||||
-- - 0 OK, done
|
||||
-- - 1 the result is not guaranteed to be C0 (with <epsgeom>)
|
||||
-- - 2 SplineType not processed (allowed : max 3)
|
||||
-- (no result produced)
|
||||
-- - 3 error during creation of control points
|
||||
-- (no result produced)
|
||||
-- - 4 polynomial equation is not correct (no result produced)
|
||||
-- - 5 less than one segment (no result produced)
|
||||
|
||||
IncreaseCurveContinuity
|
||||
(curve : mutable BSplineCurve from Geom;
|
||||
epsgeom : Real;
|
||||
continuity : Integer = 2) returns Integer;
|
||||
---Purpose : Tries to increase curve continuity with tolerance <epsgeom>
|
||||
-- <continuity> is the new desired continuity, can be 1 or 2
|
||||
-- (more than 2 is considered as 2).
|
||||
-- Returns the new maximum continuity obtained on all knots.
|
||||
-- Remark that, for instance with <continuity> = 2, even if not
|
||||
-- all the knots can be passed to C2, all knots which can be are.
|
||||
|
||||
IncreaseCurveContinuity
|
||||
(curve : mutable BSplineCurve from Geom2d;
|
||||
epsgeom : Real;
|
||||
continuity : Integer = 2) returns Integer;
|
||||
|
||||
SplineSurfaceFromIGES
|
||||
(igesent : SplineSurface from IGESGeom;
|
||||
epscoef, epsgeom : Real;
|
||||
result : out mutable BSplineSurface from Geom)
|
||||
returns Integer;
|
||||
---Purpose : Converts a SplineSurface from IGES to a BSplineSurface from CasCade
|
||||
-- <epscoef> gives tolerance to consider coefficient to be nul
|
||||
-- <epsgeom> gives tolerance to consider poles to be equal
|
||||
-- The returned value is a status with these possible values :
|
||||
-- - 0 OK, done
|
||||
-- - 1 the result is not guaranteed to be C0 (with <epsgeom>)
|
||||
-- - 2 degree is not compatible with code boundary type
|
||||
-- (warning) but C0 is OK
|
||||
-- - 3 idem but C0 is not guaranteed (warning)
|
||||
-- - 4 degree has been determined to be nul, either in U or V
|
||||
-- (no result produced)
|
||||
-- - 5 less than one segment in U or V (no result produced)
|
||||
|
||||
IncreaseSurfaceContinuity
|
||||
(surface : mutable BSplineSurface from Geom;
|
||||
epsgeom : Real;
|
||||
continuity : Integer = 2) returns Integer;
|
||||
---Purpose : Tries to increase Surface continuity with tolerance <epsgeom>
|
||||
-- <continuity> is the new desired continuity, can be 1 or 2
|
||||
-- (more than 2 is considered as 2).
|
||||
-- Returns the new maximum continuity obtained on all knots.
|
||||
-- Remark that, for instance with <continuity> = 2, even if not
|
||||
-- all the knots can be passed to C2, all knots which can be are.
|
||||
|
||||
end IGESConvGeom;
|
651
src/IGESConvGeom/IGESConvGeom.cxx
Executable file
651
src/IGESConvGeom/IGESConvGeom.cxx
Executable file
@@ -0,0 +1,651 @@
|
||||
// Copyright: Matra-Datavision 1994
|
||||
// File: IGESConvGeom.cxx
|
||||
// Created: Thu Sep 1 16:00:17 1994
|
||||
// Author: Christian CAILLET
|
||||
// <cky>
|
||||
// modif du 31/01/97 : mjm
|
||||
// on commence par les SplineCurves.
|
||||
// modif du 17/03/97 : mjm
|
||||
// SplineSurfaces.
|
||||
//%13 pdn 12.02.99: USA60293 avoid applying transformation twice
|
||||
|
||||
#include <IGESConvGeom.ixx>
|
||||
|
||||
#include <IGESData_ToolLocation.hxx>
|
||||
|
||||
#include <BSplCLib.hxx>
|
||||
|
||||
#include <BSplSLib.hxx>
|
||||
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <GeomConvert_CompCurveToBSplineCurve.hxx>
|
||||
#include <PLib.hxx>
|
||||
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <TColgp_HArray2OfPnt.hxx>
|
||||
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IGESConvGeom::SplineCurveFromIGES
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer IGESConvGeom::SplineCurveFromIGES
|
||||
(const Handle(IGESGeom_SplineCurve)& st,
|
||||
const Standard_Real /*epscoef*/, const Standard_Real epsgeom,
|
||||
Handle(Geom_BSplineCurve)& res)
|
||||
{
|
||||
Standard_Integer returned = 0;
|
||||
|
||||
// on recupere le degre
|
||||
Standard_Integer degree = st->SplineType();
|
||||
if (degree > 3) degree = 3;
|
||||
|
||||
// on recupere le nombre de segments.
|
||||
Standard_Integer nbSegs = st->NbSegments();
|
||||
if (nbSegs < 1) return 5; // FAIL : no segment
|
||||
|
||||
Standard_Integer nbKnots = nbSegs+1;
|
||||
|
||||
// Array of multiplicities.
|
||||
TColStd_Array1OfInteger multi(1, nbKnots);
|
||||
multi.Init(degree);
|
||||
multi.SetValue(multi.Lower(), degree+1);
|
||||
multi.SetValue(multi.Upper(), degree+1);
|
||||
|
||||
// Array of knots.
|
||||
TColStd_Array1OfReal knots(1, nbKnots);
|
||||
TColStd_Array1OfReal delta(1, nbSegs);
|
||||
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
|
||||
for (i = 1; i<= nbKnots; i++)
|
||||
knots.SetValue(i, st->BreakPoint(i));
|
||||
|
||||
for (i = 1; i <= nbSegs; i++)
|
||||
delta.SetValue(i, st->BreakPoint(i+1) - st->BreakPoint(i));
|
||||
|
||||
TColgp_Array1OfPnt bspoles(1, nbSegs*degree+1);
|
||||
Standard_Integer ibspole = bspoles.Lower()-1; // Bspole Index.
|
||||
// il faut reparametrer avant de passer dans PLib.
|
||||
// on est entre[0, T(i+1)-T(i)] et on veut [0,1]
|
||||
|
||||
for (i = 1; i <= nbSegs; i++) {
|
||||
Standard_Real AX,BX,CX,DX,AY,BY,CY,DY,AZ,BZ,CZ,DZ;
|
||||
st->XCoordPolynomial(i, AX, BX, CX, DX);
|
||||
st->YCoordPolynomial(i, AY, BY, CY, DY);
|
||||
st->ZCoordPolynomial(i, AZ, BZ, CZ, DZ);
|
||||
if (st->NbDimensions() == 2 ) BZ=0.,CZ=0.,DZ=0.;
|
||||
Standard_Real Di = delta(i);
|
||||
Standard_Real Di2 = delta(i)*delta(i);
|
||||
Standard_Real Di3 = delta(i)*delta(i)*delta(i);
|
||||
|
||||
TColgp_Array1OfPnt coeff(0, degree);
|
||||
switch (degree) {
|
||||
case 3 :
|
||||
coeff.SetValue(coeff.Lower()+3, gp_Pnt(DX*Di3, DY*Di3, DZ*Di3));
|
||||
case 2 :
|
||||
coeff.SetValue(coeff.Lower()+2, gp_Pnt(CX*Di2, CY*Di2, CZ*Di2));
|
||||
case 1 :
|
||||
coeff.SetValue(coeff.Lower()+1, gp_Pnt(BX*Di, BY*Di, BZ*Di));
|
||||
coeff.SetValue(coeff.Lower()+0, gp_Pnt(AX, AY, AZ));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
TColgp_Array1OfPnt bzpoles(0, degree);
|
||||
PLib::CoefficientsPoles(coeff,PLib::NoWeights(),bzpoles,PLib::NoWeights());
|
||||
|
||||
// C0 test.
|
||||
// Not to check the first pole of the first segment.
|
||||
if (ibspole > bspoles.Lower()) {
|
||||
Standard_Integer bzlow = bzpoles.Lower();
|
||||
if (!(bspoles.Value(ibspole).IsEqual(bzpoles.Value(bzlow), epsgeom))) {
|
||||
returned = 1;
|
||||
// Medium point computing.
|
||||
bspoles.SetValue (ibspole,
|
||||
gp_Pnt((bspoles.Value(ibspole).X() + bzpoles.Value(bzlow).X())/2.,
|
||||
(bspoles.Value(ibspole).Y() + bzpoles.Value(bzlow).Y())/2.,
|
||||
(bspoles.Value(ibspole).Z() + bzpoles.Value(bzlow).Z())/2.));
|
||||
}
|
||||
}
|
||||
if (i == 1) bspoles.SetValue(++ibspole, bzpoles.Value(bzpoles.Lower()));
|
||||
|
||||
for (Standard_Integer j = bzpoles.Lower()+1; j <= bzpoles.Upper(); j++)
|
||||
bspoles.SetValue(++ibspole, bzpoles.Value(j));
|
||||
}
|
||||
if (ibspole != bspoles.Upper()) {
|
||||
// Just to be sure.
|
||||
return 3; // FAIL : Error during creation of control points
|
||||
}
|
||||
|
||||
// Building result taking into account transformation if any :
|
||||
// ===========================================================
|
||||
|
||||
//%13 pdn 12.02.99 USA60293
|
||||
// if (st->HasTransf()) {
|
||||
// gp_Trsf trsf;
|
||||
// Standard_Real epsilon = 1.E-04;
|
||||
// if (IGESData_ToolLocation::ConvertLocation
|
||||
// (epsilon,st->CompoundLocation(),trsf)) {
|
||||
// for (Standard_Integer i = bspoles.Lower(); i <= bspoles.Upper(); i++)
|
||||
// bspoles.SetValue(i, bspoles.Value(i).Transformed(trsf));
|
||||
// }
|
||||
// else
|
||||
// AddFail(st, "Transformation : not a similarity");
|
||||
// }
|
||||
res = new Geom_BSplineCurve (bspoles, knots, multi, degree);
|
||||
// GeomConvert_CompCurveToBSplineCurve CompCurve =
|
||||
// GeomConvert_CompCurveToBSplineCurve(res);
|
||||
// res = CompCurve.BSplineCurve();
|
||||
return returned;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IGESConvGeom::IncreaseCurveContinuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer IGESConvGeom::IncreaseCurveContinuity (const Handle(Geom_BSplineCurve)& res,
|
||||
const Standard_Real epsgeom,
|
||||
const Standard_Integer continuity)
|
||||
{
|
||||
if (continuity < 1) return continuity;
|
||||
Standard_Boolean isC1 = Standard_True, isC2 = Standard_True;
|
||||
Standard_Integer degree = res->Degree();
|
||||
|
||||
|
||||
Standard_Boolean isModified;
|
||||
do {
|
||||
isModified = Standard_False;
|
||||
for (Standard_Integer i = res->FirstUKnotIndex()+1; i < res->LastUKnotIndex(); i++)
|
||||
if(degree - res->Multiplicity(i) < continuity) {
|
||||
if (continuity >= 2) {
|
||||
if (!res->RemoveKnot(i, degree-2, epsgeom)) {
|
||||
isC2 = Standard_False;
|
||||
Standard_Boolean locOK = res->RemoveKnot(i, degree-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
else
|
||||
isModified = Standard_True;
|
||||
}
|
||||
else {
|
||||
Standard_Boolean locOK = res->RemoveKnot(i, degree-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (isModified);
|
||||
|
||||
if (!isC1) return 0;
|
||||
if (continuity >= 2 && !isC2) return 1;
|
||||
return continuity;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IncreaseCurveContinuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer IGESConvGeom::IncreaseCurveContinuity (const Handle(Geom2d_BSplineCurve)& res,
|
||||
const Standard_Real epsgeom,
|
||||
const Standard_Integer continuity)
|
||||
{
|
||||
if (continuity < 1) return continuity;
|
||||
Standard_Boolean isC1 = Standard_True, isC2 = Standard_True;
|
||||
Standard_Integer degree = res->Degree();
|
||||
|
||||
Standard_Boolean isModified;
|
||||
do {
|
||||
isModified = Standard_False;
|
||||
for (Standard_Integer i = res->FirstUKnotIndex()+1; i < res->LastUKnotIndex(); i++)
|
||||
if(degree - res->Multiplicity(i) < continuity) {
|
||||
if (continuity >= 2) {
|
||||
if (!res->RemoveKnot(i, degree-2, epsgeom)) {
|
||||
isC2 = Standard_False;
|
||||
Standard_Boolean locOK = res->RemoveKnot(i, degree-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
else
|
||||
isModified = Standard_True;
|
||||
}
|
||||
else {
|
||||
Standard_Boolean locOK = res->RemoveKnot(i, degree-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (isModified);
|
||||
|
||||
if (!isC1) return 0;
|
||||
if (continuity >= 2 && !isC2) return 1;
|
||||
return continuity;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IGESConvGeom::SplineSurfaceFromIGES
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer IGESConvGeom::SplineSurfaceFromIGES
|
||||
(const Handle(IGESGeom_SplineSurface)& st,
|
||||
const Standard_Real /*epscoef*/, const Standard_Real epsgeom,
|
||||
Handle(Geom_BSplineSurface)& res)
|
||||
{
|
||||
Standard_Integer returned = 0;
|
||||
Standard_Integer degree = st->BoundaryType();
|
||||
if (degree > 3) degree = 3;
|
||||
Standard_Integer DegreeU = degree;
|
||||
Standard_Integer DegreeV = degree;
|
||||
|
||||
Standard_Integer NbUSeg = st->NbUSegments();
|
||||
Standard_Integer NbVSeg = st->NbVSegments();
|
||||
|
||||
if ((NbUSeg < 1) || (NbVSeg < 1)) return 5;
|
||||
|
||||
// Output BSpline knots & multiplicities arraies for U & V :
|
||||
// =========================================================
|
||||
|
||||
TColStd_Array1OfReal UKnot(1,NbUSeg+1);
|
||||
TColStd_Array1OfReal VKnot(1,NbVSeg+1);
|
||||
TColStd_Array1OfReal deltaU(1,NbUSeg);
|
||||
TColStd_Array1OfReal deltaV(1,NbVSeg);
|
||||
|
||||
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
|
||||
for (i=1; i <= NbUSeg+1; i++)
|
||||
UKnot.SetValue(i, st->UBreakPoint(i));
|
||||
|
||||
for (i=1; i <= NbUSeg; i++)
|
||||
deltaU.SetValue(i, st->UBreakPoint(i+1)- st->UBreakPoint(i));
|
||||
|
||||
for (i=1; i <= NbVSeg+1; i++)
|
||||
VKnot.SetValue(i, st->VBreakPoint(i));
|
||||
|
||||
for (i=1; i <= NbVSeg; i++)
|
||||
deltaV.SetValue(i, st->VBreakPoint(i+1)- st->VBreakPoint(i));
|
||||
|
||||
TColStd_Array1OfInteger UMult(1,NbUSeg+1); UMult.Init(DegreeU);
|
||||
UMult.SetValue(UMult.Lower(),DegreeU+1);
|
||||
UMult.SetValue(UMult.Upper(),DegreeU+1);
|
||||
|
||||
TColStd_Array1OfInteger VMult(1,NbVSeg+1); VMult.Init(DegreeV);
|
||||
VMult.SetValue(VMult.Lower(),DegreeV+1);
|
||||
VMult.SetValue(VMult.Upper(),DegreeV+1);
|
||||
|
||||
|
||||
// Poles computing
|
||||
// ===============
|
||||
|
||||
Standard_Integer NbUPoles = NbUSeg * DegreeU + 1;
|
||||
Standard_Integer NbVPoles = NbVSeg * DegreeV + 1;
|
||||
|
||||
TColgp_Array2OfPnt BsPole(1, NbUPoles, 1, NbVPoles);
|
||||
|
||||
Standard_Integer iBs, jBs, iBz, jBz;
|
||||
Standard_Boolean wasC0 = Standard_True;
|
||||
|
||||
// Patch (1,1)
|
||||
// ===========
|
||||
Standard_Integer USeg, VSeg, j;
|
||||
USeg = 1;
|
||||
VSeg = 1;
|
||||
|
||||
Handle(TColStd_HArray1OfReal) XPoly = st->XPolynomial(USeg, VSeg);
|
||||
Handle(TColStd_HArray1OfReal) YPoly = st->YPolynomial(USeg, VSeg);
|
||||
Handle(TColStd_HArray1OfReal) ZPoly = st->ZPolynomial(USeg, VSeg);
|
||||
|
||||
TColgp_Array2OfPnt Coef(1, DegreeU+1, 1, DegreeV+1);
|
||||
Standard_Real ParamU, ParamV;
|
||||
ParamU = 1.;
|
||||
for (i=1; i<=DegreeU+1; i++) {
|
||||
ParamV = 1.;
|
||||
for (j=1; j<=DegreeV+1; j++) {
|
||||
Standard_Integer PolyIndex = i + 4*(j-1);
|
||||
gp_Pnt aPoint(XPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
YPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
ZPoly->Value(PolyIndex)*ParamU*ParamV);
|
||||
Coef.SetValue(i, j, aPoint);
|
||||
ParamV = ParamV *deltaV(VSeg);
|
||||
}
|
||||
ParamU = ParamU * deltaU(USeg);
|
||||
}
|
||||
TColgp_Array2OfPnt BzPole(1, DegreeU+1, 1, DegreeV+1);
|
||||
PLib::CoefficientsPoles(Coef,PLib::NoWeights2(),BzPole,PLib::NoWeights2());
|
||||
|
||||
iBs = BsPole.LowerRow();
|
||||
jBs = BsPole.LowerCol();
|
||||
|
||||
// Making output BSpline poles array :
|
||||
for (iBz=BzPole.LowerRow(); iBz<=BzPole.UpperRow(); iBz++) {
|
||||
for (jBz=BzPole.LowerCol(); jBz<=BzPole.UpperCol(); jBz++)
|
||||
BsPole.SetValue(iBs, jBs++, BzPole.Value(iBz,jBz));
|
||||
jBs = BsPole.LowerCol();
|
||||
iBs++;
|
||||
}
|
||||
|
||||
|
||||
// Patches (1<USeg<NbUSeg, 1)
|
||||
// ==========================
|
||||
|
||||
VSeg = 1;
|
||||
for (USeg=2; USeg<=NbUSeg; USeg++) {
|
||||
XPoly = st->XPolynomial(USeg, VSeg);
|
||||
YPoly = st->YPolynomial(USeg, VSeg);
|
||||
ZPoly = st->ZPolynomial(USeg, VSeg);
|
||||
Standard_Real ParamU, ParamV;
|
||||
ParamU = 1.;
|
||||
for (i=Coef.LowerRow(); i<=Coef.UpperRow(); i++) {
|
||||
ParamV = 1.;
|
||||
for (j=Coef.LowerCol(); j<=Coef.UpperCol(); j++) {
|
||||
Standard_Integer PolyIndex = i + 4*(j-1);
|
||||
gp_Pnt aPoint;
|
||||
aPoint.SetCoord(XPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
YPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
ZPoly->Value(PolyIndex)*ParamU*ParamV);
|
||||
Coef.SetValue(i, j, aPoint);
|
||||
ParamV = ParamV *deltaV(VSeg);
|
||||
}
|
||||
ParamU = ParamU * deltaU(USeg);
|
||||
}
|
||||
PLib::CoefficientsPoles(Coef,PLib::NoWeights2(),BzPole,PLib::NoWeights2());
|
||||
|
||||
// C0 check and correction for poles lying on isoparametrics U=0 & V=0
|
||||
Standard_Integer iBs = BsPole.LowerRow() + (USeg-1)*DegreeU;
|
||||
Standard_Integer jBs = BsPole.LowerCol();
|
||||
iBz = BzPole.LowerRow();
|
||||
for (jBz=BzPole.LowerCol(); jBz<=BzPole.UpperCol(); jBz++) {
|
||||
if (!BzPole.Value(iBz,jBz).IsEqual(BsPole.Value(iBs,jBs), epsgeom)) {
|
||||
wasC0=Standard_False;
|
||||
gp_Pnt MidPoint;
|
||||
Standard_Real XCoord =
|
||||
0.5 * (BzPole.Value(iBz,jBz).X() + BsPole.Value(iBs,jBs).X());
|
||||
Standard_Real YCoord =
|
||||
0.5 * (BzPole.Value(iBz,jBz).Y() + BsPole.Value(iBs,jBs).Y());
|
||||
Standard_Real ZCoord =
|
||||
0.5 * (BzPole.Value(iBz,jBz).Z() + BsPole.Value(iBs,jBs).Z());
|
||||
MidPoint.SetCoord(XCoord, YCoord, ZCoord);
|
||||
BsPole.SetValue(iBs, jBs++, MidPoint);
|
||||
}
|
||||
else {
|
||||
BsPole.SetValue(iBs, jBs++, BzPole.Value(iBz,jBz));
|
||||
}
|
||||
}
|
||||
|
||||
// Other poles (no check about C0) :
|
||||
iBs++;
|
||||
jBs = BsPole.LowerCol();
|
||||
for (iBz=BzPole.LowerRow()+1; iBz<=BzPole.UpperRow(); iBz++) {
|
||||
for (jBz=BzPole.LowerCol(); jBz<=BzPole.UpperCol(); jBz++)
|
||||
BsPole.SetValue(iBs, jBs++, BzPole.Value(iBz,jBz));
|
||||
iBs++;
|
||||
jBs = BsPole.LowerCol();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Patches (1, 1<VSeg<NbVSeg)
|
||||
// ==========================
|
||||
|
||||
USeg = 1;
|
||||
for (VSeg=2; VSeg <= NbVSeg; VSeg++) {
|
||||
XPoly = st->XPolynomial(USeg, VSeg);
|
||||
YPoly = st->YPolynomial(USeg, VSeg);
|
||||
ZPoly = st->ZPolynomial(USeg, VSeg);
|
||||
Standard_Real ParamU, ParamV;
|
||||
ParamU = 1.;
|
||||
for (i=Coef.LowerRow(); i<=Coef.UpperRow(); i++) {
|
||||
ParamV = 1.;
|
||||
for (j=Coef.LowerCol(); j<=Coef.UpperCol(); j++) {
|
||||
Standard_Integer PolyIndex = i + 4*(j-1);
|
||||
gp_Pnt aPoint;
|
||||
aPoint.SetCoord(XPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
YPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
ZPoly->Value(PolyIndex)*ParamU*ParamV);
|
||||
Coef.SetValue(i, j, aPoint);
|
||||
ParamV = ParamV *deltaV(VSeg);
|
||||
}
|
||||
ParamU = ParamU * deltaU(USeg);
|
||||
}
|
||||
PLib::CoefficientsPoles(Coef,PLib::NoWeights2(),BzPole,PLib::NoWeights2());
|
||||
|
||||
// C0 check and correction for poles lying on isoparametrics U=0 & V=0
|
||||
iBs = BsPole.LowerRow();
|
||||
jBs = BsPole.LowerCol() + (VSeg-1)*DegreeV;
|
||||
jBz = BzPole.LowerCol();
|
||||
for (iBz=BzPole.LowerRow(); iBz<=BzPole.UpperRow(); iBz++) {
|
||||
if (!BzPole.Value(iBz,jBz).IsEqual(BsPole.Value(iBs,jBs), epsgeom)) {
|
||||
wasC0=Standard_False;
|
||||
gp_Pnt MidPoint;
|
||||
Standard_Real XCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).X() + BsPole.Value(iBs,jBs).X());
|
||||
Standard_Real YCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).Y() + BsPole.Value(iBs,jBs).Y());
|
||||
Standard_Real ZCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).Z() + BsPole.Value(iBs,jBs).Z());
|
||||
MidPoint.SetCoord(XCoord, YCoord, ZCoord);
|
||||
BsPole.SetValue(iBs++, jBs, MidPoint);
|
||||
}
|
||||
else{
|
||||
BsPole.SetValue(iBs++, jBs, BzPole.Value(iBz,jBz));
|
||||
}
|
||||
}
|
||||
|
||||
jBs++;
|
||||
iBs = BsPole.LowerRow();
|
||||
for (jBz=BzPole.LowerCol()+1; jBz<=BzPole.UpperCol(); jBz++) {
|
||||
for (iBz=BzPole.LowerRow(); iBz<=BzPole.UpperRow(); iBz++)
|
||||
BsPole.SetValue(iBs++, jBs, BzPole.Value(iBz,jBz));
|
||||
iBs = BsPole.LowerRow();
|
||||
jBs++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Patches (1<USeg<NbUSeg, 1<VSeg<NbVSeg)
|
||||
// ======================================
|
||||
|
||||
for (VSeg=2; VSeg <= NbVSeg; VSeg++) {
|
||||
for (USeg=2; USeg <= NbUSeg; USeg++) {
|
||||
XPoly = st->XPolynomial(USeg, VSeg);
|
||||
YPoly = st->YPolynomial(USeg, VSeg);
|
||||
ZPoly = st->ZPolynomial(USeg, VSeg);
|
||||
Standard_Real ParamU, ParamV;
|
||||
ParamU = 1.;
|
||||
for (i=Coef.LowerRow(); i<=Coef.UpperRow(); i++) {
|
||||
ParamV = 1.;
|
||||
for (j=Coef.LowerCol(); j<=Coef.UpperCol(); j++) {
|
||||
Standard_Integer PolyIndex = i + 4*(j-1);
|
||||
gp_Pnt aPoint;
|
||||
aPoint.SetCoord(XPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
YPoly->Value(PolyIndex)*ParamU*ParamV,
|
||||
ZPoly->Value(PolyIndex)*ParamU*ParamV);
|
||||
Coef.SetValue(i, j, aPoint);
|
||||
ParamV = ParamV *deltaV(VSeg);
|
||||
}
|
||||
ParamU = ParamU * deltaU(USeg);
|
||||
}
|
||||
PLib::CoefficientsPoles(Coef,PLib::NoWeights2(),BzPole,PLib::NoWeights2());
|
||||
|
||||
// C0 check and correction for poles lying on isoparametrics U=0 & V=0
|
||||
iBs = (USeg-1)*DegreeU + BsPole.LowerRow();
|
||||
jBs = (VSeg-1)*DegreeV + BsPole.LowerCol();
|
||||
jBz = BzPole.LowerCol();
|
||||
for (iBz=BzPole.LowerRow(); iBz<=BzPole.UpperRow(); iBz++) {
|
||||
if (!BzPole.Value(iBz,jBz).IsEqual(BsPole.Value(iBs,jBs), epsgeom)) {
|
||||
wasC0=Standard_False;
|
||||
gp_Pnt MidPoint;
|
||||
Standard_Real XCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).X() + BsPole.Value(iBs,jBs).X());
|
||||
Standard_Real YCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).Y() + BsPole.Value(iBs,jBs).Y());
|
||||
Standard_Real ZCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).Z() + BsPole.Value(iBs,jBs).Z());
|
||||
MidPoint.SetCoord(XCoord, YCoord, ZCoord);
|
||||
BsPole.SetValue(iBs++, jBs, MidPoint);
|
||||
}
|
||||
else
|
||||
BsPole.SetValue(iBs++, jBs, BzPole.Value(iBz,jBz));
|
||||
}
|
||||
|
||||
iBs = (USeg-1)*DegreeU + BsPole.LowerRow();
|
||||
iBz = BzPole.LowerRow();
|
||||
for (jBz=BzPole.LowerCol(); jBz<=BzPole.UpperCol(); jBz++) {
|
||||
// C0 check and correction for poles lying on isoparametrics U=0 & V=0
|
||||
if (!BzPole.Value(iBz,jBz).IsEqual(BsPole.Value(iBs,jBs), epsgeom)) {
|
||||
wasC0=Standard_False;
|
||||
gp_Pnt MidPoint;
|
||||
Standard_Real XCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).X() + BsPole.Value(iBs,jBs).X());
|
||||
Standard_Real YCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).Y() + BsPole.Value(iBs,jBs).Y());
|
||||
Standard_Real ZCoord = 0.5 *
|
||||
(BzPole.Value(iBz,jBz).Z() + BsPole.Value(iBs,jBs).Z());
|
||||
MidPoint.SetCoord(XCoord, YCoord, ZCoord);
|
||||
BsPole.SetValue(iBs, jBs++, MidPoint);
|
||||
}
|
||||
else
|
||||
BsPole.SetValue(iBs, jBs++, BzPole.Value(iBz,jBz));
|
||||
}
|
||||
|
||||
iBs = BsPole.LowerRow() + (USeg-1)*DegreeU + 1;
|
||||
jBs = BsPole.LowerCol() + (VSeg-1)*DegreeV + 1;
|
||||
for (iBz=BzPole.LowerRow()+1; iBz<=BzPole.UpperRow(); iBz++) {
|
||||
for (jBz=BzPole.LowerCol()+1; jBz<=BzPole.UpperCol(); jBz++)
|
||||
BsPole.SetValue(iBs, jBs++, BzPole.Value(iBz,jBz));
|
||||
jBs = BsPole.LowerCol() + (VSeg-1)*DegreeV + 1;
|
||||
iBs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Building result taking into account transformation if any :
|
||||
// ===========================================================
|
||||
|
||||
if (st->HasTransf()) {
|
||||
gp_GTrsf GSplTrsf(st->CompoundLocation());
|
||||
gp_Trsf SplTrsf;
|
||||
Standard_Real epsilon = 1.E-04;
|
||||
if (IGESData_ToolLocation::ConvertLocation(epsilon,GSplTrsf,SplTrsf))
|
||||
for (iBs=BsPole.LowerRow(); iBs<=BsPole.UpperRow(); iBs++)
|
||||
for (jBs=BsPole.LowerCol(); jBs<=BsPole.UpperCol(); jBs++)
|
||||
BsPole.SetValue(iBs, jBs, BsPole.Value(iBs,jBs).Transformed(SplTrsf));
|
||||
// else
|
||||
// AddWarning(start, "Transformation skipped : Not a similarity");
|
||||
}
|
||||
|
||||
res = new Geom_BSplineSurface
|
||||
(BsPole, UKnot, VKnot, UMult, VMult, DegreeU, DegreeV);
|
||||
if (wasC0) returned += 1;
|
||||
return returned;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IGESConvGeom::IncreaseSurfaceContinuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer IGESConvGeom::IncreaseSurfaceContinuity (const Handle(Geom_BSplineSurface)& res,
|
||||
const Standard_Real epsgeom,
|
||||
const Standard_Integer continuity)
|
||||
{
|
||||
if (continuity < 1) return continuity;
|
||||
Standard_Boolean isC1 = Standard_True, isC2 = Standard_True;
|
||||
Standard_Integer i,j;
|
||||
|
||||
i = res->LastUKnotIndex(); //knots.Upper();
|
||||
j = res->FirstUKnotIndex(); //knots.Lower();
|
||||
Standard_Integer DegreeU = res->UDegree();
|
||||
|
||||
Standard_Boolean isModified;
|
||||
do {
|
||||
isModified = Standard_False;
|
||||
for (i = res->FirstUKnotIndex()+1; i < res->LastUKnotIndex(); i++)
|
||||
if(DegreeU - res->UMultiplicity(i) < continuity) {
|
||||
if (continuity >= 2) {
|
||||
if (!res->RemoveUKnot(i, DegreeU-2, epsgeom)) {
|
||||
isC2 = Standard_False;
|
||||
Standard_Boolean locOK = res->RemoveUKnot(i, DegreeU-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
else
|
||||
isModified = Standard_True;
|
||||
}
|
||||
else {
|
||||
Standard_Boolean locOK = res->RemoveUKnot(i, DegreeU-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (isModified);
|
||||
|
||||
Standard_Integer DegreeV = res->VDegree();
|
||||
do {
|
||||
isModified = Standard_False;
|
||||
for (i = res->FirstVKnotIndex()+1; i < res->LastVKnotIndex(); i++)
|
||||
if(DegreeV - res->VMultiplicity(i) < continuity) {
|
||||
if (continuity >= 2) {
|
||||
if (!res->RemoveVKnot(i, DegreeV-2, epsgeom)) {
|
||||
isC2 = Standard_False;
|
||||
Standard_Boolean locOK = res->RemoveVKnot(i, DegreeV-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
else
|
||||
isModified = Standard_True;
|
||||
}
|
||||
else {
|
||||
Standard_Boolean locOK = res->RemoveVKnot(i, DegreeV-1, epsgeom); // is C1 ?
|
||||
isC1 &= locOK;
|
||||
isModified |= locOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (isModified);
|
||||
|
||||
/*
|
||||
while (--i > j) { // from 2 to NbKnots-1
|
||||
if (continuity >= 2) {
|
||||
if (!res->RemoveUKnot(i, DegreeU-2, epsgeom)) { // is C2 ?
|
||||
isC2 = Standard_False;
|
||||
isC1 &= res->RemoveUKnot(i, DegreeU-1, epsgeom); // is C1 ?
|
||||
}
|
||||
}
|
||||
else {
|
||||
isC1 &= res->RemoveUKnot(i, DegreeU-1, epsgeom); // is C1 ?
|
||||
}
|
||||
}
|
||||
|
||||
i = res->LastVKnotIndex(); //knots.Upper();
|
||||
j = res->FirstVKnotIndex(); //knots.Lower();
|
||||
Standard_Integer DegreeV = res->VDegree();
|
||||
while (--i > j) { // from 2 to NbKnots-1
|
||||
if (continuity >= 2) {
|
||||
if (!res->RemoveVKnot(i, DegreeV-2, epsgeom)) { // is C2 ?
|
||||
isC2 = Standard_False;
|
||||
isC1 &= res->RemoveVKnot(i, DegreeV-1, epsgeom); // is C1 ?
|
||||
}
|
||||
}
|
||||
else {
|
||||
isC1 &= res->RemoveVKnot(i, DegreeV-1, epsgeom); // is C1 ?
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
if (!isC1) return 0;
|
||||
if (continuity >= 2 && !isC2) return 1;
|
||||
return continuity;
|
||||
}
|
||||
|
117
src/IGESConvGeom/IGESConvGeom_GeomBuilder.cdl
Executable file
117
src/IGESConvGeom/IGESConvGeom_GeomBuilder.cdl
Executable file
@@ -0,0 +1,117 @@
|
||||
-- File: IGESConvGeom_GeomBuilder.cdl
|
||||
-- Created: Wed Nov 16 14:16:50 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@stylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class GeomBuilder from IGESConvGeom
|
||||
|
||||
---Purpose : This class provides some useful basic tools to build IGESGeom
|
||||
-- curves, especially :
|
||||
-- define a curve in a plane in 3D space (ex. Circular or Conic
|
||||
-- arc, or Copious Data defined in 2D)
|
||||
-- make a CopiousData from a list of points/vectors
|
||||
|
||||
uses XY from gp, XYZ from gp, Trsf, Ax1, Ax2, Ax3,
|
||||
HSequenceOfXYZ, HArray1OfXY, HArray1OfXYZ,
|
||||
TransformationMatrix, CopiousData
|
||||
|
||||
raises DomainError
|
||||
|
||||
is
|
||||
|
||||
Create returns GeomBuilder;
|
||||
---Purpose : Creates a GeomBuilder at initial state.
|
||||
|
||||
Clear (me : in out) is static;
|
||||
---Purpose : Clears list of Points/Vectors and data about Transformation
|
||||
|
||||
AddXY (me : in out; val : XY from gp) is static;
|
||||
---Purpose : Adds a XY (Z=0) to the list of points
|
||||
|
||||
AddXYZ (me : in out; val : XYZ from gp) is static;
|
||||
---Purpose : Adds a XYZ to the list of points
|
||||
|
||||
AddVec (me : in out; val : XYZ from gp) is static;
|
||||
---Purpose : Adds a Vector part to the list of points. It will be used
|
||||
-- for CopiousData, datatype=3, only.
|
||||
-- AddXY and AddXYZ consider a null vector part (0,0,0)
|
||||
-- AddVec adds to the last added XY or XYZ
|
||||
|
||||
NbPoints (me) returns Integer is static;
|
||||
---Purpose : Returns the count of already recorded points
|
||||
|
||||
Point (me; num : Integer) returns XYZ is static;
|
||||
---Purpose : Returns a point given its rank (if added as XY, Z will be 0)
|
||||
|
||||
MakeCopiousData (me; datatype : Integer; polyline : Boolean = Standard_False)
|
||||
returns mutable CopiousData
|
||||
---Purpose : Makes a CopiousData with the list of recorded Points/Vectors
|
||||
-- according to <datatype>, which must be 1,2 or 3
|
||||
-- If <polyline> is given True, the CopiousData is coded as a
|
||||
-- Polyline, but <datatype> must not be 3
|
||||
-- <datatype> = 1 : Common Z is computed as average of all Z
|
||||
-- <datatype> = 1 or 2 : Vectors are ignored
|
||||
raises DomainError;
|
||||
-- Error if : <datatype> is not 1,2 or 3; or NbPoints is 0
|
||||
|
||||
MakeXY (me) returns mutable HArray1OfXY is static;
|
||||
---Purpose : Returns the list of points as a HArray1OfXY. Z are ignored.
|
||||
|
||||
MakeXYZ (me) returns mutable HArray1OfXYZ is static;
|
||||
---Purpose : Returns the list of points as a HArray1OfXYZ
|
||||
|
||||
|
||||
Position (me) returns Trsf from gp is static;
|
||||
---Purpose : Returns the Position in which the method EvalXYZ will
|
||||
-- evaluate a XYZ. It can be regarded as defining a local system.
|
||||
-- It is initially set to Identity
|
||||
|
||||
SetPosition (me : in out; pos : Trsf from gp) is static;
|
||||
---Purpose : Sets final position from an already defined Trsf
|
||||
|
||||
SetPosition (me : in out; pos : Ax3 from gp) is static;
|
||||
---Purpose : Sets final position from an Ax3
|
||||
|
||||
SetPosition (me : in out; pos : Ax2 from gp) is static;
|
||||
---Purpose : Sets final position from an Ax2
|
||||
|
||||
SetPosition (me : in out; pos : Ax1 from gp) is static;
|
||||
---Purpose : Sets final position from an Ax1
|
||||
-- (this means that origin point and Z-axis are defined, the
|
||||
-- other axes are defined arbitrarily)
|
||||
|
||||
IsIdentity (me) returns Boolean is static;
|
||||
---Purpose : Returns True if the Position is Identity
|
||||
|
||||
IsTranslation (me) returns Boolean is static;
|
||||
---Purpose : Returns True if the Position is a Translation only
|
||||
-- Remark : Identity and ZOnly will answer True
|
||||
|
||||
IsZOnly (me) returns Boolean is static;
|
||||
---Purpose : Returns True if the Position corresponds to a Z-Displacement,
|
||||
-- i.e. is a Translation only, and only on Z
|
||||
-- Remark : Identity will answer True
|
||||
|
||||
EvalXYZ (me; val : XYZ from gp; X,Y,Z : out Real) is static;
|
||||
---Purpose : Evaluates a XYZ value in the Position already defined.
|
||||
-- Returns the transformed coordinates.
|
||||
-- For a 2D definition, X,Y will then be used to define a XY and
|
||||
-- Z will be regarded as a Z Displacement (can be ignored)
|
||||
|
||||
MakeTransformation (me; unit : Real = 1)
|
||||
returns mutable TransformationMatrix is static;
|
||||
---Purpose : Returns the IGES Transformation which corresponds to the
|
||||
-- Position. Even if it is an Identity : IsIdentity should be
|
||||
-- tested first.
|
||||
-- <unit> is the unit value in which the model is created :
|
||||
-- it is used to convert translation part
|
||||
|
||||
fields
|
||||
|
||||
theXYZ : HSequenceOfXYZ;
|
||||
theVec : HSequenceOfXYZ;
|
||||
thepos : Trsf from gp;
|
||||
|
||||
end GeomBuilder;
|
190
src/IGESConvGeom/IGESConvGeom_GeomBuilder.cxx
Executable file
190
src/IGESConvGeom/IGESConvGeom_GeomBuilder.cxx
Executable file
@@ -0,0 +1,190 @@
|
||||
#include <IGESConvGeom_GeomBuilder.ixx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
#include <Interface_Translates.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <gp.hxx>
|
||||
|
||||
|
||||
static Standard_Real epsl = 1.E-10;
|
||||
static Standard_Real epsa = 1.E-10;
|
||||
|
||||
IGESConvGeom_GeomBuilder::IGESConvGeom_GeomBuilder ()
|
||||
{ Clear(); }
|
||||
|
||||
|
||||
void IGESConvGeom_GeomBuilder::Clear ()
|
||||
{
|
||||
theXYZ = new TColgp_HSequenceOfXYZ();
|
||||
theVec = new TColgp_HSequenceOfXYZ();
|
||||
gp_Trsf trid; thepos = trid;
|
||||
}
|
||||
|
||||
void IGESConvGeom_GeomBuilder::AddXY (const gp_XY& val)
|
||||
{
|
||||
gp_XYZ aval (val.X(),val.Y(),0.);
|
||||
theXYZ->Append (aval);
|
||||
aval.SetCoord (0.,0.,0.);
|
||||
theVec->Append (aval);
|
||||
}
|
||||
|
||||
void IGESConvGeom_GeomBuilder::AddXYZ (const gp_XYZ& val)
|
||||
{
|
||||
theXYZ->Append (val);
|
||||
theVec->Append (gp_XYZ(0.,0.,0.) );
|
||||
}
|
||||
|
||||
void IGESConvGeom_GeomBuilder::AddVec (const gp_XYZ& val)
|
||||
{
|
||||
if (!theVec->IsEmpty()) theVec->SetValue (theVec->Length(), val);
|
||||
}
|
||||
|
||||
Standard_Integer IGESConvGeom_GeomBuilder::NbPoints () const
|
||||
{ return theXYZ->Length(); }
|
||||
|
||||
gp_XYZ IGESConvGeom_GeomBuilder::Point (const Standard_Integer num) const
|
||||
{ return theXYZ->Value (num); }
|
||||
|
||||
Handle(IGESGeom_CopiousData) IGESConvGeom_GeomBuilder::MakeCopiousData
|
||||
(const Standard_Integer datatype, const Standard_Boolean polyline) const
|
||||
{
|
||||
Standard_Integer num, nb = theXYZ->Length();
|
||||
if (datatype < 1 || datatype > 3 || nb == 0 || (polyline && datatype == 3))
|
||||
Standard_DomainError::Raise ("IGESConvGeom_GeomBuilder : MakeCopiousData");
|
||||
|
||||
Standard_Integer nbd = datatype+1; // 1->2 2->3 et 3->6
|
||||
if (datatype == 3) nbd = 6;
|
||||
Handle(TColStd_HArray1OfReal) data = new TColStd_HArray1OfReal (1,nb*nbd);
|
||||
Standard_Real CZ = 0.;
|
||||
for (num = 1; num <= nb; num ++) {
|
||||
const gp_XYZ& pnt = theXYZ->Value(num);
|
||||
data->SetValue ((num-1)*nbd+1 , pnt.X());
|
||||
data->SetValue ((num-1)*nbd+2 , pnt.Y());
|
||||
if (datatype > 1) data->SetValue ((num-1)*nbd+3 , pnt.Z());
|
||||
else CZ += pnt.Z();
|
||||
if (datatype < 3) continue;
|
||||
const gp_XYZ& vec = theVec->Value(num);
|
||||
data->SetValue ((num-1)*nbd+4 , vec.X());
|
||||
data->SetValue ((num-1)*nbd+5 , vec.Y());
|
||||
data->SetValue ((num-1)*nbd+6 , vec.Z());
|
||||
}
|
||||
if (datatype == 1) CZ /= nb;
|
||||
|
||||
Handle(IGESGeom_CopiousData) res = new IGESGeom_CopiousData;
|
||||
res->Init (datatype,CZ,data);
|
||||
res->SetPolyline (polyline);
|
||||
return res;
|
||||
}
|
||||
|
||||
Handle(TColgp_HArray1OfXY) IGESConvGeom_GeomBuilder::MakeXY () const
|
||||
{
|
||||
Handle(TColgp_HArray1OfXY) res;
|
||||
Standard_Integer num, nb = theXYZ->Length();
|
||||
if (nb == 0) return res;
|
||||
res = new TColgp_HArray1OfXY (1,nb);
|
||||
for (num = 1; num <= nb; num ++) {
|
||||
const gp_XYZ& pnt = theXYZ->Value(num);
|
||||
res->SetValue (num , gp_XY (pnt.X(),pnt.Y()) );
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Handle(TColgp_HArray1OfXYZ) IGESConvGeom_GeomBuilder::MakeXYZ () const
|
||||
{
|
||||
Handle(TColgp_HArray1OfXYZ) res;
|
||||
/*
|
||||
Standard_Integer num, nb = theXYZ->Length();
|
||||
if (nb == 0) return res;
|
||||
res = new TColgp_HArray1OfXYZ (1,nb);
|
||||
for (num = 1; num <= nb; num ++) {
|
||||
res->SetValue (num , theXYZ->Value(num) );
|
||||
}
|
||||
*/
|
||||
SeqToArray(theXYZ,res,TColgp_HArray1OfXYZ);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
gp_Trsf IGESConvGeom_GeomBuilder::Position () const
|
||||
{ return thepos; }
|
||||
|
||||
void IGESConvGeom_GeomBuilder::SetPosition (const gp_Trsf& pos)
|
||||
{ thepos = pos; }
|
||||
|
||||
void IGESConvGeom_GeomBuilder::SetPosition (const gp_Ax3& pos)
|
||||
{
|
||||
gp_Ax3 orig (gp::XOY());
|
||||
gp_Trsf ps;
|
||||
ps.SetTransformation (pos,orig);
|
||||
thepos = ps;
|
||||
}
|
||||
|
||||
void IGESConvGeom_GeomBuilder::SetPosition (const gp_Ax2& pos)
|
||||
{
|
||||
gp_Ax3 a3(pos);
|
||||
SetPosition (a3);
|
||||
}
|
||||
|
||||
void IGESConvGeom_GeomBuilder::SetPosition (const gp_Ax1& pos)
|
||||
{
|
||||
const gp_Pnt& p = pos.Location();
|
||||
const gp_Dir& d = pos.Direction();
|
||||
gp_Ax3 a3 (p,d);
|
||||
SetPosition (a3);
|
||||
}
|
||||
|
||||
Standard_Boolean IGESConvGeom_GeomBuilder::IsIdentity () const
|
||||
{
|
||||
if (thepos.Form() == gp_Identity) return Standard_True;
|
||||
// sinon, regarder de plus pres ...
|
||||
if (!IsTranslation()) return Standard_False;
|
||||
if (!thepos.TranslationPart().IsEqual (gp_XYZ(0.,0.,0.),epsl) )
|
||||
return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean IGESConvGeom_GeomBuilder::IsTranslation () const
|
||||
{
|
||||
if (thepos.Form() == gp_Identity || thepos.Form() == gp_Translation)
|
||||
return Standard_True;
|
||||
// sinon, regarder de plus pres ...
|
||||
|
||||
Standard_Integer i,j;
|
||||
for (i = 1; i <= 3; i ++)
|
||||
for (j = 1; j <= 3; j ++) {
|
||||
Standard_Real cons = (i == j ? 1. : 0.);
|
||||
Standard_Real val = thepos.Value(i,j);
|
||||
if (val > cons + epsa || val < cons - epsa) return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean IGESConvGeom_GeomBuilder::IsZOnly () const
|
||||
{
|
||||
if (!IsTranslation()) return Standard_False;
|
||||
gp_XYZ t = thepos.TranslationPart(); t.SetZ (0.0);
|
||||
if (!t.IsEqual (gp_XYZ(0.,0.,0.),epsl) ) return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
void IGESConvGeom_GeomBuilder::EvalXYZ
|
||||
(const gp_XYZ& val,
|
||||
Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
|
||||
{
|
||||
val.Coord (X,Y,Z);
|
||||
thepos.Inverted().Transforms (X,Y,Z);
|
||||
}
|
||||
|
||||
Handle(IGESGeom_TransformationMatrix)
|
||||
IGESConvGeom_GeomBuilder::MakeTransformation (const Standard_Real unit) const
|
||||
{
|
||||
Handle(TColStd_HArray2OfReal) data = new TColStd_HArray2OfReal (1,3,1,4);
|
||||
Standard_Integer i,j;
|
||||
for (i = 1; i <= 3; i ++)
|
||||
for (j = 1; j <= 4; j ++)
|
||||
data->SetValue (i,j, (j == 4 ? thepos.Value(i,j)/unit : thepos.Value(i,j)) );
|
||||
Handle(IGESGeom_TransformationMatrix) rs = new IGESGeom_TransformationMatrix;
|
||||
rs->Init (data);
|
||||
if (thepos.IsNegative()) rs->SetFormNumber(1);
|
||||
return rs;
|
||||
}
|
Reference in New Issue
Block a user