package Contap
- ---Purpose:
+ ---Purpose:
uses Standard,StdFail,MMgt, GeomAbs, TopAbs, TCollection, gp, TColgp,
math, IntSurf, IntStart, IntWalk,
Geom2d, TColStd, Geom, Adaptor3d, Adaptor2d
+
is
-
- generic class Point;
- generic class Line;
- generic class SurfFunction;
-
- generic class ArcFunction;
-
- generic class SurfProps;
+ class Point;
+
+ class Line;
+
+ class SurfFunction;
+
+ class ArcFunction;
+
+ class SurfProps;
+
+ class Contour;
- generic class ContourGen, ThePoint,TheSequenceOfPoint,TheHSequenceOfPoint,
- TheLine, TheSequenceOfLine,
- TheSurfProps, TheSurfFunction, TheArcFunction,
- TheSearch, TheIWalking, TheSearchInside;
- ---TheLineConstructor;
+ class TheSequenceOfPoint instantiates Sequence from TCollection (Point from Contap);
- class ContAna;
+ class TheHSequenceOfPoint instantiates HSequence from TCollection
+ (Point from Contap,
+ TheSequenceOfPoint from Contap);
+
+ class TheSequenceOfLine instantiates Sequence from TCollection(Line from Contap);
+
+ class TheSearch instantiates SearchOnBoundaries from IntStart
+ (HVertex from Adaptor3d,
+ HCurve2d from Adaptor2d,
+ HCurve2dTool from Contap,
+ HContTool from Contap,
+ TopolTool from Adaptor3d,
+ ArcFunction from Contap);
+
+ class TheIWalking instantiates IWalking from IntWalk
+ (PathPoint from IntSurf,
+ PathPointTool from IntSurf,
+ SequenceOfPathPoint from IntSurf,
+ InteriorPoint from IntSurf,
+ InteriorPointTool from IntSurf,
+ SequenceOfInteriorPoint from IntSurf,
+ HSurface from Adaptor3d,
+ HSurfaceTool from Adaptor3d,
+ SurfFunction from Contap);
+
+ class TheSearchInside instantiates SearchInside from IntStart
+ (HSurface from Adaptor3d,
+ HSurfaceTool from Adaptor3d,
+ TopolTool from Adaptor3d,
+ HContTool from Contap,
+ SurfFunction from Contap);
+
+
+ class ContAna;
enumeration TFunction is
- ContourStd,
- ContourPrs,
- DraftStd,
- DraftPrs
- end TFunction;
+ ContourStd,
+ ContourPrs,
+ DraftStd,
+ DraftPrs
+ end TFunction;
enumeration IType is -- a replacer dans IntSurf et fusionner avec IntPatch
-- type of the line of contour
-
- Lin, -- pour conflit avec deferred class Line
- Circle,
+ Lin, -- pour conflit avec deferred class Line
+ Circle,
Walking,
- Restriction
+ Restriction
end IType;
-
- generic class HContToolGen;
-
- generic class HCurve2dToolGen;
-
- class HCurve2dTool instantiates
- HCurve2dToolGen from Contap (
- HCurve2d from Adaptor2d);
-
- class HContTool instantiates
- HContToolGen from Contap (
- HVertex from Adaptor3d,
- HCurve2d from Adaptor2d,
- HSurface from Adaptor3d,
- HCurve2dTool from Contap,
- HSurfaceTool from Adaptor3d);
-
- class Contour instantiates ContourGen from Contap
- (HVertex from Adaptor3d,
- HCurve2d from Adaptor2d,
- HSurface from Adaptor3d,
- HCurve2dTool from Contap,
- HSurfaceTool from Adaptor3d,
- HContTool from Contap,
- TopolTool from Adaptor3d);
+ class HContTool;
+
+ class HCurve2dTool;
end Contap;
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-generic class ArcFunction from Contap
- (TheArc as any;
- TheSurface as any;
- TheArcTool as any;
- TheSurfaceTool as any;
- TheSurfProps as any; -- as SurfProps from Contap(TheSurface,
- -- TheSurfaceTool)
- TheContTool as any) -- as ContTool from Contap()
-
-
-inherits FunctionWithDerivative from math
+class ArcFunction from Contap inherits FunctionWithDerivative from math
uses Pnt from gp,
Dir from gp,
SequenceOfPnt from TColgp,
TFunction from Contap,
--modified by NIZNHY-PKV Thu Mar 29 16:52:28 2001 f
- Quadric from IntSurf
- --modified by NIZNHY-PKV Thu Mar 29 16:52:31 2001 t
+ Quadric from IntSurf,
+ --modified by NIZNHY-PKV Thu Mar 29 16:52:31 2001
+ HCurve2d from Adaptor2d,
+ HSurface from Adaptor3d,
+ HCurve2dTool from Contap,
+ HSurfaceTool from Adaptor3d,
+ SurfProps from Contap,
+ HContTool from Contap
is
returns ArcFunction from Contap;
- Set(me: in out; S: TheSurface)
+ Set(me: in out; S: HSurface from Adaptor3d)
is static;
is static;
- Set(me: in out; A: TheArc)
+ Set(me: in out; A: HCurve2d from Adaptor2d)
---C++: inline
is static;
fields
- myArc : TheArc;
- mySurf : TheSurface;
+ myArc : HCurve2d from Adaptor2d;
+ mySurf : HSurface from Adaptor3d;
myMean : Real from Standard;
myType : TFunction from Contap;
myDir : Dir from gp;
--- /dev/null
+// Created on: 1993-06-03
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1993-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_ArcFunction.ixx>
+
+#include <Contap_HContTool.hxx>
+#include <Contap_SurfProps.hxx>
+#include <Contap_HCurve2dTool.hxx>
+
+Contap_ArcFunction::Contap_ArcFunction ():
+myMean(1.),
+myType(Contap_ContourStd),
+myDir(0.,0.,1.)
+{}
+
+
+void Contap_ArcFunction::Set(const Handle(Adaptor3d_HSurface)& S)
+{
+ mySurf = S;
+ Standard_Integer i;
+ Standard_Integer nbs = Contap_HContTool::NbSamplePoints(S);
+ Standard_Real U,V;
+ // gp_Vec d1u,d1v;
+ gp_Vec norm;
+ if (nbs > 0) {
+ myMean = 0.;
+ for (i = 1; i <= nbs; i++) {
+ Contap_HContTool::SamplePoint(S,i,U,V);
+ // Adaptor3d_HSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
+ // myMean = myMean + d1u.Crossed(d1v).Magnitude();
+ Contap_SurfProps::Normale(S,U,V,solpt,norm);
+ myMean = myMean + norm.Magnitude();
+ }
+ myMean = myMean / ((Standard_Real)nbs);
+ }
+}
+
+
+Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
+ Standard_Real& F)
+{
+ //gp_Vec d1u,d1v;
+ gp_Pnt2d pt2d(Contap_HCurve2dTool::Value(myArc,U));
+ // Adaptor3d_HSurfaceTool::D1(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v);
+ // gp_Vec norm(d1u.Crossed(d1v));
+ gp_Vec norm;
+ Contap_SurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);
+
+ switch (myType) {
+ case Contap_ContourStd:
+ {
+ F = (norm.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ return Standard_True;
+}
+
+
+Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
+ Standard_Real& D)
+{
+ gp_Pnt2d pt2d;
+ gp_Vec2d d2d;
+ Standard_Real dfu =0.,dfv =0.;
+ // gp_Vec d1u,d1v,d2u,d2v,d2uv;
+ Contap_HCurve2dTool::D1(myArc,U,pt2d,d2d);
+ // Adaptor3d_HSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
+ gp_Vec norm,dnu,dnv;
+ Contap_SurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
+
+ switch (myType) {
+ case Contap_ContourStd:
+ {
+ // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
+ // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
+ dfu = (dnu.Dot(myDir))/myMean;
+ dfv = (dnv.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ gp_Vec Ep(myEye,solpt);
+ // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
+ // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
+ dfu = (dnu.Dot(Ep))/myMean;
+ dfv = (dnv.Dot(Ep))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ /*
+ gp_Vec norm(d1u.Crossed(d1v).Normalized());
+ gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
+ dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
+ dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ */
+ norm.Normalized();
+ dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
+ dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ D = d2d.X()*dfu + d2d.Y()*dfv;
+ return Standard_True;
+}
+
+Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
+ Standard_Real& F,
+ Standard_Real& D)
+{
+ gp_Pnt2d pt2d;
+ gp_Vec2d d2d;
+ Standard_Real dfu =0.,dfv =0.;
+ // gp_Vec d1u,d1v,d2u,d2v,d2uv;
+ Contap_HCurve2dTool::D1(myArc,U,pt2d,d2d);
+ // Adaptor3d_HSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
+ // gp_Vec norm(d1u.Crossed(d1v));
+ gp_Vec norm,dnu,dnv;
+ Contap_SurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
+
+ switch (myType) {
+ case Contap_ContourStd:
+ {
+ F = (norm.Dot(myDir))/myMean;
+ // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
+ // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
+ dfu = (dnu.Dot(myDir))/myMean;
+ dfv = (dnv.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ gp_Vec Ep(myEye,solpt);
+ F = (norm.Dot(Ep))/myMean;
+ // dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
+ // dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
+ dfu = (dnu.Dot(Ep))/myMean;
+ dfv = (dnv.Dot(Ep))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
+ norm.Normalize();
+ /*
+ gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
+ dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
+ dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ */
+ dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
+ dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+
+ D = d2d.X()*dfu + d2d.Y()*dfv;
+ return Standard_True;
+}
+
+Standard_Integer Contap_ArcFunction::GetStateNumber ()
+{
+ seqpt.Append(solpt);
+ return seqpt.Length();
+}
+
+Standard_Integer Contap_ArcFunction::NbSamples () const
+{
+ return Max(Max(Contap_HContTool::NbSamplesU(mySurf,0.,0.),
+ Contap_HContTool::NbSamplesV(mySurf,0.,0.)),
+ Contap_HContTool::NbSamplesOnArc(myArc));
+}
+
+//modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
+//=======================================================================
+//function : Quadric
+//purpose : returns empty Quadric
+//=======================================================================
+const IntSurf_Quadric& Contap_ArcFunction::Quadric() const
+{
+ return(myQuad);
+}
+//modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t
+++ /dev/null
-// Created on: 1993-06-03
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <gp_Pnt2d.hxx>
-#include <gp_Vec2d.hxx>
-
-Contap_ArcFunction::Contap_ArcFunction ():
- myMean(1.),
- myType(Contap_ContourStd),
- myDir(0.,0.,1.)
-{}
-
-
-void Contap_ArcFunction::Set(const TheSurface& S)
-{
- mySurf = S;
- Standard_Integer i;
- Standard_Integer nbs = TheContTool::NbSamplePoints(S);
- Standard_Real U,V;
-// gp_Vec d1u,d1v;
- gp_Vec norm;
- if (nbs > 0) {
- myMean = 0.;
- for (i = 1; i <= nbs; i++) {
- TheContTool::SamplePoint(S,i,U,V);
-// TheSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
-// myMean = myMean + d1u.Crossed(d1v).Magnitude();
- TheSurfProps::Normale(S,U,V,solpt,norm);
- myMean = myMean + norm.Magnitude();
- }
- myMean = myMean / ((Standard_Real)nbs);
- }
-}
-
-
-Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
- Standard_Real& F)
-{
- //gp_Vec d1u,d1v;
- gp_Pnt2d pt2d(TheArcTool::Value(myArc,U));
-// TheSurfaceTool::D1(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v);
-// gp_Vec norm(d1u.Crossed(d1v));
- gp_Vec norm;
- TheSurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);
-
- switch (myType) {
- case Contap_ContourStd:
- {
- F = (norm.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
- F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- return Standard_True;
-}
-
-
-Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
- Standard_Real& D)
-{
- gp_Pnt2d pt2d;
- gp_Vec2d d2d;
- Standard_Real dfu =0.,dfv =0.;
-// gp_Vec d1u,d1v,d2u,d2v,d2uv;
- TheArcTool::D1(myArc,U,pt2d,d2d);
-// TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
- gp_Vec norm,dnu,dnv;
- TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
-
- switch (myType) {
- case Contap_ContourStd:
- {
-// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
-// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
- dfu = (dnu.Dot(myDir))/myMean;
- dfv = (dnv.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- gp_Vec Ep(myEye,solpt);
-// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
-// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
- dfu = (dnu.Dot(Ep))/myMean;
- dfv = (dnv.Dot(Ep))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
-/*
- gp_Vec norm(d1u.Crossed(d1v).Normalized());
- gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
- dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
- dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
- dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
-*/
- norm.Normalized();
- dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
- dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- D = d2d.X()*dfu + d2d.Y()*dfv;
- return Standard_True;
-}
-
-Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
- Standard_Real& F,
- Standard_Real& D)
-{
- gp_Pnt2d pt2d;
- gp_Vec2d d2d;
- Standard_Real dfu =0.,dfv =0.;
-// gp_Vec d1u,d1v,d2u,d2v,d2uv;
- TheArcTool::D1(myArc,U,pt2d,d2d);
-// TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
-// gp_Vec norm(d1u.Crossed(d1v));
- gp_Vec norm,dnu,dnv;
- TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
-
- switch (myType) {
- case Contap_ContourStd:
- {
- F = (norm.Dot(myDir))/myMean;
-// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
-// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
- dfu = (dnu.Dot(myDir))/myMean;
- dfv = (dnv.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- gp_Vec Ep(myEye,solpt);
- F = (norm.Dot(Ep))/myMean;
-// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
-// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
- dfu = (dnu.Dot(Ep))/myMean;
- dfv = (dnv.Dot(Ep))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
- F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
- norm.Normalize();
-/*
- gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
- dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
- dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
- dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
-*/
- dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
- dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
-
- D = d2d.X()*dfu + d2d.Y()*dfv;
- return Standard_True;
-}
-
-Standard_Integer Contap_ArcFunction::GetStateNumber ()
-{
- seqpt.Append(solpt);
- return seqpt.Length();
-}
-
-Standard_Integer Contap_ArcFunction::NbSamples () const
-{
- return Max(Max(TheContTool::NbSamplesU(mySurf,0.,0.),
- TheContTool::NbSamplesV(mySurf,0.,0.)),
- TheContTool::NbSamplesOnArc(myArc));
-}
-
-//modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
-//=======================================================================
-//function : Quadric
-//purpose : returns empty Quadric
-//=======================================================================
- const IntSurf_Quadric& Contap_ArcFunction::Quadric() const
-{
- return(myQuad);
-}
-//modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t
myEye = Eye;
}
-inline void Contap_ArcFunction::Set(const TheArc& A)
+inline void Contap_ArcFunction::Set(const Handle(Adaptor2d_HCurve2d)& A)
{
myArc = A;
seqpt.Clear();
--- /dev/null
+-- Created on: 1993-02-05
+-- Created by: Jacques GOUSSARD
+-- Copyright (c) 1993-1999 Matra Datavision
+-- Copyright (c) 1999-2014 OPEN CASCADE SAS
+--
+-- This file is part of Open CASCADE Technology software library.
+--
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
+-- by the Free Software Foundation, with special exception defined in the file
+-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+-- distribution for complete text of the license and disclaimer of any warranty.
+--
+-- Alternatively, this file may be used under the terms of Open CASCADE
+-- commercial license or contractual agreement.
+
+class Contour from Contap
+
+uses PathPoint from IntSurf,
+ PathPointTool from IntSurf,
+ SequenceOfPathPoint from IntSurf,
+ InteriorPoint from IntSurf,
+ InteriorPointTool from IntSurf,
+ SequenceOfInteriorPoint from IntSurf,
+ Pnt from gp,
+ Vec from gp,
+ Point from Contap,
+ Line from Contap,
+ SurfFunction from Contap,
+ ArcFunction from Contap,
+ TheSequenceOfLine from Contap,
+ TheSearch from Contap,
+ TheSearchInside from Contap,
+ HSurface from Adaptor3d,
+ TopolTool from Adaptor3d
+
+
+raises NotDone from StdFail,
+ OutOfRange from Standard,
+ ConstructionError from Standard
+
+
+is
+
+ Create
+
+ returns Contour from Contap;
+
+
+ Create(Direction: Vec from gp)
+
+ returns Contour from Contap;
+
+
+ Create(Direction: Vec from gp; Angle: Real from Standard)
+
+ returns Contour from Contap;
+
+
+ Create(Eye: Pnt from gp)
+
+ returns Contour from Contap;
+
+
+ Create(Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d;
+ Direction: Vec from gp)
+
+ ---Purpose: Creates the contour in a given direction.
+
+ returns Contour from Contap;
+
+
+ Create(Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d;
+ Direction: Vec from gp; Angle: Real from Standard)
+
+ ---Purpose: Creates the contour in a given direction.
+
+ returns Contour from Contap;
+
+
+ Create(Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d;
+ Eye: Pnt from gp)
+
+ ---Purpose: Creates the contour for a perspective view.
+
+ returns Contour from Contap;
+
+
+ Perform(me: in out; Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d)
+
+ ---Purpose: Creates the contour in a given direction.
+
+ raises ConstructionError from Standard
+ is static;
+
+
+ Perform(me: in out; Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d;
+ Direction: Vec from gp)
+
+ ---Purpose: Creates the contour in a given direction.
+
+ is static;
+
+
+ Perform(me: in out; Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d;
+ Direction: Vec from gp; Angle: Real from Standard)
+
+ ---Purpose: Creates the contour in a given direction.
+
+ is static;
+
+
+ Perform(me: in out; Surf: HSurface from Adaptor3d; Domain: TopolTool from Adaptor3d;
+ Eye: Pnt from gp)
+
+ ---Purpose: Creates the contour for a perspective view.
+
+ is static;
+
+
+ Init(me: in out; Direction: Vec from gp)
+
+ is static;
+
+
+ Init(me: in out; Direction: Vec from gp; Angle: Real from Standard)
+
+ is static;
+
+
+ Init(me: in out; Eye: Pnt from gp)
+
+ is static;
+
+
+ IsDone(me)
+
+ returns Boolean from Standard
+ ---C++: inline
+
+ is static;
+
+
+ IsEmpty(me)
+
+ ---Purpose: Returns true if the is no line.
+
+ returns Boolean from Standard
+ ---C++: inline
+
+ raises NotDone from StdFail
+
+ is static;
+
+
+ NbLines(me)
+
+ returns Integer from Standard
+ ---C++: inline
+
+ raises NotDone from StdFail
+
+ is static;
+
+
+ Line(me; Index: Integer from Standard)
+
+ returns Line from Contap
+ ---C++: return const&
+ ---C++: inline
+
+ raises NotDone from StdFail,
+ OutOfRange from Standard
+
+ is static;
+
+
+ SurfaceFunction(me : in out)
+ returns SurfFunction
+ ---Purpose: Returns a reference on the internal
+ -- SurfaceFunction. This is used to compute tangents
+ -- on the lines.
+ ---C++: return &
+ ---C++: inline
+ is static;
+
+
+ Perform(me: in out; Domain: TopolTool from Adaptor3d)
+
+ is static private;
+
+
+ PerformAna(me: in out; Domain: TopolTool from Adaptor3d)
+
+ is static private;
+
+
+fields
+
+ done : Boolean from Standard;
+ slin : TheSequenceOfLine from Contap;
+ solrst : TheSearch from Contap;
+ solins : TheSearchInside from Contap;
+ mySFunc : SurfFunction from Contap;
+ myAFunc : ArcFunction from Contap;
+ modeset : Boolean from Standard;
+
+end Contour;
--- /dev/null
+// Created on: 1993-02-05
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1993-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_Contour.ixx>
+
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+
+#include <math_FunctionSetRoot.hxx>
+
+#include <IntSurf.hxx>
+#include <IntSurf_InteriorPoint.hxx>
+#include <IntSurf_SequenceOfPathPoint.hxx>
+
+#include <TopTrans_CurveTransition.hxx>
+
+#include <TColStd_Array1OfInteger.hxx>
+
+#include <BndLib_AddSurface.hxx>
+#include <Bnd_Box.hxx>
+
+#include <Adaptor3d_HSurfaceTool.hxx>
+
+#include <Contap_ContAna.hxx>
+#include <Contap_HContTool.hxx>
+#include <Contap_HCurve2dTool.hxx>
+#include <Contap_SurfProps.hxx>
+#include <Contap_TheIWalking.hxx>
+#include <Contap_TheSegmentOfTheSearch.hxx>
+#include <Contap_ThePathPointOfTheSearch.hxx>
+
+#define Tolpetit 1.e-10 // pour dist au carre
+
+#define tole 5.e-6
+
+Contap_Contour::Contap_Contour () :
+done(Standard_False),modeset(Standard_False)
+{}
+
+Contap_Contour::Contap_Contour (const gp_Vec& Direction) :
+
+done(Standard_False),modeset(Standard_True)
+{
+ mySFunc.Set(Direction);
+ myAFunc.Set(Direction);
+}
+
+
+Contap_Contour::Contap_Contour (const gp_Vec& Direction,
+ const Standard_Real Angle) :
+
+done(Standard_False),modeset(Standard_True)
+{
+ mySFunc.Set(Direction,Angle);
+ myAFunc.Set(Direction,Angle);
+}
+
+Contap_Contour::Contap_Contour (const gp_Pnt& Eye) :
+
+done(Standard_False),modeset(Standard_True)
+{
+ mySFunc.Set(Eye);
+ myAFunc.Set(Eye);
+}
+
+
+Contap_Contour::Contap_Contour (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ const gp_Vec& Direction) :
+
+done(Standard_False),modeset(Standard_True)
+{
+ Perform(Surf,Domain,Direction);
+}
+
+
+Contap_Contour::Contap_Contour (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ const gp_Vec& Direction,
+ const Standard_Real Angle) :
+
+done(Standard_False),modeset(Standard_True)
+{
+ Perform(Surf,Domain,Direction,Angle);
+}
+
+
+Contap_Contour::Contap_Contour (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ const gp_Pnt& Eye) :
+
+done(Standard_False),modeset(Standard_True)
+{
+ Perform(Surf,Domain,Eye);
+}
+
+
+void Contap_Contour::Init (const gp_Vec& Direction)
+
+{
+ done = Standard_False;
+ modeset = Standard_True;
+ mySFunc.Set(Direction);
+ myAFunc.Set(Direction);
+}
+
+
+void Contap_Contour::Init(const gp_Vec& Direction,
+ const Standard_Real Angle)
+{
+ done = Standard_False;
+ modeset = Standard_True;
+ mySFunc.Set(Direction,Angle);
+ myAFunc.Set(Direction,Angle);
+}
+
+void Contap_Contour::Init (const gp_Pnt& Eye)
+{
+ done = Standard_False;
+ modeset = Standard_True;
+ mySFunc.Set(Eye);
+ myAFunc.Set(Eye);
+}
+
+
+void Contap_Contour::Perform (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain)
+{
+ if (!modeset) {Standard_ConstructionError::Raise();}
+ mySFunc.Set(Surf);
+ myAFunc.Set(Surf);
+
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(Surf);
+ switch (typS) {
+ case GeomAbs_Plane:
+ case GeomAbs_Sphere:
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ {
+ PerformAna(Domain); //Surf,Domain,Direction,0.,gp_Pnt(0.,0.,0.),1);
+ }
+ break;
+
+ default:
+ {
+ Perform(Domain); //Surf,Domain,Direction,0.,gp_Pnt(0.,0.,0.),1);
+ }
+ break;
+ }
+
+}
+
+
+void Contap_Contour::Perform (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ const gp_Vec& Direction)
+
+{
+ Init(Direction);
+ Perform(Surf,Domain);
+}
+
+void Contap_Contour::Perform (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ const gp_Vec& Direction,
+ const Standard_Real Angle)
+
+{
+ Init(Direction,Angle);
+ Perform(Surf,Domain);
+}
+
+
+void Contap_Contour::Perform (const Handle(Adaptor3d_HSurface)& Surf,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ const gp_Pnt& Eye)
+
+{
+ Init(Eye);
+ Perform(Surf,Domain);
+}
+
+static IntSurf_TypeTrans ComputeTransitionOnLine
+(Contap_SurfFunction&,
+ const Standard_Real,
+ const Standard_Real,
+ const gp_Vec&);
+
+
+static IntSurf_TypeTrans ComputeTransitionOngpCircle
+(Contap_SurfFunction&,
+ const gp_Circ&);
+
+
+static IntSurf_TypeTrans ComputeTransitionOngpLine
+(Contap_SurfFunction&,
+ const gp_Lin&);
+
+
+static void ComputeInternalPoints
+(Contap_Line& Line,
+ Contap_SurfFunction&,
+ const Standard_Real ureso,
+ const Standard_Real vreso);
+
+
+static void ComputeInternalPointsOnRstr
+(Contap_Line&,
+ const Standard_Real,
+ const Standard_Real,
+ Contap_SurfFunction&);
+
+static void ProcessSegments (const Contap_TheSearch&,
+ Contap_TheSequenceOfLine&,
+ const Standard_Real,
+ Contap_SurfFunction&,
+ const Handle(Adaptor3d_TopolTool)&);
+
+//-- --------------------------------------------------------------------------------
+//-- Recherche des portions utiles sur les lignes
+
+
+static void Recadre(const Handle(Adaptor3d_HSurface)& myHS1,
+ Standard_Real& u1,
+ Standard_Real& v1) {
+ Standard_Real f,l,lmf;
+ GeomAbs_SurfaceType typs1 = myHS1->GetType();
+
+ Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
+ switch (typs1) {
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ {
+ myHS1IsUPeriodic = Standard_True;
+ myHS1IsVPeriodic = Standard_False;
+ break;
+ }
+ case GeomAbs_Torus:
+ {
+ myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True;
+ break;
+ }
+ default:
+ {
+ myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False;
+ break;
+ }
+ }
+ if(myHS1IsUPeriodic) {
+ lmf = M_PI+M_PI; //-- myHS1->UPeriod();
+ f = myHS1->FirstUParameter();
+ l = myHS1->LastUParameter();
+ while(u1 < f) { u1+=lmf; }
+ while(u1 > l) { u1-=lmf; }
+ }
+ if(myHS1IsVPeriodic) {
+ lmf = M_PI+M_PI; //-- myHS1->VPeriod();
+ f = myHS1->FirstVParameter();
+ l = myHS1->LastVParameter();
+ while(v1 < f) { v1+=lmf; }
+ while(v1 > l) { v1-=lmf; }
+ }
+}
+
+
+static void LineConstructor(Contap_TheSequenceOfLine& slin,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ Contap_Line& L,
+ const Handle(Adaptor3d_HSurface)& Surf) {
+
+ //-- ------------------------------------------------------------
+ //-- on decoupe la ligne en portions entre 2 vertex
+ Standard_Real Tol = Precision::PConfusion();
+ Contap_IType typl = L.TypeContour();
+ //-- cout<<"\n ----------- Ligne Constructor "<<endl;
+ if(typl == Contap_Walking) {
+ Standard_Real u1,v1,u2,v2;
+ Standard_Integer nbvtx = L.NbVertex();
+ //-- cout<<" WLine -> "<<nbvtx<<" vtx"<<endl;
+ for(Standard_Integer i=1;i<nbvtx;i++) {
+ Standard_Integer firstp = (Standard_Integer) L.Vertex(i).ParameterOnLine();
+ Standard_Integer lastp = (Standard_Integer) L.Vertex(i+1).ParameterOnLine();
+ if(firstp!=lastp) {
+ Standard_Integer pmid = (firstp+lastp)/2; //-- entiers
+ const IntSurf_PntOn2S& Pmid = L.Point(pmid);
+ Pmid.Parameters(u1,v1,u2,v2);
+ Recadre(Surf,u2,v2);
+ TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
+ if(in2 == TopAbs_OUT) {
+ }
+ else {
+ //-- cout<<"ContapWLine : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
+ Handle(IntSurf_LineOn2S) LineOn2S = new IntSurf_LineOn2S();
+ Contap_Line Line;
+ for(Standard_Integer j=firstp; j<=lastp; j++) {
+ LineOn2S->Add(L.Point(j));
+ }
+ Line.SetLineOn2S(LineOn2S);
+ Contap_Point pvtx = L.Vertex(i);
+ pvtx.SetParameter(1);
+ Line.Add(pvtx);
+
+ pvtx = L.Vertex(i+1);
+ pvtx.SetParameter(lastp-firstp+1);
+ Line.Add(pvtx);
+ Line.SetTransitionOnS(L.TransitionOnS());
+ slin.Append(Line);
+ }
+ }
+ }
+ }
+ else if(typl==Contap_Lin) {
+ Standard_Real u2,v2;// u1,v1;
+ Standard_Integer nbvtx = L.NbVertex();
+ //-- cout<<" Lin -> "<<nbvtx<<" vtx"<<endl;
+ for(Standard_Integer i=1;i<nbvtx;i++) {
+ Standard_Real firstp = L.Vertex(i).ParameterOnLine();
+ Standard_Real lastp = L.Vertex(i+1).ParameterOnLine();
+ if(firstp!=lastp) {
+ Standard_Real pmid = (firstp+lastp)*0.5;
+ gp_Pnt Pmid = ElCLib::Value(pmid,L.Line());
+ if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Cylinder) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cylinder(Surf),Pmid,u2,v2);
+ }
+ else if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Cone) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cone(Surf),Pmid,u2,v2);
+ }
+ else {
+ //-- cout<<" Pb ds Contap_ContourGen_2.gxx (type)"<<endl;
+ }
+
+ Recadre(Surf,u2,v2);
+ TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
+ if(in2 == TopAbs_OUT) {
+ }
+ else {
+ //-- cout<<"Contap Lin : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
+ Contap_Line Line;
+ Line.SetValue(L.Line());
+ Contap_Point pvtx = L.Vertex(i);
+ Line.Add(pvtx);
+
+ pvtx = L.Vertex(i+1);
+ Line.Add(pvtx);
+ Line.SetTransitionOnS(L.TransitionOnS());
+ slin.Append(Line);
+ }
+ }
+ }
+ }
+ else if(typl==Contap_Circle) {
+ Standard_Real u2,v2; //u1,v1,
+ Standard_Integer nbvtx = L.NbVertex();
+ //-- cout<<" Circ -> "<<nbvtx<<" vtx"<<endl;
+ Standard_Boolean novtx = Standard_True;
+ if(nbvtx) novtx=Standard_False;
+ for(Standard_Integer i=1;i<nbvtx || novtx;i++) {
+ Standard_Real firstp=0,lastp=M_PI+M_PI;
+ if(novtx == Standard_False) {
+ firstp = L.Vertex(i).ParameterOnLine();
+ lastp = L.Vertex(i+1).ParameterOnLine();
+ }
+ if(Abs(firstp-lastp)>0.000000001) {
+ Standard_Real pmid = (firstp+lastp)*0.5;
+ gp_Pnt Pmid = ElCLib::Value(pmid,L.Circle());
+ if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Cylinder) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cylinder(Surf),Pmid,u2,v2);
+ }
+ else if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Cone) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cone(Surf),Pmid,u2,v2);
+ }
+ else if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Sphere) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Sphere(Surf),Pmid,u2,v2);
+ }
+ else {
+ //-- cout<<" Pb ds Contap_ContourGen_2.gxx (typep)"<<endl;
+ }
+
+ Recadre(Surf,u2,v2);
+ TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
+ if(in2 == TopAbs_OUT) {
+ }
+ else {
+ //-- cout<<"Contap Circle : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
+ Contap_Line Line;
+ Line.SetValue(L.Circle());
+ if(novtx == Standard_False) {
+ Contap_Point pvtx = L.Vertex(i);
+ Line.Add(pvtx);
+ pvtx = L.Vertex(i+1);
+ Line.Add(pvtx);
+ }
+ Line.SetTransitionOnS(L.TransitionOnS());
+ slin.Append(Line);
+ }
+ }
+ novtx = Standard_False;
+ }
+ if(nbvtx) {
+ Standard_Real firstp = L.Vertex(nbvtx).ParameterOnLine();
+ Standard_Real lastp = L.Vertex(1).ParameterOnLine() + M_PI+M_PI;
+ if(Abs(firstp-lastp)>0.0000000001) {
+ Standard_Real pmid = (firstp+lastp)*0.5;
+ gp_Pnt Pmid = ElCLib::Value(pmid,L.Circle());
+ if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Cylinder) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cylinder(Surf),Pmid,u2,v2);
+ }
+ else if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Cone) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cone(Surf),Pmid,u2,v2);
+ }
+ else if(Adaptor3d_HSurfaceTool::GetType(Surf)==GeomAbs_Sphere) {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Sphere(Surf),Pmid,u2,v2);
+ }
+ else {
+ //-- cout<<" Pb ds Contap_ContourGen_2.gxx (typep)"<<endl;
+ }
+
+ Recadre(Surf,u2,v2);
+ TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
+ if(in2 == TopAbs_OUT) {
+ }
+ else {
+ //-- cout<<"Contap Circle *Compl* : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
+ Contap_Line Line;
+ Line.SetValue(L.Circle());
+ Contap_Point pvtx = L.Vertex(nbvtx);
+ Line.Add(pvtx);
+
+ pvtx = L.Vertex(1); pvtx.SetParameter(pvtx.ParameterOnLine()+M_PI+M_PI);
+ Line.Add(pvtx);
+ Line.SetTransitionOnS(L.TransitionOnS());
+ slin.Append(Line);
+ }
+ }
+ }
+ }
+ else {
+ //-- cout<<" ni WLine ni Lin ni Circ "<<endl;
+ slin.Append(L);
+ }
+ //--
+}
+
+//-- --------------------------------------------------------------------------------
+
+
+
+static void KeepInsidePoints(const Contap_TheSearchInside& solins,
+ const Contap_TheSearch& solrst,
+ Contap_SurfFunction& Func,
+ IntSurf_SequenceOfInteriorPoint& seqpins)
+
+{
+ Standard_Integer Nba = solrst.NbSegments();
+ if (Nba <= 0) return;
+ Standard_Integer Nbp,indp,inda;
+ Standard_Real U,V,paramproj;
+ gp_Pnt2d toproj,Ptproj;
+ Standard_Boolean projok,tokeep;
+ const Handle(Adaptor3d_HSurface)& Surf = Func.Surface();
+
+ Nbp = solins.NbPoints();
+ for (indp=1; indp <= Nbp; indp++) {
+ tokeep = Standard_True;
+ const IntSurf_InteriorPoint& pti = solins.Value(indp);
+ pti.Parameters(U,V);
+ toproj = gp_Pnt2d(U,V);
+ for (inda = 1; inda <= Nba; inda++) {
+ const Handle(Adaptor2d_HCurve2d)& thearc = solrst.Segment(inda).Curve();
+ projok = Contap_HContTool::Project(thearc,toproj,paramproj,Ptproj);
+ if (projok) {
+ gp_Pnt pprojete = Adaptor3d_HSurfaceTool::Value(Surf,Ptproj.X(),Ptproj.Y());
+ if (pti.Value().Distance(pprojete) <= Precision::Confusion()) {
+ tokeep = Standard_False;
+ break;
+ }
+ }
+ }
+ if (tokeep) {
+ seqpins.Append(pti);
+ }
+ }
+}
+
+
+static void ComputeTangency (const Contap_TheSearch& solrst,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ Contap_SurfFunction& Func,
+ IntSurf_SequenceOfPathPoint& seqpdep,
+ TColStd_Array1OfInteger& Destination)
+{
+
+ Standard_Integer i,k;
+ Standard_Integer NbPoints = solrst.NbPoints();
+ Standard_Integer seqlength = 0;
+
+ Standard_Real theparam,test;
+ Standard_Boolean fairpt;
+ TopAbs_Orientation arcorien,vtxorien;
+ Standard_Boolean ispassing;
+
+ math_Vector X(1, 2);
+ math_Vector F(1, 1);
+ math_Matrix D(1, 1, 1, 2);
+
+ gp_Vec normale, vectg, tg3drst,v1,v2;
+ gp_Dir2d dirtg;
+ gp_Vec2d tg2drst;
+ gp_Pnt2d pt2d;
+
+ IntSurf_PathPoint PPoint;
+ const Handle(Adaptor3d_HSurface)& Surf = Func.Surface();
+
+ for (i=1; i<= NbPoints; i++) {
+
+ if (Destination(i) == 0) {
+
+ const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
+ const Handle(Adaptor2d_HCurve2d)& thearc = PStart.Arc();
+ theparam = PStart.Parameter();
+ gp_Pnt2d Ptoproj=Contap_HCurve2dTool::Value(thearc,theparam);
+ //-- lbr le 15 mai 97
+ //-- On elimine les points qui sont egalement present sur une restriction solution
+ Standard_Boolean SurUneRestrictionSolution = Standard_False;
+ for(Standard_Integer restriction=1;
+ SurUneRestrictionSolution==Standard_False && restriction<=solrst.NbSegments();
+ restriction++) {
+ const Handle(Adaptor2d_HCurve2d)& thearcsol = solrst.Segment(restriction).Curve();
+ Standard_Real paramproj;
+ gp_Pnt2d pproj;
+ Standard_Boolean projok = Contap_HContTool::Project(thearcsol,Ptoproj,paramproj,pproj);
+ if(projok) {
+ //gp_Pnt pprojete = Adaptor3d_HSurfaceTool::Value(Surf,Ptoproj.X(),Ptoproj.Y());
+ //IFV - begin
+ gp_Pnt pprojete = Adaptor3d_HSurfaceTool::Value(Surf,pproj.X(),pproj.Y());
+ //IFV - end
+ if ((PStart.Value()).Distance(pprojete) <= Precision::Confusion()) {
+ SurUneRestrictionSolution = Standard_True;
+ }
+ }
+ }
+ if(SurUneRestrictionSolution == Standard_False) {
+ arcorien = Domain->Orientation(thearc);
+ ispassing = (arcorien == TopAbs_INTERNAL ||
+ arcorien == TopAbs_EXTERNAL);
+
+ Contap_HCurve2dTool::D1(thearc,theparam,pt2d,tg2drst);
+ X(1) = pt2d.X();
+ X(2) = pt2d.Y();
+ PPoint.SetValue(PStart.Value(),X(1),X(2));
+
+ Func.Values(X,F,D);
+ if (Func.IsTangent()) {
+ PPoint.SetTangency(Standard_True);
+ Destination(i) = seqlength+1;
+ if (!PStart.IsNew()) {
+ const Handle(Adaptor3d_HVertex)& vtx = PStart.Vertex();
+ for (k=i+1; k<=NbPoints; k++) {
+ if (Destination(k) ==0) {
+ const Contap_ThePathPointOfTheSearch& PStart2 = solrst.Point(k);
+ if (!PStart2.IsNew()) {
+ const Handle(Adaptor3d_HVertex)& vtx2 = PStart2.Vertex();
+ if (Domain->Identical(vtx,vtx2)) {
+ const Handle(Adaptor2d_HCurve2d)& thearc2 = PStart2.Arc();
+ theparam = PStart2.Parameter();
+ arcorien = Domain->Orientation(thearc2);
+ ispassing = ispassing && (arcorien == TopAbs_INTERNAL ||
+ arcorien == TopAbs_EXTERNAL);
+
+ pt2d = Contap_HCurve2dTool::Value(thearc2,theparam);
+ X(1) = pt2d.X();
+ X(2) = pt2d.Y();
+ PPoint.AddUV(X(1),X(2));
+ Destination(k) = seqlength+1;
+ }
+ }
+ }
+ }
+ }
+ PPoint.SetPassing(ispassing);
+ seqpdep.Append(PPoint);
+ seqlength++;
+ }
+ else { // on a un point de depart potentiel
+
+ vectg = Func.Direction3d();
+ dirtg = Func.Direction2d();
+
+ gp_Pnt ptbid;
+ // Adaptor3d_HSurfaceTool::D1(Surf,X(1),X(2),ptbid,v1,v2);
+ Contap_SurfProps::DerivAndNorm(Surf,X(1),X(2),ptbid,v1,v2,normale);
+ tg3drst = tg2drst.X()*v1 + tg2drst.Y()*v2;
+ // normale = v1.Crossed(v2);
+ if(normale.SquareMagnitude() < RealEpsilon()) {
+ //-- cout<<"\n*** Contap_ContourGen_2.gxx Normale Nulle en U:"<<X(1)<<" V:"<<X(2)<<endl;
+ }
+ else {
+ test = vectg.Dot(normale.Crossed(tg3drst));
+
+ if (PStart.IsNew()) {
+ Standard_Real tbis = vectg.Normalized().Dot(tg3drst.Normalized());
+ if (Abs(tbis) < 1.-tole) {
+
+ if ((test < 0. && arcorien == TopAbs_FORWARD) ||
+ (test > 0. && arcorien == TopAbs_REVERSED)) {
+ vectg.Reverse();
+ dirtg.Reverse();
+ }
+ PPoint.SetDirections(vectg,dirtg);
+ }
+ else { // on garde le point comme point d`arret (tangent)
+ PPoint.SetTangency(Standard_True);
+ }
+ PPoint.SetPassing(ispassing);
+ Destination(i) = seqlength+1;
+ seqpdep.Append(PPoint);
+ seqlength++;
+ }
+ else { // traiter la transition complexe
+ gp_Dir bidnorm(1.,1.,1.);
+
+ Standard_Boolean tobeverified = Standard_False;
+ TopAbs_Orientation LocTrans;
+ TopTrans_CurveTransition comptrans;
+ comptrans.Reset(vectg,bidnorm,0.);
+ if (arcorien != TopAbs_INTERNAL &&
+ arcorien != TopAbs_EXTERNAL) {
+ // pour essai
+ const Handle(Adaptor3d_HVertex)& vtx = PStart.Vertex();
+ vtxorien = Domain->Orientation(vtx);
+ test = test/(vectg.Magnitude());
+ test = test/((normale.Crossed(tg3drst)).Magnitude());
+
+ if (Abs(test) <= tole) {
+ tobeverified = Standard_True;
+ LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
+ }
+ else {
+ if ((test > 0. && arcorien == TopAbs_FORWARD) ||
+ (test < 0. && arcorien == TopAbs_REVERSED)){
+ LocTrans = TopAbs_FORWARD;
+ }
+ else {
+ LocTrans = TopAbs_REVERSED;
+ }
+ if (arcorien == TopAbs_REVERSED) {tg3drst.Reverse();} // pas deja fait ???
+ }
+
+ comptrans.Compare(tole,tg3drst,bidnorm,0.,LocTrans,vtxorien);
+ }
+ Destination(i) = seqlength+1;
+ for (k= i+1; k<=NbPoints; k++) {
+ if (Destination(k) == 0) {
+ const Contap_ThePathPointOfTheSearch& PStart2 = solrst.Point(k);
+ if (!PStart2.IsNew()) {
+ const Handle(Adaptor3d_HVertex)& vtx2 = PStart2.Vertex();
+ if (Domain->Identical(PStart.Vertex(),vtx2)) {
+ const Handle(Adaptor2d_HCurve2d)& thearc2 = PStart2.Arc();
+ theparam = PStart2.Parameter();
+ arcorien = Domain->Orientation(thearc2);
+
+ Contap_HCurve2dTool::D1(thearc2,theparam,pt2d,tg2drst);
+ X(1) = pt2d.X();
+ X(2) = pt2d.Y();
+ PPoint.AddUV(X(1),X(2));
+
+ if (arcorien != TopAbs_INTERNAL &&
+ arcorien != TopAbs_EXTERNAL) {
+ ispassing = Standard_False;
+ tg3drst = tg2drst.X()*v1 + tg2drst.Y()*v2;
+ test = vectg.Dot(normale.Crossed(tg3drst));
+ test = test/(vectg.Magnitude());
+ test = test /((normale.Crossed(tg3drst)).Magnitude());
+
+ vtxorien = Domain->Orientation(vtx2);
+ if (Abs(test) <= tole) {
+ tobeverified = Standard_True;
+ LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
+ }
+ else {
+ if ((test > 0. && arcorien == TopAbs_FORWARD) ||
+ (test < 0. && arcorien == TopAbs_REVERSED)){
+ LocTrans = TopAbs_FORWARD;
+ }
+ else {
+ LocTrans = TopAbs_REVERSED;
+ }
+ if (arcorien == TopAbs_REVERSED) {tg3drst.Reverse();} //deja fait????
+ }
+
+ comptrans.Compare(tole,tg3drst,bidnorm,0.,LocTrans,vtxorien);
+ }
+ Destination(k) = seqlength+1;
+ }
+ }
+ }
+ }
+ fairpt = Standard_True;
+ if (!ispassing) {
+ TopAbs_State Before = comptrans.StateBefore();
+ TopAbs_State After = comptrans.StateAfter();
+ if ((Before == TopAbs_UNKNOWN)||(After == TopAbs_UNKNOWN)) {
+ fairpt = Standard_False;
+ }
+ else if (Before == TopAbs_IN) {
+ if (After == TopAbs_IN) {
+ ispassing = Standard_True;
+ }
+ else {
+ vectg.Reverse();
+ dirtg.Reverse();
+ }
+ }
+ else {
+ if (After !=TopAbs_IN) {
+ fairpt = Standard_False;
+ }
+ }
+ }
+
+ // evite de partir le long d une restriction solution
+
+ if (fairpt && tobeverified) {
+ for (k=i; k <=NbPoints ; k++) {
+ if (Destination(k)==seqlength + 1) {
+ theparam = solrst.Point(k).Parameter();
+ const Handle(Adaptor2d_HCurve2d)& thearc2 = solrst.Point(k).Arc();
+ arcorien = Domain->Orientation(thearc2);
+
+ if (arcorien == TopAbs_FORWARD ||
+ arcorien == TopAbs_REVERSED) {
+ Contap_HCurve2dTool::D1(thearc2,theparam,pt2d,tg2drst);
+ tg3drst = tg2drst.X()*v1 + tg2drst.Y()*v2;
+ vtxorien = Domain->Orientation(solrst.Point(k).Vertex());
+ if ((arcorien == TopAbs_FORWARD &&
+ vtxorien == TopAbs_REVERSED) ||
+ (arcorien == TopAbs_REVERSED &&
+ vtxorien == TopAbs_FORWARD)) {
+ tg3drst.Reverse();
+ }
+ test = vectg.Normalized().Dot(tg3drst.Normalized());
+ if (test >= 1. - tole) {
+ fairpt = Standard_False;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (fairpt) {
+ PPoint.SetDirections(vectg,dirtg);
+ PPoint.SetPassing(ispassing);
+ seqpdep.Append(PPoint);
+ seqlength++;
+ }
+ else { // il faut remettre en "ordre" si on ne garde pas le point.
+ for (k=i; k <=NbPoints ; k++) {
+ if (Destination(k)==seqlength + 1) {
+ Destination(k) = -Destination(k);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+IntSurf_TypeTrans ComputeTransitionOnLine(Contap_SurfFunction& SFunc,
+ const Standard_Real u,
+ const Standard_Real v,
+ const gp_Vec& tgline)
+{
+ gp_Vec d1u,d1v;
+ gp_Pnt pntbid;
+ //gp_Vec tglineuv;
+
+ Adaptor3d_HSurfaceTool::D1(SFunc.Surface(),u,v,pntbid,d1u,d1v);
+
+ //------------------------------------------------------
+ //-- Calcul de la tangente dans l espace uv ---
+ //------------------------------------------------------
+
+ Standard_Real det,d1uT,d1vT,normu2,normv2,d1ud1v,alpha,beta;
+ d1uT = d1u.Dot(tgline);
+ d1vT = d1v.Dot(tgline);
+ normu2 = d1u.Dot(d1u);
+ normv2 = d1v.Dot(d1v);
+ d1ud1v = d1u.Dot(d1v);
+ det = normu2 * normv2 - d1ud1v * d1ud1v;
+ if(det<RealEpsilon()) {
+ //-- On ne doit pas passer ici !!
+ //-- cout<<" Probleme !!!"<<endl ;
+ return IntSurf_Undecided;
+ }
+
+ alpha = (d1uT * normv2 - d1vT * d1ud1v)/det;
+ beta = (normu2 * d1vT - d1ud1v * d1uT)/det;
+ //-----------------------------------------------------
+ //-- Calcul du Gradient de la fonction Utilisee --
+ //-- pour le contour apparent --
+ //-----------------------------------------------------
+
+ Standard_Real v1,v2;
+ math_Vector X(1,2);
+ math_Matrix Df(1,1,1,2);
+ X(1) = u;
+ X(2) = v;
+ SFunc.Derivatives(X,Df);
+ v1 = Df(1,1);
+ v2 = Df(1,2);
+
+ //-----------------------------------------------------
+ //-- On calcule si la fonction --
+ //-- F(.) = Normale . Dir_Regard --
+ //-- Croit Losrque l on se deplace sur la Gauche --
+ //-- de la direction de deplacement sur la ligne. --
+ //-----------------------------------------------------
+
+ det = -v1*beta + v2*alpha;
+
+ if(det<RealEpsilon()) { // revoir le test jag 940620
+ return IntSurf_Undecided;
+ }
+ if(det>0.0) {
+ return(IntSurf_Out);
+ }
+ return(IntSurf_In);
+}
+
+
+void ProcessSegments (const Contap_TheSearch& solrst,
+ Contap_TheSequenceOfLine& slin,
+ const Standard_Real TolArc,
+ Contap_SurfFunction& SFunc,
+ const Handle(Adaptor3d_TopolTool)& Domain)
+
+{
+ Standard_Integer i,j,k;
+ Standard_Integer nbedg = solrst.NbSegments();
+ Standard_Integer Nblines,Nbpts;
+
+ Handle(Adaptor2d_HCurve2d) arcRef;
+ Contap_Point ptvtx;
+
+ Contap_ThePathPointOfTheSearch PStartf,PStartl;
+
+ Standard_Boolean dofirst,dolast,procf,procl;
+ Standard_Real paramf =0.,paraml =0.,U;
+ Contap_Line theline;
+
+ gp_Vec tgline;//,norm1,norm2;
+ gp_Pnt valpt;
+
+ gp_Vec d1u,d1v;
+ gp_Pnt2d p2d;
+ gp_Vec2d d2d;
+
+
+ for (i = 1; i <= nbedg; i++) {
+
+ const Contap_TheSegmentOfTheSearch& thesegsol = solrst.Segment(i);
+ theline.SetValue(thesegsol.Curve());
+
+ // Traitement des points debut/fin du segment solution.
+
+ dofirst = Standard_False;
+ dolast = Standard_False;
+ procf = Standard_False;
+ procl = Standard_False;
+
+ if (thesegsol.HasFirstPoint()) {
+ dofirst = Standard_True;
+ PStartf = thesegsol.FirstPoint();
+ paramf = PStartf.Parameter();
+ }
+ if (thesegsol.HasLastPoint()) {
+ dolast = Standard_True;
+ PStartl = thesegsol.LastPoint();
+ paraml = PStartl.Parameter();
+ }
+
+ // determination de la transition
+ if (dofirst && dolast) {
+ U = (paramf+paraml)/2.;
+ }
+ else if (dofirst) {
+ U = paramf + 1.0;
+ }
+ else if (dolast) {
+ U = paraml - 1.0;
+ }
+ else {
+ U = 0.0;
+ }
+
+ Contap_HCurve2dTool::D1(thesegsol.Curve(),U,p2d,d2d);
+ Adaptor3d_HSurfaceTool::D1(SFunc.Surface(),p2d.X(),p2d.Y(),valpt,d1u,d1v);
+ tgline.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+ IntSurf_TypeTrans tral =
+ ComputeTransitionOnLine(SFunc,p2d.X(),p2d.Y(),tgline);
+
+ theline.SetTransitionOnS(tral);
+
+
+ if (dofirst || dolast) {
+ Nblines = slin.Length();
+ for (j=1; j<=Nblines; j++) {
+ Nbpts = slin(j).NbVertex();
+ for (k=1; k<=Nbpts;k++) {
+ ptvtx = slin(j).Vertex(k);
+ if (dofirst) {
+ if (ptvtx.Value().Distance(PStartf.Value()) <=TolArc) {
+ slin(j).Vertex(k).SetMultiple();
+ ptvtx.SetMultiple();
+ ptvtx.SetParameter(paramf);
+ theline.Add(ptvtx);
+ procf=Standard_True;
+ }
+ }
+ if (dolast) {
+ if (ptvtx.Value().Distance(PStartl.Value()) <=TolArc) {
+ slin(j).Vertex(k).SetMultiple();
+ ptvtx.SetMultiple();
+ ptvtx.SetParameter(paraml);
+ theline.Add(ptvtx);
+ procl=Standard_True;
+ }
+ }
+ }
+ // Si on a traite le pt debut et/ou fin, on ne doit pas recommencer si
+ // il (ils) correspond(ent) a un point multiple.
+
+ if (procf) {
+ dofirst = Standard_False;
+ }
+ if (procl) {
+ dolast = Standard_False;
+ }
+ }
+ }
+
+ // Si on n a pas trouve le point debut et./ou fin sur une des lignes
+ // d intersection, il faut quand-meme le placer sur la restriction solution
+
+ if (dofirst) {
+
+ p2d = Contap_HCurve2dTool::Value(thesegsol.Curve(),paramf);
+ ptvtx.SetValue(PStartf.Value(),p2d.X(),p2d.Y());
+ ptvtx.SetParameter(paramf);
+ if (! PStartf.IsNew()) {
+ ptvtx.SetVertex(PStartf.Vertex());
+ }
+ theline.Add(ptvtx);
+ }
+ if (dolast) {
+ p2d = Contap_HCurve2dTool::Value(thesegsol.Curve(),paraml);
+ ptvtx.SetValue(PStartl.Value(),p2d.X(),p2d.Y());
+ ptvtx.SetParameter(paraml);
+ if (! PStartl.IsNew()) {
+ ptvtx.SetVertex(PStartl.Vertex());
+ }
+ theline.Add(ptvtx);
+ }
+
+ // il faut chercher le points internal sur les restrictions solutions.
+ if (thesegsol.HasFirstPoint() && thesegsol.HasLastPoint()) {
+ ComputeInternalPointsOnRstr(theline,paramf,paraml,SFunc);
+ }
+ LineConstructor(slin,Domain,theline,SFunc.Surface()); //-- lbr
+ //-- slin.Append(theline);
+ theline.Clear();
+ }
+}
+
+void ComputeInternalPointsOnRstr
+(Contap_Line& Line,
+ const Standard_Real Paramf,
+ const Standard_Real Paraml,
+ Contap_SurfFunction& SFunc)
+{
+ // On recherche les points ou la tangente a la ligne de contour et
+ // la direction sont alignees.
+ // 1ere etape : recherche de changement de signe.
+ // 2eme etape : localisation de la solution par dichotomie
+
+
+ Standard_Integer indexinf,indexsup,i;
+ gp_Vec tgt, vecref, vectest, vtestb, vecregard,d1u,d1v;
+ gp_Pnt pcour;
+ gp_Pnt2d p2d;
+ gp_Vec2d d2d;
+ Standard_Boolean found,ok = Standard_False,toutvu,solution;
+ Standard_Real paramp = 0.,paraminf,paramsup,toler;
+
+ if (Line.TypeContour() != Contap_Restriction) {
+ return;
+ }
+
+ const Handle_Adaptor2d_HCurve2d& thearc = Line.Arc();
+
+ const Handle(Adaptor3d_HSurface)& Surf = SFunc.Surface();
+ Contap_TFunction TypeFunc(SFunc.FunctionType());
+
+ Standard_Integer Nbpnts = Contap_HContTool::NbSamplesOnArc(thearc);
+ indexinf = 1;
+ vecregard = SFunc.Direction();
+ toler = Contap_HCurve2dTool::Resolution(thearc,Precision::Confusion());
+ found = Standard_False;
+
+ do {
+ paraminf = ((Nbpnts-indexinf)*Paramf + (indexinf-1)*Paraml)/(Nbpnts-1);
+ Contap_HCurve2dTool::D1(thearc,paraminf,p2d,d2d);
+ Adaptor3d_HSurfaceTool::D1(Surf,p2d.X(),p2d.Y(),pcour,d1u,d1v);
+ tgt.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+
+ if (tgt.Magnitude() > gp::Resolution()) {
+ if (TypeFunc == Contap_ContourPrs || TypeFunc==Contap_DraftPrs) {
+ vecregard.SetXYZ(pcour.XYZ()-SFunc.Eye().XYZ());
+ }
+ vecref = vecregard.Crossed(tgt);
+
+ if (vecref.Magnitude() <= gp::Resolution()) {
+ indexinf++;
+ }
+ else {
+ found = Standard_True;
+ }
+ }
+ else {
+ indexinf++;
+ }
+ } while ((indexinf <= Nbpnts) && (!found));
+
+
+ indexsup = indexinf +1;
+ toutvu = (indexsup > Nbpnts);
+ while (!toutvu) {
+ paramsup = ((Nbpnts-indexsup)*Paramf + (indexsup-1)*Paraml)/(Nbpnts-1);
+ Contap_HCurve2dTool::D1(thearc,paramsup,p2d,d2d);
+ Adaptor3d_HSurfaceTool::D1(Surf,p2d.X(),p2d.Y(),pcour,d1u,d1v);
+ tgt.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+
+ if (tgt.Magnitude() > gp::Resolution()) {
+ if (TypeFunc == Contap_ContourPrs || TypeFunc==Contap_DraftPrs) {
+ vecregard.SetXYZ(pcour.XYZ()-SFunc.Eye().XYZ());
+ }
+ vectest = vecregard.Crossed(tgt);
+ }
+ else {
+ vectest = gp_Vec(0.,0.,0.);
+ }
+ if (vectest.Magnitude() <= gp::Resolution()) {
+ // On cherche un vrai changement de signe
+ indexsup++;
+ }
+ else {
+ if (vectest.Dot(vecref) < 0.) {
+ // Essayer de converger
+ // cout << "Changement de signe detecte" << endl;
+ solution = Standard_False;
+ while (!solution) {
+ paramp = (paraminf+paramsup)/2.;
+ Contap_HCurve2dTool::D1(thearc,paramp,p2d,d2d);
+ Adaptor3d_HSurfaceTool::D1(Surf,p2d.X(),p2d.Y(),pcour,d1u,d1v);
+ tgt.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+
+ if (tgt.Magnitude() > gp::Resolution()) {
+ if (TypeFunc == Contap_ContourPrs || TypeFunc==Contap_DraftPrs) {
+ vecregard.SetXYZ(pcour.XYZ()-SFunc.Eye().XYZ());
+ }
+ vtestb = vecregard.Crossed(tgt);
+ }
+ else {
+ vtestb = gp_Vec(0.,0.,0.);
+ }
+
+ if ((vtestb.Magnitude() <= gp::Resolution())||
+ (Abs(paramp-paraminf) <= toler) ||
+ (Abs(paramp-paramsup) <= toler)) {
+ // on est a la solution
+ solution = Standard_True;
+ ok = Standard_True;
+ }
+ else if (vtestb.Dot(vecref) < 0.) {
+ paramsup = paramp;
+ }
+ else {
+ paraminf = paramp;
+ }
+
+ }
+
+ if (ok) {
+ // On verifie que le point trouve ne correspond pas a un ou des
+ // vertex deja existant(s). On teste sur le parametre paramp.
+ for (i=1; i<=Line.NbVertex(); i++) {
+ Contap_Point& thevtx = Line.Vertex(i);
+ if (Abs(thevtx.ParameterOnLine()-paramp) <= toler) {
+ thevtx.SetInternal();
+ ok = Standard_False; // on a correspondance
+ }
+ }
+ if (ok) { // il faut alors rajouter le point
+ Contap_Point internalp(pcour,p2d.X(),p2d.Y());
+ internalp.SetParameter(paramp);
+ internalp.SetInternal();
+ Line.Add(internalp);
+ }
+ }
+ paramsup = ((Nbpnts-indexsup)*Paramf + (indexsup-1)*Paraml)/(Nbpnts-1);
+ }
+ vecref = vectest;
+ indexinf = indexsup;
+ indexsup++;
+ paraminf = paramsup;
+ }
+ toutvu = (indexsup > Nbpnts);
+ }
+}
+
+
+void ComputeInternalPoints
+(Contap_Line& Line,
+ Contap_SurfFunction& SFunc,
+ const Standard_Real ureso,
+ const Standard_Real vreso)
+
+{
+ // On recherche les points ou la tangente a la ligne de contour et
+ // la direction sont alignees.
+ // 1ere etape : recheche de changement de signe.
+ // 2eme etape : localisation de la solution par simili dichotomie
+
+
+ Standard_Integer indexinf,indexsup,index;
+ gp_Vec tgt, vecref, vectest, vtestb, vecregard;
+ //gp_Pnt pprec,pcour;
+ Standard_Boolean found,ok = Standard_False,toutvu,solution;
+ Standard_Real paramp = 0.,U,V;
+
+ math_Vector XInf(1,2),XSup(1,2),X(1,2),F(1,1);
+ math_Matrix DF(1,1,1,2);
+ math_Vector toler(1,2),infb(1,2),supb(1,2);
+
+ if (Line.TypeContour() != Contap_Walking) {
+ return;
+ }
+
+ Standard_Integer Nbpnts = Line.NbPnts();
+ const Handle(Adaptor3d_HSurface)& Surf = SFunc.Surface();
+ Contap_TFunction TypeFunc(SFunc.FunctionType());
+
+ toler(1) = ureso; //-- Trop long !!! Adaptor3d_HSurfaceTool::UResolution(Surf,SFunc.Tolerance());
+ toler(2) = vreso; //---Beaucoup trop long !!! Adaptor3d_HSurfaceTool::VResolution(Surf,SFunc.Tolerance());
+ infb(1) = Adaptor3d_HSurfaceTool::FirstUParameter(Surf);
+ infb(2) = Adaptor3d_HSurfaceTool::FirstVParameter(Surf);
+ supb(1) = Adaptor3d_HSurfaceTool::LastUParameter(Surf);
+ supb(2) = Adaptor3d_HSurfaceTool::LastVParameter(Surf);
+
+ math_FunctionSetRoot rsnld(SFunc,toler,30);
+
+ indexinf = 1;
+ vecregard = SFunc.Direction();
+
+ found = Standard_False;
+ do {
+ Line.Point(indexinf).ParametersOnS2(XInf(1),XInf(2));
+ SFunc.Values(XInf,F,DF);
+ if (!SFunc.IsTangent()) {
+ tgt = SFunc.Direction3d();
+ if (TypeFunc == Contap_ContourPrs || TypeFunc == Contap_DraftPrs) {
+ vecregard.SetXYZ(Line.Point(indexinf).Value().XYZ()-SFunc.Eye().XYZ());
+ }
+ vecref = vecregard.Crossed(tgt);
+
+ if (vecref.Magnitude() <= gp::Resolution()) {
+ indexinf++;
+ }
+ else {
+ found = Standard_True;
+ }
+ }
+ else {
+ indexinf++;
+ }
+ } while ((indexinf <= Nbpnts) && (!found));
+
+
+ indexsup = indexinf +1;
+ toutvu = (indexsup > Nbpnts);
+ while (!toutvu) {
+ Line.Point(indexsup).ParametersOnS2(XSup(1),XSup(2));
+ SFunc.Values(XSup,F,DF);
+ if (!SFunc.IsTangent()) {
+ tgt = SFunc.Direction3d();
+
+ if (TypeFunc == Contap_ContourPrs || TypeFunc == Contap_DraftPrs) {
+ vecregard.SetXYZ(Line.Point(indexsup).Value().XYZ()-SFunc.Eye().XYZ());
+ }
+ vectest = vecregard.Crossed(tgt);
+ }
+ else {
+ vectest = gp_Vec(0.,0.,0.);
+ }
+ if (vectest.Magnitude() <= gp::Resolution()) {
+ // On cherche un vrai changement de signe
+ indexsup++;
+ }
+ else {
+ if (vectest.Dot(vecref) < 0.) {
+ // Essayer de converger
+ // cout << "Changement de signe detecte" << endl;
+ solution = Standard_False;
+ while (!solution) {
+ X(1) = (XInf(1) + XSup(1)) /2.;
+ X(2) = (XInf(2) + XSup(2)) /2.;
+ rsnld.Perform(SFunc,X,infb,supb);
+
+ if (!rsnld.IsDone()) {
+ cout << "Echec recherche internal points" << endl;
+ solution = Standard_True;
+ ok = Standard_False;
+ }
+ else {
+
+ rsnld.Root(X);
+ SFunc.Values(X,F,DF);
+ if (Abs(F(1)) <= SFunc.Tolerance()) {
+
+ if (!SFunc.IsTangent()) {
+ tgt = SFunc.Direction3d();
+ if (TypeFunc == Contap_ContourPrs ||
+ TypeFunc == Contap_DraftPrs) {
+ vecregard.SetXYZ(SFunc.Point().XYZ()-SFunc.Eye().XYZ());
+ }
+ vtestb = vecregard.Crossed(tgt);
+ }
+ else {
+ vtestb = gp_Vec(0.,0.,0.);
+ }
+ if ((vtestb.Magnitude() <= gp::Resolution())||
+ (Abs(X(1)-XInf(1)) <= toler(1)
+ && Abs(X(2)-XInf(2)) <= toler(2)) ||
+ (Abs(X(1)-XSup(1)) <= toler(1)
+ && Abs(X(2)-XSup(2)) <= toler(2))) {
+ // on est a la solution
+ solution = Standard_True;
+ ok = Standard_True;
+ }
+ else if (vtestb.Dot(vecref) < 0.) {
+ XSup = X;
+ }
+ else {
+ XInf = X;
+ }
+ }
+ else { // on n est pas sur une solution
+ cout << "Echec recherche internal points" << endl;
+ solution = Standard_True;
+ ok = Standard_False;
+ }
+ }
+ }
+
+ if (ok) {
+ Standard_Boolean newpoint = Standard_False;
+ Line.Point(indexinf).ParametersOnS2(U,V);
+ gp_Vec2d vinf(X(1)-U,X(2)-V);
+ if (Abs(vinf.X()) <= toler(1) && Abs(vinf.Y()) <= toler(2)) {
+ paramp = indexinf;
+ }
+ else {
+ for (index = indexinf+1; index <= indexsup; index++) {
+ Line.Point(index).ParametersOnS2(U,V);
+ gp_Vec2d vsup(X(1)-U,X(2)-V);
+ if (Abs(vsup.X()) <= toler(1) && Abs(vsup.Y()) <= toler(2)) {
+ paramp = index;
+ break;
+ }
+ else if (vinf.Dot(vsup) < 0.) {
+ // on est entre les 2 points
+ paramp = index;
+ IntSurf_PntOn2S pt2s;
+ pt2s.SetValue(SFunc.Point(),Standard_False,X(1),X(2));
+ Line.LineOn2S()->InsertBefore(index,pt2s);
+
+ //-- Il faut decaler les parametres des vertex situes entre
+ //-- index et NbPnts ###################################
+ for(Standard_Integer v=1; v<=Line.NbVertex(); v++) {
+ Contap_Point& Vertex = Line.Vertex(v);
+ if(Vertex.ParameterOnLine() >= index) {
+ Vertex.SetParameter(Vertex.ParameterOnLine()+1);
+ }
+ }
+
+ Nbpnts = Nbpnts+1;
+ indexsup = indexsup+1;
+ newpoint = Standard_True;
+ break;
+ }
+ else {
+ vinf = vsup;
+ }
+ }
+ }
+
+ Standard_Integer v;
+ if (!newpoint) {
+ // on est sur un point de cheminement. On regarde alors
+ // la correspondance avec un vertex existant.
+ newpoint = Standard_True;
+ for (v=1; v<= Line.NbVertex(); v++) {
+ Contap_Point& Vertex = Line.Vertex(v);
+ if(Vertex.ParameterOnLine() == paramp) {
+ Vertex.SetInternal();
+ newpoint = Standard_False;
+ }
+ }
+ }
+
+ if (newpoint && paramp >1. && paramp < Nbpnts) {
+ // on doit creer un nouveau vertex.
+ Contap_Point internalp(SFunc.Point(),X(1),X(2));
+ internalp.SetParameter(paramp);
+ internalp.SetInternal();
+ Line.Add(internalp);
+ }
+ }
+ Line.Point(indexsup).ParametersOnS2(XSup(1),XSup(2));
+ }
+ vecref = vectest;
+ indexinf = indexsup;
+ indexsup++;
+ XInf = XSup;
+ }
+ toutvu = (indexsup > Nbpnts);
+ }
+}
+
+
+void Contap_Contour::Perform
+(const Handle(Adaptor3d_TopolTool)& Domain) {
+
+ done = Standard_False;
+ slin.Clear();
+
+ Standard_Integer i,j,k,Nbvt1,Nbvt2,ivt1,ivt2;
+ Standard_Integer NbPointRst,NbPointIns;
+ Standard_Integer Nblines, Nbpts, indfirst, indlast;
+ Standard_Real U,V;
+ gp_Pnt2d pt2d;
+ gp_Vec2d d2d;
+ gp_Pnt ptonsurf;
+ gp_Vec d1u,d1v,normale,tgtrst,tgline;
+ Standard_Real currentparam;
+ IntSurf_Transition TLine,TArc;
+
+ Contap_Line theline;
+ Contap_Point ptdeb,ptfin;
+ Contap_ThePathPointOfTheSearch PStartf,PStartl;
+
+ // Standard_Real TolArc = 1.e-5;
+ Standard_Real TolArc = Precision::Confusion();
+
+ const Handle(Adaptor3d_HSurface)& Surf = mySFunc.Surface();
+
+ Standard_Real EpsU = Adaptor3d_HSurfaceTool::UResolution(Surf,Precision::Confusion());
+ Standard_Real EpsV = Adaptor3d_HSurfaceTool::VResolution(Surf,Precision::Confusion());
+ Standard_Real Preci = Min(EpsU,EpsV);
+ // Standard_Real Fleche = 5.e-1;
+ // Standard_Real Pas = 5.e-2;
+ Standard_Real Fleche = 0.01;
+ Standard_Real Pas = 0.005;
+ // lbr: Il y avait Pas 0.2 -> Manque des Inters sur restr ; devrait faire un mini de 5 pts par lignes
+ //-- le 23 janvier 98 0.05 -> 0.01
+
+
+ //-- ******************************************************************************** Janvier 98
+ Bnd_Box B1; Standard_Boolean Box1OK = Standard_True;
+
+ Standard_Real Uinf = Surf->FirstUParameter();
+ Standard_Real Vinf = Surf->FirstVParameter();
+ Standard_Real Usup = Surf->LastUParameter();
+ Standard_Real Vsup = Surf->LastVParameter();
+
+ Standard_Boolean Uinfinfinite = Precision::IsNegativeInfinite(Uinf);
+ Standard_Boolean Usupinfinite = Precision::IsPositiveInfinite(Usup);
+ Standard_Boolean Vinfinfinite = Precision::IsNegativeInfinite(Vinf);
+ Standard_Boolean Vsupinfinite = Precision::IsPositiveInfinite(Vsup);
+
+ if( Uinfinfinite || Usupinfinite || Vinfinfinite || Vsupinfinite) {
+ Box1OK = Standard_False;
+ }
+ else {
+ BndLib_AddSurface::Add(Surf->Surface(),1e-8,B1);
+ }
+ Standard_Real x0,y0,z0,x1,y1,z1,dx,dy,dz;
+ if(Box1OK) {
+ B1.Get(x0,y0,z0,x1,y1,z1);
+ dx=x1-x0;
+ dy=y1-y0;
+ dz=z1-z0;
+ }
+ else {
+ dx=dy=dz=1.0;
+ }
+ if(dx<dy) dx=dy;
+ if(dx<dz) dx=dz;
+ if(dx>10000.0) dx=10000.0;
+ Fleche*=dx;
+ TolArc*=dx;
+ //-- ********************************************************************************
+
+
+ //gp_Pnt valpt;
+
+ //jag 940616 SFunc.Set(1.e-8); // tolerance sur la fonction
+ mySFunc.Set(Precision::Confusion()); // tolerance sur la fonction
+
+ Standard_Boolean RecheckOnRegularity = Standard_True;
+ solrst.Perform(myAFunc,Domain,TolArc,TolArc,RecheckOnRegularity);
+
+ if (!solrst.IsDone()) {
+ return;
+ }
+
+ NbPointRst = solrst.NbPoints();
+ IntSurf_SequenceOfPathPoint seqpdep;
+ TColStd_Array1OfInteger Destination(1,NbPointRst+1);
+ Destination.Init(0);
+ if (NbPointRst != 0) {
+ ComputeTangency(solrst,Domain,mySFunc,seqpdep,Destination);
+ }
+
+ //jag 940616 solins.Perform(SFunc,Surf,Domain,1.e-6); // 1.e-6 : tolerance dans l espace.
+ solins.Perform(mySFunc,Surf,Domain,Precision::Confusion());
+
+ NbPointIns = solins.NbPoints();
+ IntSurf_SequenceOfInteriorPoint seqpins;
+
+ if (NbPointIns != 0) {
+ Standard_Boolean bKeepAllPoints = Standard_False;
+ //IFV begin
+ if(solrst.NbSegments() <= 0) {
+ if(mySFunc.FunctionType() == Contap_ContourStd) {
+ const Handle(Adaptor3d_HSurface)& Surf = mySFunc.Surface();
+ if(Adaptor3d_HSurfaceTool::GetType(Surf) == GeomAbs_Torus) {
+ gp_Torus aTor = Adaptor3d_HSurfaceTool::Torus(Surf);
+ gp_Dir aTorDir = aTor.Axis().Direction();
+ gp_Dir aProjDir = mySFunc.Direction();
+
+ if(aTorDir.Dot(aProjDir) < Precision::Confusion()) {
+ bKeepAllPoints = Standard_True;
+ }
+ }
+ }
+ }
+
+ if(bKeepAllPoints) {
+ Standard_Integer Nbp = solins.NbPoints(), indp;
+ for (indp=1; indp <= Nbp; indp++) {
+ const IntSurf_InteriorPoint& pti = solins.Value(indp);
+ seqpins.Append(pti);
+ }
+ }
+ //IFV - end
+ else {
+ KeepInsidePoints(solins,solrst,mySFunc,seqpins);
+ }
+ }
+
+ if (seqpdep.Length() != 0 || seqpins.Length() != 0) {
+
+ Contap_TheIWalking iwalk(Preci,Fleche,Pas);
+ iwalk.Perform(seqpdep,seqpins,mySFunc ,Surf);
+ if(!iwalk.IsDone()) {
+ return;
+ }
+
+ Nblines = iwalk.NbLines();
+ for (j=1; j<=Nblines; j++) {
+ IntSurf_TypeTrans TypeTransOnS = IntSurf_Undecided;
+ const Handle(Contap_TheIWLineOfTheIWalking)& iwline = iwalk.Value(j);
+ Nbpts = iwline->NbPoints();
+ theline.SetLineOn2S(iwline->Line());
+
+ // jag 941018 On calcule une seule fois la transition
+
+ tgline = iwline->TangentVector(k);
+ iwline->Line()->Value(k).ParametersOnS2(U,V);
+ TypeTransOnS = ComputeTransitionOnLine(mySFunc,U,V,tgline);
+ theline.SetTransitionOnS(TypeTransOnS);
+
+ //---------------------------------------------------------------------
+ //-- On ajoute a la liste des vertex les 1er et dernier points de la -
+ //-- ligne de cheminement si ceux-ci ne sont pas presents -
+ //---------------------------------------------------------------------
+
+ if (iwline->HasFirstPoint()) {
+ indfirst = iwline->FirstPointIndex();
+ const IntSurf_PathPoint& PPoint = seqpdep(indfirst);
+ Standard_Integer themult = PPoint.Multiplicity();
+ for (i=NbPointRst; i>=1; i--) {
+ if (Destination(i) == indfirst) {
+ PPoint.Parameters(themult,U,V);
+ ptdeb.SetValue(PPoint.Value(),U,V);
+ ptdeb.SetParameter(1.0);
+
+ const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
+ const Handle(Adaptor2d_HCurve2d)& currentarc = PStart.Arc();
+ currentparam = PStart.Parameter();
+ if (!iwline->IsTangentAtBegining()) {
+
+ Contap_HCurve2dTool::D1(currentarc,currentparam,pt2d,d2d);
+ Contap_SurfProps::DerivAndNorm(Surf,pt2d.X(),pt2d.Y(),
+ ptonsurf,d1u,d1v,normale);
+ tgtrst = d2d.X()*d1u;
+ tgtrst.Add(d2d.Y()*d1v);
+
+ IntSurf::MakeTransition(PPoint.Direction3d(),tgtrst,normale,
+ TLine,TArc);
+
+ }
+ else {// a voir. En effet, on a cheminer. Si on est sur un point
+ // debut, on sait qu'on rentre dans la matiere
+ TLine.SetValue();
+ TArc.SetValue();
+ }
+
+ ptdeb.SetArc(currentarc,currentparam,TLine,TArc);
+
+ if (!solrst.Point(i).IsNew()) {
+ ptdeb.SetVertex(PStart.Vertex());
+ }
+ theline.Add(ptdeb);
+ themult--;
+ }
+ }
+ }
+ else {
+ iwline->Value(1).ParametersOnS2(U,V);
+ ptdeb.SetValue(theline.Point(1).Value(),U,V);
+ ptdeb.SetParameter(1.0);
+ theline.Add(ptdeb);
+ }
+
+ if (iwline->HasLastPoint()) {
+ indlast = iwline->LastPointIndex();
+ const IntSurf_PathPoint& PPoint = seqpdep(indlast);
+ Standard_Integer themult = PPoint.Multiplicity();
+ for (i=NbPointRst; i>=1; i--) {
+ if (Destination(i) == indlast) {
+ PPoint.Parameters(themult,U,V);
+ ptfin.SetValue(PPoint.Value(),U,V);
+ ptfin.SetParameter((Standard_Real)(Nbpts));
+ const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
+ const Handle(Adaptor2d_HCurve2d)& currentarc = PStart.Arc();
+ currentparam = PStart.Parameter();
+
+ if (!iwline->IsTangentAtEnd()) {
+
+ Contap_HCurve2dTool::D1(currentarc,currentparam,pt2d,d2d);
+
+ Contap_SurfProps::DerivAndNorm(Surf,pt2d.X(),pt2d.Y(),
+ ptonsurf,d1u,d1v,normale);
+ tgtrst = d2d.X()*d1u;
+ tgtrst.Add(d2d.Y()*d1v);
+ IntSurf::MakeTransition(PPoint.Direction3d().Reversed(),
+ tgtrst,normale,TLine,TArc);
+ }
+ else {
+ TLine.SetValue();
+ TArc.SetValue();
+ }
+
+ ptfin.SetArc(currentarc,currentparam,TLine,TArc);
+
+ if (!solrst.Point(i).IsNew()) {
+ ptfin.SetVertex(PStart.Vertex());
+ }
+ theline.Add(ptfin);
+ themult--;
+ }
+ }
+ }
+ else {
+ iwline->Value(Nbpts).ParametersOnS2(U,V);
+ ptfin.SetValue(theline.Point(Nbpts).Value(),U,V);
+ ptfin.SetParameter((Standard_Real)(Nbpts));
+ theline.Add(ptfin);
+ }
+
+ ComputeInternalPoints(theline,mySFunc,EpsU,EpsV);
+ LineConstructor(slin,Domain,theline,Surf); //-- lbr
+ //-- slin.Append(theline);
+ theline.ResetSeqOfVertex();
+ }
+
+
+ Nblines = slin.Length();
+ for (j=1; j<=Nblines-1; j++) {
+ const Contap_Line& theli = slin(j);
+ Nbvt1 = theli.NbVertex();
+ for (ivt1=1; ivt1<=Nbvt1; ivt1++) {
+ if (!theli.Vertex(ivt1).IsOnArc()) {
+ const gp_Pnt& pttg1 = theli.Vertex(ivt1).Value();
+
+ for (k=j+1; k<=Nblines;k++) {
+ const Contap_Line& theli2 = slin(k);
+ Nbvt2 = theli2.NbVertex();
+ for (ivt2=1; ivt2<=Nbvt2; ivt2++) {
+ if (!theli2.Vertex(ivt2).IsOnArc()) {
+ const gp_Pnt& pttg2 = theli2.Vertex(ivt2).Value();
+
+ if (pttg1.Distance(pttg2) <= TolArc) {
+ theli.Vertex(ivt1).SetMultiple();
+ theli2.Vertex(ivt2).SetMultiple();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // jag 940620 On ajoute le traitement des restrictions solutions.
+
+ if (solrst.NbSegments() !=0) {
+ ProcessSegments(solrst,slin,TolArc,mySFunc,Domain);
+ }
+
+
+ // Ajout crad pour depanner CMA en attendant mieux
+ if (solrst.NbSegments() !=0) {
+
+ Nblines = slin.Length();
+ for (j=1; j<=Nblines; j++) {
+ const Contap_Line& theli = slin(j);
+ if (theli.TypeContour() == Contap_Walking) {
+ Nbvt1 = theli.NbVertex();
+ for (ivt1=1; ivt1<=Nbvt1; ivt1++) {
+ Contap_Point& ptvt = theli.Vertex(ivt1);
+ if (!ptvt.IsOnArc() && !ptvt.IsMultiple()) {
+ Standard_Real Up,Vp;
+ ptvt.Parameters(Up,Vp);
+ gp_Pnt2d toproj(Up,Vp);
+ Standard_Boolean projok;
+ for (k=1; k<=Nblines;k++) {
+ if (slin(k).TypeContour() == Contap_Restriction) {
+ const Handle(Adaptor2d_HCurve2d)& thearc = slin(k).Arc();
+ Standard_Real paramproj;
+ gp_Pnt2d Ptproj;
+ projok = Contap_HContTool::Project(thearc,toproj,paramproj,Ptproj);
+
+ if (projok) {
+ Standard_Real dist = Ptproj.Distance(gp_Pnt2d(Up,Vp));
+ if (dist <= Preci) {
+ // Calcul de la transition
+
+ Contap_HCurve2dTool::D1(thearc,paramproj,Ptproj,d2d);
+ // Adaptor3d_HSurfaceTool::D1(Surf,Ptproj.X(),Ptproj.Y(),
+ // ptonsurf,d1u,d1v);
+ // normale = d1u.Crossed(d1v);
+
+ Contap_SurfProps::DerivAndNorm
+ (Surf,Ptproj.X(),Ptproj.Y(),ptonsurf,d1u,d1v,normale);
+
+ tgtrst = d2d.X()*d1u;
+ tgtrst.Add(d2d.Y()*d1v);
+ Standard_Integer Paraml =
+ (Standard_Integer) ptvt.ParameterOnLine();
+
+ if (Paraml == theli.NbPnts()) {
+ tgline = gp_Vec(theli.Point(Paraml-1).Value(),
+ ptvt.Value());
+ }
+ else {
+ tgline = gp_Vec(ptvt.Value(),
+ theli.Point(Paraml+1).Value());
+ }
+ IntSurf::MakeTransition(tgline,tgtrst,normale,
+ TLine,TArc);
+ ptvt.SetArc(thearc,paramproj,TLine,TArc);
+ ptvt.SetMultiple();
+ ptdeb.SetValue(ptonsurf,Ptproj.X(),Ptproj.Y());
+ ptdeb.SetParameter(paramproj);
+ ptdeb.SetMultiple();
+ slin(k).Add(ptdeb);
+ break;
+ }
+ else {
+ projok = Standard_False;
+ }
+ }
+ }
+ else {
+ projok = Standard_False;
+ }
+ if (projok) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ done = Standard_True;
+}
+
+static Standard_Boolean FindLine(Contap_Line& Line,
+ const Handle(Adaptor3d_HSurface)& Surf,
+ const gp_Pnt2d& Pt2d,
+ gp_Pnt& Ptref,
+ Standard_Real& Paramin,
+ gp_Vec& Tgmin,
+ gp_Vec& Norm)
+{
+ // Standard_Integer i;
+ gp_Pnt pt,ptmin;
+ gp_Vec tg;
+ Standard_Real para,dist;
+ Standard_Real dismin = RealLast();
+
+ Contap_SurfProps::Normale(Surf,Pt2d.X(),Pt2d.Y(),Ptref,Norm);
+
+ if (Line.TypeContour() == Contap_Lin) {
+ gp_Lin lin(Line.Line());
+ para = ElCLib::Parameter(lin,Ptref);
+ ElCLib::D1(para,lin,pt,tg);
+ dist = pt.Distance(Ptref) + Abs(Norm.Dot(lin.Direction()));
+ }
+ else { // Contap__Circle
+ gp_Circ cir(Line.Circle());
+ para = ElCLib::Parameter(cir,Ptref);
+ ElCLib::D1(para,cir,pt,tg);
+ dist = pt.Distance(Ptref)+Abs(Norm.Dot(tg/cir.Radius()));
+ }
+ if (dist < dismin) {
+ dismin = dist;
+ Paramin = para;
+ ptmin = pt;
+ Tgmin = tg;
+ }
+ if (ptmin.SquareDistance(Ptref) <= Tolpetit) {
+ return Standard_True;
+ }
+ else {
+ return Standard_False;
+ }
+}
+
+
+static void PutPointsOnLine (const Contap_TheSearch& solrst,
+ const Handle(Adaptor3d_HSurface)& Surf,
+ Contap_TheSequenceOfLine& slin)
+
+{
+ Standard_Integer i,l;//,index;
+ Standard_Integer NbPoints = solrst.NbPoints();
+
+ Standard_Real theparam;
+
+ IntSurf_Transition TLine,TArc;
+ Standard_Boolean goon;
+
+ gp_Pnt2d pt2d;
+ gp_Vec2d d2d;
+
+ gp_Pnt ptonsurf;
+ gp_Vec vectg,normale,tgtrst;
+ Standard_Real paramlin = 0.0;
+
+
+ Standard_Integer nbLin = slin.Length();
+ for(l=1;l<=nbLin;l++) {
+ Contap_Line& Line=slin.ChangeValue(l);
+ for (i=1; i<= NbPoints; i++) {
+
+ const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
+ const Handle(Adaptor2d_HCurve2d)& thearc = PStart.Arc();
+ theparam = PStart.Parameter();
+
+ Contap_HCurve2dTool::D1(thearc,theparam,pt2d,d2d);
+ goon = FindLine(Line,Surf,pt2d,ptonsurf,paramlin,vectg,normale);
+
+ Contap_Point PPoint;
+
+ if (goon) {
+ gp_Vec d1u,d1v;
+ gp_Pnt bidpt;
+ Adaptor3d_HSurfaceTool::D1(Surf,pt2d.X(),pt2d.Y(),bidpt,d1u,d1v);
+ PPoint.SetValue(ptonsurf,pt2d.X(),pt2d.Y());
+ if (normale.Magnitude() < RealEpsilon()) {
+ TLine.SetValue();
+ TArc.SetValue();
+ }
+ else {
+ // Petit test qui devrait permettre de bien traiter les pointes
+ // des cones, et les sommets d`une sphere. Il faudrait peut-etre
+ // rajouter une methode dans SurfProps
+
+ if (Abs(d2d.Y()) <= Precision::Confusion()) {
+ tgtrst = d1v.Crossed(normale);
+ if(d2d.X() < 0.0)
+ tgtrst.Reverse();
+ }
+ else {
+ tgtrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+ }
+ IntSurf::MakeTransition(vectg,tgtrst,normale,TLine,TArc);
+ }
+
+ PPoint.SetArc(thearc,theparam, TLine, TArc);
+ PPoint.SetParameter(paramlin);
+ if (!PStart.IsNew()) {
+ PPoint.SetVertex(PStart.Vertex());
+ }
+ Line.Add(PPoint);
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------------
+//-- Orientation des contours Apparents quand ceux-ci sont des lignes ou des cercles
+//-- On prend un point de la ligne ou du cercle ---> P
+//-- On projete ce point sur la surface P ---> u,v
+//-- et on evalue la transition au point u,v
+//----------------------------------------------------------------------------------
+
+IntSurf_TypeTrans ComputeTransitionOngpLine
+(Contap_SurfFunction& SFunc,
+ const gp_Lin& L)
+{
+ const Handle(Adaptor3d_HSurface)& Surf=SFunc.Surface();
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(Surf);
+ gp_Pnt P;
+ gp_Vec T;
+ ElCLib::D1(0.0,L,P,T);
+ Standard_Real u = 0.,v = 0.;
+ switch (typS) {
+ case GeomAbs_Cylinder: {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cylinder(Surf),P,u,v);
+ break;
+ }
+ case GeomAbs_Cone: {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cone(Surf),P,u,v);
+ break;
+ }
+ case GeomAbs_Sphere: {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Sphere(Surf),P,u,v);
+ break;
+ }
+ default:
+ break;
+ }
+ return(ComputeTransitionOnLine(SFunc,u,v,T));
+}
+
+
+IntSurf_TypeTrans ComputeTransitionOngpCircle
+(Contap_SurfFunction& SFunc,
+ const gp_Circ& C)
+{
+ const Handle(Adaptor3d_HSurface)& Surf=SFunc.Surface();
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(Surf);
+ gp_Pnt P;
+ gp_Vec T;
+ ElCLib::D1(0.0,C,P,T);
+ Standard_Real u = 0.,v = 0.;
+ switch (typS) {
+ case GeomAbs_Cylinder: {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cylinder(Surf),P,u,v);
+ break;
+ }
+ case GeomAbs_Cone: {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Cone(Surf),P,u,v);
+ break;
+ }
+ case GeomAbs_Sphere: {
+ ElSLib::Parameters(Adaptor3d_HSurfaceTool::Sphere(Surf),P,u,v);
+ break;
+ }
+ default:
+ break;
+ }
+ return(ComputeTransitionOnLine(SFunc,u,v,T));
+}
+
+
+void Contap_Contour::PerformAna(const Handle(Adaptor3d_TopolTool)& Domain)
+{
+
+ done = Standard_False;
+ slin.Clear();
+
+ Standard_Real TolArc = 1.e-5;
+
+ Standard_Integer nbCont, nbPointRst, i;
+ //gp_Circ cirsol;
+ //gp_Lin linsol;
+ Contap_ContAna contana;
+ Contap_Line theline;
+ const Handle(Adaptor3d_HSurface)& Surf = mySFunc.Surface();
+ Contap_TFunction TypeFunc(mySFunc.FunctionType());
+ Standard_Boolean PerformSolRst = Standard_True;
+
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(Surf);
+
+ switch (typS) {
+ case GeomAbs_Plane:
+ {
+ gp_Pln pl(Adaptor3d_HSurfaceTool::Plane(Surf));
+ switch (TypeFunc) {
+ case Contap_ContourStd:
+ {
+ gp_Dir Dirpln(pl.Axis().Direction());
+ if (Abs(mySFunc.Direction().Dot(Dirpln)) > Precision::Angular()) {
+ // Aucun point du plan n`est solution, en particulier aucun point
+ // sur restriction.
+ PerformSolRst = Standard_False;
+ }
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ gp_Pnt Eye(mySFunc.Eye());
+ if (pl.Distance(Eye) > Precision::Confusion()) {
+ // Aucun point du plan n`est solution, en particulier aucun point
+ // sur restriction.
+ PerformSolRst = Standard_False;
+ }
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ gp_Dir Dirpln(pl.Axis().Direction());
+ Standard_Real Sina = Sin(mySFunc.Angle());
+ if (Abs(mySFunc.Direction().Dot(Dirpln)+ Sina) > //voir SurfFunction
+ Precision::Angular()) {
+
+ PerformSolRst = Standard_False;
+ }
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ }
+ break;
+
+ case GeomAbs_Sphere:
+ {
+ switch (TypeFunc) {
+ case Contap_ContourStd:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Sphere(Surf),mySFunc.Direction());
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Sphere(Surf),mySFunc.Eye());
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Sphere(Surf),
+ mySFunc.Direction(),mySFunc.Angle());
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ }
+ break;
+
+ case GeomAbs_Cylinder:
+ {
+ switch (TypeFunc) {
+ case Contap_ContourStd:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Cylinder(Surf),mySFunc.Direction());
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Cylinder(Surf),mySFunc.Eye());
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Cylinder(Surf),
+ mySFunc.Direction(),mySFunc.Angle());
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ }
+ break;
+
+ case GeomAbs_Cone:
+ {
+ switch (TypeFunc) {
+ case Contap_ContourStd:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Cone(Surf),mySFunc.Direction());
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Cone(Surf),mySFunc.Eye());
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ contana.Perform(Adaptor3d_HSurfaceTool::Cone(Surf),
+ mySFunc.Direction(),mySFunc.Angle());
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ default:
+ break;
+ }
+ break;
+ }
+
+ if (typS != GeomAbs_Plane) {
+
+ if (!contana.IsDone()) {
+ return;
+ }
+
+ nbCont = contana.NbContours();
+
+ if (contana.NbContours() == 0) {
+ done = Standard_True;
+ return;
+ }
+
+ GeomAbs_CurveType typL = contana.TypeContour();
+ if (typL == GeomAbs_Circle) {
+ theline.SetValue(contana.Circle());
+ IntSurf_TypeTrans TransCircle;
+ TransCircle = ComputeTransitionOngpCircle(mySFunc,contana.Circle());
+ theline.SetTransitionOnS(TransCircle);
+ slin.Append(theline);
+ }
+ else if (typL == GeomAbs_Line) {
+ for (i=1; i<=nbCont; i++) {
+ theline.SetValue(contana.Line(i));
+ IntSurf_TypeTrans TransLine;
+ TransLine = ComputeTransitionOngpLine(mySFunc,contana.Line(i));
+ theline.SetTransitionOnS(TransLine);
+ slin.Append(theline);
+ theline.Clear();
+ }
+
+ /*
+ if (typS == GeomAbs_Cone) {
+ Standard_Real u,v;
+ gp_Cone thecone(Adaptor3d_HSurfaceTool::Cone(Surf));
+ ElSLib::Parameters(thecone,thecone.Apex(),u,v);
+ Contap_Point vtxapex(thecone.Apex(),u,v);
+ vtxapex.SetInternal();
+ vtxapex.SetMultiple();
+ for (i=1; i<=nbCont i++) {
+ slin.ChangeValue(i).Add(vtxapex);
+ }
+ }
+ */
+ }
+ }
+
+ if(PerformSolRst) {
+
+ solrst.Perform(myAFunc,Domain,TolArc,TolArc);
+ if (!solrst.IsDone()) {
+ return;
+ }
+ nbPointRst = solrst.NbPoints();
+
+ if (nbPointRst != 0) {
+ PutPointsOnLine(solrst,Surf,slin);
+ }
+
+ if (solrst.NbSegments() !=0) {
+ ProcessSegments(solrst,slin,TolArc,mySFunc,Domain);
+ }
+
+
+ //-- lbr
+ //Standard_Boolean oneremov;
+ Standard_Integer nblinto = slin.Length();
+ TColStd_SequenceOfInteger SeqToDestroy;
+
+ //-- cout<<" Construct Contour_3 nblin = "<<nblinto<<endl;
+ for(i=1; i<= nblinto ; i++) {
+ //-- cout<<" nbvtx : "<<slin.Value(i).NbVertex()<<endl;
+ //--if(slin.Value(i).NbVertex() > 1) {
+ if(slin.Value(i).TypeContour() != Contap_Restriction) {
+ LineConstructor(slin,Domain,slin.ChangeValue(i),Surf);
+ SeqToDestroy.Append(i);
+ }
+ //-- }
+ }
+ for(i=SeqToDestroy.Length(); i>=1; i--) {
+ slin.Remove(SeqToDestroy.Value(i));
+ }
+ }
+
+ done = Standard_True;
+}
+
--- /dev/null
+// Created on: 1993-02-05
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1993-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <StdFail_NotDone.hxx>
+
+inline Standard_Boolean Contap_Contour::IsDone () const
+{
+ return done;
+}
+
+inline Standard_Boolean Contap_Contour::IsEmpty () const
+{
+ return NbLines()==0;
+}
+
+inline Standard_Integer Contap_Contour::NbLines () const
+{
+ if (!done) {StdFail_NotDone::Raise();}
+ return slin.Length();
+}
+
+inline const Contap_Line &
+Contap_Contour::Line (const Standard_Integer Index) const
+{
+ if (!done) {StdFail_NotDone::Raise();}
+ return slin(Index);
+}
+
+inline Contap_SurfFunction &
+Contap_Contour::SurfaceFunction ()
+{
+ if (!done) {StdFail_NotDone::Raise();}
+ return mySFunc;
+}
+
+++ /dev/null
--- Created on: 1993-02-05
--- Created by: Jacques GOUSSARD
--- Copyright (c) 1993-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-generic class ContourGen from Contap
- (TheVertex as any;
- TheArc as any;
- TheSurface as any;
- TheArcTool as any;
- TheSurfaceTool as any;
- TheContTool as any; -- as ContTool from Contap(TheVertex,TheArc,
- -- TheSurface)
- TheTopolTool as Transient)
-
-
-uses PathPoint from IntSurf,
- PathPointTool from IntSurf,
- SequenceOfPathPoint from IntSurf,
- InteriorPoint from IntSurf,
- InteriorPointTool from IntSurf,
- SequenceOfInteriorPoint from IntSurf,
- Pnt from gp,
- Vec from gp
-
-
-raises NotDone from StdFail,
- OutOfRange from Standard,
- ConstructionError from Standard
-
- class ThePoint instantiates Point from Contap
- (TheVertex,
- TheArc);
-
- class TheSequenceOfPoint instantiates Sequence from TCollection
- (ThePoint);
-
- class TheHSequenceOfPoint instantiates HSequence from TCollection
- (ThePoint,TheSequenceOfPoint);
-
-
- class TheLine instantiates Line from Contap
- (TheVertex,
- TheArc,
- ThePoint,
- TheHSequenceOfPoint);
-
-
- class TheSequenceOfLine instantiates Sequence from TCollection
- (TheLine);
-
-
- class TheSurfProps instantiates SurfProps from Contap
- (TheSurface,
- TheSurfaceTool);
-
-
- class TheSurfFunction instantiates SurfFunction from Contap
- (TheSurface,
- TheSurfaceTool,
- TheSurfProps from Contap,
- TheContTool);
-
- class TheArcFunction instantiates ArcFunction from Contap
- (TheArc,
- TheSurface,
- TheArcTool,
- TheSurfaceTool,
- TheSurfProps from Contap,
- TheContTool);
-
-
- class TheSearch instantiates SearchOnBoundaries from IntStart
- (TheVertex,
- TheArc,
- TheArcTool,
- TheContTool,
- TheTopolTool,
- TheArcFunction from Contap);
-
-
- class TheIWalking instantiates IWalking from IntWalk
- (PathPoint from IntSurf,
- PathPointTool from IntSurf,
- SequenceOfPathPoint from IntSurf,
- InteriorPoint from IntSurf,
- InteriorPointTool from IntSurf,
- SequenceOfInteriorPoint from IntSurf,
- TheSurface,
- TheSurfaceTool,
- TheSurfFunction from Contap);
-
-
- class TheSearchInside instantiates SearchInside from IntStart
- (TheSurface,
- TheSurfaceTool,
- TheTopolTool,
- TheContTool,
- TheSurfFunction from Contap);
-
-is
-
- Create
-
- returns ContourGen from Contap;
-
-
- Create(Direction: Vec from gp)
-
- returns ContourGen from Contap;
-
-
- Create(Direction: Vec from gp; Angle: Real from Standard)
-
- returns ContourGen from Contap;
-
-
- Create(Eye: Pnt from gp)
-
- returns ContourGen from Contap;
-
-
- Create(Surf: TheSurface; Domain: TheTopolTool;
- Direction: Vec from gp)
-
- ---Purpose: Creates the contour in a given direction.
-
- returns ContourGen from Contap;
-
-
- Create(Surf: TheSurface; Domain: TheTopolTool;
- Direction: Vec from gp; Angle: Real from Standard)
-
- ---Purpose: Creates the contour in a given direction.
-
- returns ContourGen from Contap;
-
-
- Create(Surf: TheSurface; Domain: TheTopolTool;
- Eye: Pnt from gp)
-
- ---Purpose: Creates the contour for a perspective view.
-
- returns ContourGen from Contap;
-
-
- Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool)
-
- ---Purpose: Creates the contour in a given direction.
-
- raises ConstructionError from Standard
- is static;
-
-
- Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool;
- Direction: Vec from gp)
-
- ---Purpose: Creates the contour in a given direction.
-
- is static;
-
-
- Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool;
- Direction: Vec from gp; Angle: Real from Standard)
-
- ---Purpose: Creates the contour in a given direction.
-
- is static;
-
-
- Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool;
- Eye: Pnt from gp)
-
- ---Purpose: Creates the contour for a perspective view.
-
- is static;
-
-
- Init(me: in out; Direction: Vec from gp)
-
- is static;
-
-
- Init(me: in out; Direction: Vec from gp; Angle: Real from Standard)
-
- is static;
-
-
- Init(me: in out; Eye: Pnt from gp)
-
- is static;
-
-
- IsDone(me)
-
- returns Boolean from Standard
- ---C++: inline
-
- is static;
-
-
- IsEmpty(me)
-
- ---Purpose: Returns true if the is no line.
-
- returns Boolean from Standard
- ---C++: inline
-
- raises NotDone from StdFail
-
- is static;
-
-
- NbLines(me)
-
- returns Integer from Standard
- ---C++: inline
-
- raises NotDone from StdFail
-
- is static;
-
-
- Line(me; Index: Integer from Standard)
-
- returns TheLine from Contap
- ---C++: return const&
- ---C++: inline
-
- raises NotDone from StdFail,
- OutOfRange from Standard
-
- is static;
-
-
- SurfaceFunction(me : in out)
- returns TheSurfFunction
- ---Purpose: Returns a reference on the internal
- -- SurfaceFunction. This is used to compute tangents
- -- on the lines.
- ---C++: return &
- ---C++: inline
- is static;
-
-
- Perform(me: in out; Domain: TheTopolTool)
-
- is static private;
-
-
- PerformAna(me: in out; Domain: TheTopolTool)
-
- is static private;
-
-
-fields
-
- done : Boolean from Standard;
- slin : TheSequenceOfLine from Contap;
- solrst : TheSearch from Contap;
- solins : TheSearchInside from Contap;
- mySFunc : TheSurfFunction from Contap;
- myAFunc : TheArcFunction from Contap;
- modeset : Boolean from Standard;
-
-end ContourGen;
+++ /dev/null
-// Created on: 1993-02-05
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <ElCLib.hxx>
-
-#include <gp_Pln.hxx>
-#include <gp_Sphere.hxx>
-#include <gp_Cylinder.hxx>
-#include <gp_Cone.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Circ.hxx>
-#include <Contap_ContAna.hxx>
-#include <math_FunctionSetRoot.hxx>
-#include <IntSurf.hxx>
-
-#include <Contap_ContourGen_1.gxx>
-#include <Contap_ContourGen_2.gxx>
-#include <Contap_ContourGen_3.gxx>
+++ /dev/null
-// Created on: 1993-02-05
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <StdFail_NotDone.hxx>
-
-inline Standard_Boolean Contap_ContourGen::IsDone () const
-{
- return done;
-}
-
-inline Standard_Boolean Contap_ContourGen::IsEmpty () const
-{
- return NbLines()==0;
-}
-
-inline Standard_Integer Contap_ContourGen::NbLines () const
-{
- if (!done) {StdFail_NotDone::Raise();}
- return slin.Length();
-}
-
-inline const Contap_TheLine &
-Contap_ContourGen::Line (const Standard_Integer Index) const
-{
- if (!done) {StdFail_NotDone::Raise();}
- return slin(Index);
-}
-
-inline Contap_TheSurfFunction &
-Contap_ContourGen::SurfaceFunction ()
-{
- if (!done) {StdFail_NotDone::Raise();}
- return mySFunc;
-}
-
+++ /dev/null
-// Created on: 1993-02-05
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_ConstructionError.hxx>
-
-
-Contap_ContourGen::Contap_ContourGen () :
- done(Standard_False),modeset(Standard_False)
-{}
-
-Contap_ContourGen::Contap_ContourGen (const gp_Vec& Direction) :
-
- done(Standard_False),modeset(Standard_True)
-{
- mySFunc.Set(Direction);
- myAFunc.Set(Direction);
-}
-
-
-Contap_ContourGen::Contap_ContourGen (const gp_Vec& Direction,
- const Standard_Real Angle) :
-
- done(Standard_False),modeset(Standard_True)
-{
- mySFunc.Set(Direction,Angle);
- myAFunc.Set(Direction,Angle);
-}
-
-Contap_ContourGen::Contap_ContourGen (const gp_Pnt& Eye) :
-
- done(Standard_False),modeset(Standard_True)
-{
- mySFunc.Set(Eye);
- myAFunc.Set(Eye);
-}
-
-
-Contap_ContourGen::Contap_ContourGen (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain,
- const gp_Vec& Direction) :
-
- done(Standard_False),modeset(Standard_True)
-{
- Perform(Surf,Domain,Direction);
-}
-
-
-Contap_ContourGen::Contap_ContourGen (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain,
- const gp_Vec& Direction,
- const Standard_Real Angle) :
-
- done(Standard_False),modeset(Standard_True)
-{
- Perform(Surf,Domain,Direction,Angle);
-}
-
-
-Contap_ContourGen::Contap_ContourGen (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain,
- const gp_Pnt& Eye) :
-
- done(Standard_False),modeset(Standard_True)
-{
- Perform(Surf,Domain,Eye);
-}
-
-
-void Contap_ContourGen::Init (const gp_Vec& Direction)
-
-{
- done = Standard_False;
- modeset = Standard_True;
- mySFunc.Set(Direction);
- myAFunc.Set(Direction);
-}
-
-
-void Contap_ContourGen::Init(const gp_Vec& Direction,
- const Standard_Real Angle)
-{
- done = Standard_False;
- modeset = Standard_True;
- mySFunc.Set(Direction,Angle);
- myAFunc.Set(Direction,Angle);
-}
-
-void Contap_ContourGen::Init (const gp_Pnt& Eye)
-{
- done = Standard_False;
- modeset = Standard_True;
- mySFunc.Set(Eye);
- myAFunc.Set(Eye);
-}
-
-
-void Contap_ContourGen::Perform (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain)
-{
- if (!modeset) {Standard_ConstructionError::Raise();}
- mySFunc.Set(Surf);
- myAFunc.Set(Surf);
-
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
- switch (typS) {
- case GeomAbs_Plane:
- case GeomAbs_Sphere:
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- {
- PerformAna(Domain); //Surf,Domain,Direction,0.,gp_Pnt(0.,0.,0.),1);
- }
- break;
-
- default:
- {
- Perform(Domain); //Surf,Domain,Direction,0.,gp_Pnt(0.,0.,0.),1);
- }
- break;
- }
-
-}
-
-
-void Contap_ContourGen::Perform (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain,
- const gp_Vec& Direction)
-
-{
- Init(Direction);
- Perform(Surf,Domain);
-}
-
-void Contap_ContourGen::Perform (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain,
- const gp_Vec& Direction,
- const Standard_Real Angle)
-
-{
- Init(Direction,Angle);
- Perform(Surf,Domain);
-}
-
-
-void Contap_ContourGen::Perform (const TheSurface& Surf,
- const Handle(TheTopolTool)& Domain,
- const gp_Pnt& Eye)
-
-{
- Init(Eye);
- Perform(Surf,Domain);
-}
-
-
+++ /dev/null
-// Created on: 1993-02-05
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <math_Vector.hxx>
-#include <math_Matrix.hxx>
-#include <TopTrans_CurveTransition.hxx>
-#include <TopAbs_State.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp.hxx>
-#include <IntSurf_InteriorPoint.hxx>
-
-#include <IntSurf_TypeTrans.hxx>
-
-#include <Precision.hxx>
-
-#include <BndLib_AddSurface.hxx>
-#include <Bnd_Box.hxx>
-
-
-#include <ElSLib.hxx>
-
-#define tole 5.e-6
-
-
-
-
-
-static IntSurf_TypeTrans ComputeTransitionOnLine
- (Contap_TheSurfFunction&,
- const Standard_Real,
- const Standard_Real,
- const gp_Vec&);
-
-
-static IntSurf_TypeTrans ComputeTransitionOngpCircle
- (Contap_TheSurfFunction&,
- const gp_Circ&);
-
-
-static IntSurf_TypeTrans ComputeTransitionOngpLine
- (Contap_TheSurfFunction&,
- const gp_Lin&);
-
-
-static void ComputeInternalPoints
- (Contap_TheLine& Line,
- Contap_TheSurfFunction&,
- const Standard_Real ureso,
- const Standard_Real vreso);
-
-
-static void ComputeInternalPointsOnRstr
- (Contap_TheLine&,
- const Standard_Real,
- const Standard_Real,
- Contap_TheSurfFunction&);
-
-static void ProcessSegments (const Contap_TheSearch&,
- Contap_TheSequenceOfLine&,
- const Standard_Real,
- Contap_TheSurfFunction&,
- const Handle(TheTopolTool)&);
-
-//-- --------------------------------------------------------------------------------
-//-- Recherche des portions utiles sur les lignes
-
-
-static void Recadre(const TheSurface& myHS1,
- Standard_Real& u1,
- Standard_Real& v1) {
- Standard_Real f,l,lmf;
- GeomAbs_SurfaceType typs1 = myHS1->GetType();
-
- Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
- switch (typs1) {
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- {
- myHS1IsUPeriodic = Standard_True;
- myHS1IsVPeriodic = Standard_False;
- break;
- }
- case GeomAbs_Torus:
- {
- myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True;
- break;
- }
- default:
- {
- myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False;
- break;
- }
- }
- if(myHS1IsUPeriodic) {
- lmf = M_PI+M_PI; //-- myHS1->UPeriod();
- f = myHS1->FirstUParameter();
- l = myHS1->LastUParameter();
- while(u1 < f) { u1+=lmf; }
- while(u1 > l) { u1-=lmf; }
- }
- if(myHS1IsVPeriodic) {
- lmf = M_PI+M_PI; //-- myHS1->VPeriod();
- f = myHS1->FirstVParameter();
- l = myHS1->LastVParameter();
- while(v1 < f) { v1+=lmf; }
- while(v1 > l) { v1-=lmf; }
- }
-}
-
-
-static void LineConstructor(Contap_TheSequenceOfLine& slin,
- const Handle(TheTopolTool)& Domain,
- Contap_TheLine& L,
- const TheSurface& Surf) {
-
- //-- ------------------------------------------------------------
- //-- on decoupe la ligne en portions entre 2 vertex
- Standard_Real Tol = Precision::PConfusion();
- Contap_IType typl = L.TypeContour();
- //-- cout<<"\n ----------- Ligne Constructor "<<endl;
- if(typl == Contap_Walking) {
- Standard_Real u1,v1,u2,v2;
- Standard_Integer nbvtx = L.NbVertex();
- //-- cout<<" WLine -> "<<nbvtx<<" vtx"<<endl;
- for(Standard_Integer i=1;i<nbvtx;i++) {
- Standard_Integer firstp = (Standard_Integer) L.Vertex(i).ParameterOnLine();
- Standard_Integer lastp = (Standard_Integer) L.Vertex(i+1).ParameterOnLine();
- if(firstp!=lastp) {
- Standard_Integer pmid = (firstp+lastp)/2; //-- entiers
- const IntSurf_PntOn2S& Pmid = L.Point(pmid);
- Pmid.Parameters(u1,v1,u2,v2);
- Recadre(Surf,u2,v2);
- TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
- if(in2 == TopAbs_OUT) {
- }
- else {
- //-- cout<<"ContapWLine : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
- Handle(IntSurf_LineOn2S) LineOn2S = new IntSurf_LineOn2S();
- Contap_TheLine Line;
- for(Standard_Integer j=firstp; j<=lastp; j++) {
- LineOn2S->Add(L.Point(j));
- }
- Line.SetLineOn2S(LineOn2S);
- Contap_ThePoint pvtx = L.Vertex(i);
- pvtx.SetParameter(1);
- Line.Add(pvtx);
-
- pvtx = L.Vertex(i+1);
- pvtx.SetParameter(lastp-firstp+1);
- Line.Add(pvtx);
- Line.SetTransitionOnS(L.TransitionOnS());
- slin.Append(Line);
- }
- }
- }
- }
- else if(typl==Contap_Lin) {
- Standard_Real u2,v2;// u1,v1;
- Standard_Integer nbvtx = L.NbVertex();
- //-- cout<<" Lin -> "<<nbvtx<<" vtx"<<endl;
- for(Standard_Integer i=1;i<nbvtx;i++) {
- Standard_Real firstp = L.Vertex(i).ParameterOnLine();
- Standard_Real lastp = L.Vertex(i+1).ParameterOnLine();
- if(firstp!=lastp) {
- Standard_Real pmid = (firstp+lastp)*0.5;
- gp_Pnt Pmid = ElCLib::Value(pmid,L.Line());
- if(TheSurfaceTool::GetType(Surf)==GeomAbs_Cylinder) {
- ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),Pmid,u2,v2);
- }
- else if(TheSurfaceTool::GetType(Surf)==GeomAbs_Cone) {
- ElSLib::Parameters(TheSurfaceTool::Cone(Surf),Pmid,u2,v2);
- }
- else {
- //-- cout<<" Pb ds Contap_ContourGen_2.gxx (type)"<<endl;
- }
-
- Recadre(Surf,u2,v2);
- TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
- if(in2 == TopAbs_OUT) {
- }
- else {
- //-- cout<<"Contap Lin : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
- Contap_TheLine Line;
- Line.SetValue(L.Line());
- Contap_ThePoint pvtx = L.Vertex(i);
- Line.Add(pvtx);
-
- pvtx = L.Vertex(i+1);
- Line.Add(pvtx);
- Line.SetTransitionOnS(L.TransitionOnS());
- slin.Append(Line);
- }
- }
- }
- }
- else if(typl==Contap_Circle) {
- Standard_Real u2,v2; //u1,v1,
- Standard_Integer nbvtx = L.NbVertex();
- //-- cout<<" Circ -> "<<nbvtx<<" vtx"<<endl;
- Standard_Boolean novtx = Standard_True;
- if(nbvtx) novtx=Standard_False;
- for(Standard_Integer i=1;i<nbvtx || novtx;i++) {
- Standard_Real firstp=0,lastp=M_PI+M_PI;
- if(novtx == Standard_False) {
- firstp = L.Vertex(i).ParameterOnLine();
- lastp = L.Vertex(i+1).ParameterOnLine();
- }
- if(Abs(firstp-lastp)>0.000000001) {
- Standard_Real pmid = (firstp+lastp)*0.5;
- gp_Pnt Pmid = ElCLib::Value(pmid,L.Circle());
- if(TheSurfaceTool::GetType(Surf)==GeomAbs_Cylinder) {
- ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),Pmid,u2,v2);
- }
- else if(TheSurfaceTool::GetType(Surf)==GeomAbs_Cone) {
- ElSLib::Parameters(TheSurfaceTool::Cone(Surf),Pmid,u2,v2);
- }
- else if(TheSurfaceTool::GetType(Surf)==GeomAbs_Sphere) {
- ElSLib::Parameters(TheSurfaceTool::Sphere(Surf),Pmid,u2,v2);
- }
- else {
- //-- cout<<" Pb ds Contap_ContourGen_2.gxx (typep)"<<endl;
- }
-
- Recadre(Surf,u2,v2);
- TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
- if(in2 == TopAbs_OUT) {
- }
- else {
- //-- cout<<"Contap Circle : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
- Contap_TheLine Line;
- Line.SetValue(L.Circle());
- if(novtx == Standard_False) {
- Contap_ThePoint pvtx = L.Vertex(i);
- Line.Add(pvtx);
- pvtx = L.Vertex(i+1);
- Line.Add(pvtx);
- }
- Line.SetTransitionOnS(L.TransitionOnS());
- slin.Append(Line);
- }
- }
- novtx = Standard_False;
- }
- if(nbvtx) {
- Standard_Real firstp = L.Vertex(nbvtx).ParameterOnLine();
- Standard_Real lastp = L.Vertex(1).ParameterOnLine() + M_PI+M_PI;
- if(Abs(firstp-lastp)>0.0000000001) {
- Standard_Real pmid = (firstp+lastp)*0.5;
- gp_Pnt Pmid = ElCLib::Value(pmid,L.Circle());
- if(TheSurfaceTool::GetType(Surf)==GeomAbs_Cylinder) {
- ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),Pmid,u2,v2);
- }
- else if(TheSurfaceTool::GetType(Surf)==GeomAbs_Cone) {
- ElSLib::Parameters(TheSurfaceTool::Cone(Surf),Pmid,u2,v2);
- }
- else if(TheSurfaceTool::GetType(Surf)==GeomAbs_Sphere) {
- ElSLib::Parameters(TheSurfaceTool::Sphere(Surf),Pmid,u2,v2);
- }
- else {
- //-- cout<<" Pb ds Contap_ContourGen_2.gxx (typep)"<<endl;
- }
-
- Recadre(Surf,u2,v2);
- TopAbs_State in2 = Domain->Classify(gp_Pnt2d(u2,v2),Tol);
- if(in2 == TopAbs_OUT) {
- }
- else {
- //-- cout<<"Contap Circle *Compl* : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
- Contap_TheLine Line;
- Line.SetValue(L.Circle());
- Contap_ThePoint pvtx = L.Vertex(nbvtx);
- Line.Add(pvtx);
-
- pvtx = L.Vertex(1); pvtx.SetParameter(pvtx.ParameterOnLine()+M_PI+M_PI);
- Line.Add(pvtx);
- Line.SetTransitionOnS(L.TransitionOnS());
- slin.Append(Line);
- }
- }
- }
- }
- else {
- //-- cout<<" ni WLine ni Lin ni Circ "<<endl;
- slin.Append(L);
- }
- //--
-}
-
-//-- --------------------------------------------------------------------------------
-
-
-
-static void KeepInsidePoints(const Contap_TheSearchInside& solins,
- const Contap_TheSearch& solrst,
- Contap_TheSurfFunction& Func,
- IntSurf_SequenceOfInteriorPoint& seqpins)
-
-{
- Standard_Integer Nba = solrst.NbSegments();
- if (Nba <= 0) return;
- Standard_Integer Nbp,indp,inda;
- Standard_Real U,V,paramproj;
- gp_Pnt2d toproj,Ptproj;
- Standard_Boolean projok,tokeep;
- const TheSurface& Surf = Func.Surface();
-
- Nbp = solins.NbPoints();
- for (indp=1; indp <= Nbp; indp++) {
- tokeep = Standard_True;
- const IntSurf_InteriorPoint& pti = solins.Value(indp);
- pti.Parameters(U,V);
- toproj = gp_Pnt2d(U,V);
- for (inda = 1; inda <= Nba; inda++) {
- const TheArc& thearc = solrst.Segment(inda).Curve();
- projok = TheContTool::Project(thearc,toproj,paramproj,Ptproj);
- if (projok) {
- gp_Pnt pprojete = TheSurfaceTool::Value(Surf,Ptproj.X(),Ptproj.Y());
- if (pti.Value().Distance(pprojete) <= Precision::Confusion()) {
- tokeep = Standard_False;
- break;
- }
- }
- }
- if (tokeep) {
- seqpins.Append(pti);
- }
- }
-}
-
-
-static void ComputeTangency (const Contap_TheSearch& solrst,
- const Handle(TheTopolTool)& Domain,
- Contap_TheSurfFunction& Func,
- IntSurf_SequenceOfPathPoint& seqpdep,
- TColStd_Array1OfInteger& Destination)
-{
-
- Standard_Integer i,k;
- Standard_Integer NbPoints = solrst.NbPoints();
- Standard_Integer seqlength = 0;
-
- Standard_Real theparam,test;
- Standard_Boolean fairpt;
- TopAbs_Orientation arcorien,vtxorien;
- Standard_Boolean ispassing;
-
- math_Vector X(1, 2);
- math_Vector F(1, 1);
- math_Matrix D(1, 1, 1, 2);
-
- gp_Vec normale, vectg, tg3drst,v1,v2;
- gp_Dir2d dirtg;
- gp_Vec2d tg2drst;
- gp_Pnt2d pt2d;
-
- IntSurf_PathPoint PPoint;
- const TheSurface& Surf = Func.Surface();
-
- for (i=1; i<= NbPoints; i++) {
-
- if (Destination(i) == 0) {
-
- const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
- const TheArc& thearc = PStart.Arc();
- theparam = PStart.Parameter();
- gp_Pnt2d Ptoproj=TheArcTool::Value(thearc,theparam);
- //-- lbr le 15 mai 97
- //-- On elimine les points qui sont egalement present sur une restriction solution
- Standard_Boolean SurUneRestrictionSolution = Standard_False;
- for(Standard_Integer restriction=1;
- SurUneRestrictionSolution==Standard_False && restriction<=solrst.NbSegments();
- restriction++) {
- const TheArc& thearcsol = solrst.Segment(restriction).Curve();
- Standard_Real paramproj;
- gp_Pnt2d pproj;
- Standard_Boolean projok = TheContTool::Project(thearcsol,Ptoproj,paramproj,pproj);
- if(projok) {
- //gp_Pnt pprojete = TheSurfaceTool::Value(Surf,Ptoproj.X(),Ptoproj.Y());
- //IFV - begin
- gp_Pnt pprojete = TheSurfaceTool::Value(Surf,pproj.X(),pproj.Y());
- //IFV - end
- if ((PStart.Value()).Distance(pprojete) <= Precision::Confusion()) {
- SurUneRestrictionSolution = Standard_True;
- }
- }
- }
- if(SurUneRestrictionSolution == Standard_False) {
- arcorien = Domain->Orientation(thearc);
- ispassing = (arcorien == TopAbs_INTERNAL ||
- arcorien == TopAbs_EXTERNAL);
-
- TheArcTool::D1(thearc,theparam,pt2d,tg2drst);
- X(1) = pt2d.X();
- X(2) = pt2d.Y();
- PPoint.SetValue(PStart.Value(),X(1),X(2));
-
- Func.Values(X,F,D);
- if (Func.IsTangent()) {
- PPoint.SetTangency(Standard_True);
- Destination(i) = seqlength+1;
- if (!PStart.IsNew()) {
- const TheVertex& vtx = PStart.Vertex();
- for (k=i+1; k<=NbPoints; k++) {
- if (Destination(k) ==0) {
- const Contap_ThePathPointOfTheSearch& PStart2 = solrst.Point(k);
- if (!PStart2.IsNew()) {
- const TheVertex& vtx2 = PStart2.Vertex();
- if (Domain->Identical(vtx,vtx2)) {
- const TheArc& thearc2 = PStart2.Arc();
- theparam = PStart2.Parameter();
- arcorien = Domain->Orientation(thearc2);
- ispassing = ispassing && (arcorien == TopAbs_INTERNAL ||
- arcorien == TopAbs_EXTERNAL);
-
- pt2d = TheArcTool::Value(thearc2,theparam);
- X(1) = pt2d.X();
- X(2) = pt2d.Y();
- PPoint.AddUV(X(1),X(2));
- Destination(k) = seqlength+1;
- }
- }
- }
- }
- }
- PPoint.SetPassing(ispassing);
- seqpdep.Append(PPoint);
- seqlength++;
- }
- else { // on a un point de depart potentiel
-
- vectg = Func.Direction3d();
- dirtg = Func.Direction2d();
-
- gp_Pnt ptbid;
- // TheSurfaceTool::D1(Surf,X(1),X(2),ptbid,v1,v2);
- Contap_TheSurfProps::DerivAndNorm(Surf,X(1),X(2),ptbid,v1,v2,normale);
- tg3drst = tg2drst.X()*v1 + tg2drst.Y()*v2;
- // normale = v1.Crossed(v2);
- if(normale.SquareMagnitude() < RealEpsilon()) {
- //-- cout<<"\n*** Contap_ContourGen_2.gxx Normale Nulle en U:"<<X(1)<<" V:"<<X(2)<<endl;
- }
- else {
- test = vectg.Dot(normale.Crossed(tg3drst));
-
- if (PStart.IsNew()) {
- Standard_Real tbis = vectg.Normalized().Dot(tg3drst.Normalized());
- if (Abs(tbis) < 1.-tole) {
-
- if ((test < 0. && arcorien == TopAbs_FORWARD) ||
- (test > 0. && arcorien == TopAbs_REVERSED)) {
- vectg.Reverse();
- dirtg.Reverse();
- }
- PPoint.SetDirections(vectg,dirtg);
- }
- else { // on garde le point comme point d`arret (tangent)
- PPoint.SetTangency(Standard_True);
- }
- PPoint.SetPassing(ispassing);
- Destination(i) = seqlength+1;
- seqpdep.Append(PPoint);
- seqlength++;
- }
- else { // traiter la transition complexe
- gp_Dir bidnorm(1.,1.,1.);
-
- Standard_Boolean tobeverified = Standard_False;
- TopAbs_Orientation LocTrans;
- TopTrans_CurveTransition comptrans;
- comptrans.Reset(vectg,bidnorm,0.);
- if (arcorien != TopAbs_INTERNAL &&
- arcorien != TopAbs_EXTERNAL) {
- // pour essai
- const TheVertex& vtx = PStart.Vertex();
- vtxorien = Domain->Orientation(vtx);
- test = test/(vectg.Magnitude());
- test = test/((normale.Crossed(tg3drst)).Magnitude());
-
- if (Abs(test) <= tole) {
- tobeverified = Standard_True;
- LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
- }
- else {
- if ((test > 0. && arcorien == TopAbs_FORWARD) ||
- (test < 0. && arcorien == TopAbs_REVERSED)){
- LocTrans = TopAbs_FORWARD;
- }
- else {
- LocTrans = TopAbs_REVERSED;
- }
- if (arcorien == TopAbs_REVERSED) {tg3drst.Reverse();} // pas deja fait ???
- }
-
- comptrans.Compare(tole,tg3drst,bidnorm,0.,LocTrans,vtxorien);
- }
- Destination(i) = seqlength+1;
- for (k= i+1; k<=NbPoints; k++) {
- if (Destination(k) == 0) {
- const Contap_ThePathPointOfTheSearch& PStart2 = solrst.Point(k);
- if (!PStart2.IsNew()) {
- const TheVertex& vtx2 = PStart2.Vertex();
- if (Domain->Identical(PStart.Vertex(),vtx2)) {
- const TheArc& thearc2 = PStart2.Arc();
- theparam = PStart2.Parameter();
- arcorien = Domain->Orientation(thearc2);
-
- TheArcTool::D1(thearc2,theparam,pt2d,tg2drst);
- X(1) = pt2d.X();
- X(2) = pt2d.Y();
- PPoint.AddUV(X(1),X(2));
-
- if (arcorien != TopAbs_INTERNAL &&
- arcorien != TopAbs_EXTERNAL) {
- ispassing = Standard_False;
- tg3drst = tg2drst.X()*v1 + tg2drst.Y()*v2;
- test = vectg.Dot(normale.Crossed(tg3drst));
- test = test/(vectg.Magnitude());
- test = test /((normale.Crossed(tg3drst)).Magnitude());
-
- vtxorien = Domain->Orientation(vtx2);
- if (Abs(test) <= tole) {
- tobeverified = Standard_True;
- LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
- }
- else {
- if ((test > 0. && arcorien == TopAbs_FORWARD) ||
- (test < 0. && arcorien == TopAbs_REVERSED)){
- LocTrans = TopAbs_FORWARD;
- }
- else {
- LocTrans = TopAbs_REVERSED;
- }
- if (arcorien == TopAbs_REVERSED) {tg3drst.Reverse();} //deja fait????
- }
-
- comptrans.Compare(tole,tg3drst,bidnorm,0.,LocTrans,vtxorien);
- }
- Destination(k) = seqlength+1;
- }
- }
- }
- }
- fairpt = Standard_True;
- if (!ispassing) {
- TopAbs_State Before = comptrans.StateBefore();
- TopAbs_State After = comptrans.StateAfter();
- if ((Before == TopAbs_UNKNOWN)||(After == TopAbs_UNKNOWN)) {
- fairpt = Standard_False;
- }
- else if (Before == TopAbs_IN) {
- if (After == TopAbs_IN) {
- ispassing = Standard_True;
- }
- else {
- vectg.Reverse();
- dirtg.Reverse();
- }
- }
- else {
- if (After !=TopAbs_IN) {
- fairpt = Standard_False;
- }
- }
- }
-
- // evite de partir le long d une restriction solution
-
- if (fairpt && tobeverified) {
- for (k=i; k <=NbPoints ; k++) {
- if (Destination(k)==seqlength + 1) {
- theparam = solrst.Point(k).Parameter();
- const TheArc& thearc2 = solrst.Point(k).Arc();
- arcorien = Domain->Orientation(thearc2);
-
- if (arcorien == TopAbs_FORWARD ||
- arcorien == TopAbs_REVERSED) {
- TheArcTool::D1(thearc2,theparam,pt2d,tg2drst);
- tg3drst = tg2drst.X()*v1 + tg2drst.Y()*v2;
- vtxorien = Domain->Orientation(solrst.Point(k).Vertex());
- if ((arcorien == TopAbs_FORWARD &&
- vtxorien == TopAbs_REVERSED) ||
- (arcorien == TopAbs_REVERSED &&
- vtxorien == TopAbs_FORWARD)) {
- tg3drst.Reverse();
- }
- test = vectg.Normalized().Dot(tg3drst.Normalized());
- if (test >= 1. - tole) {
- fairpt = Standard_False;
- break;
- }
- }
- }
- }
- }
-
- if (fairpt) {
- PPoint.SetDirections(vectg,dirtg);
- PPoint.SetPassing(ispassing);
- seqpdep.Append(PPoint);
- seqlength++;
- }
- else { // il faut remettre en "ordre" si on ne garde pas le point.
- for (k=i; k <=NbPoints ; k++) {
- if (Destination(k)==seqlength + 1) {
- Destination(k) = -Destination(k);
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-
-IntSurf_TypeTrans ComputeTransitionOnLine(Contap_TheSurfFunction& SFunc,
- const Standard_Real u,
- const Standard_Real v,
- const gp_Vec& tgline)
-{
- gp_Vec d1u,d1v;
- gp_Pnt pntbid;
- //gp_Vec tglineuv;
-
- TheSurfaceTool::D1(SFunc.Surface(),u,v,pntbid,d1u,d1v);
-
- //------------------------------------------------------
- //-- Calcul de la tangente dans l espace uv ---
- //------------------------------------------------------
-
- Standard_Real det,d1uT,d1vT,normu2,normv2,d1ud1v,alpha,beta;
- d1uT = d1u.Dot(tgline);
- d1vT = d1v.Dot(tgline);
- normu2 = d1u.Dot(d1u);
- normv2 = d1v.Dot(d1v);
- d1ud1v = d1u.Dot(d1v);
- det = normu2 * normv2 - d1ud1v * d1ud1v;
- if(det<RealEpsilon()) {
- //-- On ne doit pas passer ici !!
- //-- cout<<" Probleme !!!"<<endl ;
- return IntSurf_Undecided;
- }
-
- alpha = (d1uT * normv2 - d1vT * d1ud1v)/det;
- beta = (normu2 * d1vT - d1ud1v * d1uT)/det;
- //-----------------------------------------------------
- //-- Calcul du Gradient de la fonction Utilisee --
- //-- pour le contour apparent --
- //-----------------------------------------------------
-
- Standard_Real v1,v2;
- math_Vector X(1,2);
- math_Matrix Df(1,1,1,2);
- X(1) = u;
- X(2) = v;
- SFunc.Derivatives(X,Df);
- v1 = Df(1,1);
- v2 = Df(1,2);
-
- //-----------------------------------------------------
- //-- On calcule si la fonction --
- //-- F(.) = Normale . Dir_Regard --
- //-- Croit Losrque l on se deplace sur la Gauche --
- //-- de la direction de deplacement sur la ligne. --
- //-----------------------------------------------------
-
- det = -v1*beta + v2*alpha;
-
- if(det<RealEpsilon()) { // revoir le test jag 940620
- return IntSurf_Undecided;
- }
- if(det>0.0) {
- return(IntSurf_Out);
- }
- return(IntSurf_In);
-}
-
-
-void ProcessSegments (const Contap_TheSearch& solrst,
- Contap_TheSequenceOfLine& slin,
- const Standard_Real TolArc,
- Contap_TheSurfFunction& SFunc,
- const Handle(TheTopolTool)& Domain)
-
-{
- Standard_Integer i,j,k;
- Standard_Integer nbedg = solrst.NbSegments();
- Standard_Integer Nblines,Nbpts;
-
- TheArc arcRef;
- Contap_ThePoint ptvtx;
-
- Contap_ThePathPointOfTheSearch PStartf,PStartl;
-
- Standard_Boolean dofirst,dolast,procf,procl;
- Standard_Real paramf =0.,paraml =0.,U;
- Contap_TheLine theline;
-
- gp_Vec tgline;//,norm1,norm2;
- gp_Pnt valpt;
-
- gp_Vec d1u,d1v;
- gp_Pnt2d p2d;
- gp_Vec2d d2d;
-
-
- for (i = 1; i <= nbedg; i++) {
-
- const Contap_TheSegmentOfTheSearch& thesegsol = solrst.Segment(i);
- theline.SetValue(thesegsol.Curve());
-
-// Traitement des points debut/fin du segment solution.
-
- dofirst = Standard_False;
- dolast = Standard_False;
- procf = Standard_False;
- procl = Standard_False;
-
- if (thesegsol.HasFirstPoint()) {
- dofirst = Standard_True;
- PStartf = thesegsol.FirstPoint();
- paramf = PStartf.Parameter();
- }
- if (thesegsol.HasLastPoint()) {
- dolast = Standard_True;
- PStartl = thesegsol.LastPoint();
- paraml = PStartl.Parameter();
- }
-
- // determination de la transition
- if (dofirst && dolast) {
- U = (paramf+paraml)/2.;
- }
- else if (dofirst) {
- U = paramf + 1.0;
- }
- else if (dolast) {
- U = paraml - 1.0;
- }
- else {
- U = 0.0;
- }
-
- TheArcTool::D1(thesegsol.Curve(),U,p2d,d2d);
- TheSurfaceTool::D1(SFunc.Surface(),p2d.X(),p2d.Y(),valpt,d1u,d1v);
- tgline.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
- IntSurf_TypeTrans tral =
- ComputeTransitionOnLine(SFunc,p2d.X(),p2d.Y(),tgline);
-
- theline.SetTransitionOnS(tral);
-
-
- if (dofirst || dolast) {
- Nblines = slin.Length();
- for (j=1; j<=Nblines; j++) {
- Nbpts = slin(j).NbVertex();
- for (k=1; k<=Nbpts;k++) {
- ptvtx = slin(j).Vertex(k);
- if (dofirst) {
- if (ptvtx.Value().Distance(PStartf.Value()) <=TolArc) {
- slin(j).Vertex(k).SetMultiple();
- ptvtx.SetMultiple();
- ptvtx.SetParameter(paramf);
- theline.Add(ptvtx);
- procf=Standard_True;
- }
- }
- if (dolast) {
- if (ptvtx.Value().Distance(PStartl.Value()) <=TolArc) {
- slin(j).Vertex(k).SetMultiple();
- ptvtx.SetMultiple();
- ptvtx.SetParameter(paraml);
- theline.Add(ptvtx);
- procl=Standard_True;
- }
- }
- }
-// Si on a traite le pt debut et/ou fin, on ne doit pas recommencer si
-// il (ils) correspond(ent) a un point multiple.
-
- if (procf) {
- dofirst = Standard_False;
- }
- if (procl) {
- dolast = Standard_False;
- }
- }
- }
-
-// Si on n a pas trouve le point debut et./ou fin sur une des lignes
-// d intersection, il faut quand-meme le placer sur la restriction solution
-
- if (dofirst) {
-
- p2d = TheArcTool::Value(thesegsol.Curve(),paramf);
- ptvtx.SetValue(PStartf.Value(),p2d.X(),p2d.Y());
- ptvtx.SetParameter(paramf);
- if (! PStartf.IsNew()) {
- ptvtx.SetVertex(PStartf.Vertex());
- }
- theline.Add(ptvtx);
- }
- if (dolast) {
- p2d = TheArcTool::Value(thesegsol.Curve(),paraml);
- ptvtx.SetValue(PStartl.Value(),p2d.X(),p2d.Y());
- ptvtx.SetParameter(paraml);
- if (! PStartl.IsNew()) {
- ptvtx.SetVertex(PStartl.Vertex());
- }
- theline.Add(ptvtx);
- }
-
- // il faut chercher le points internal sur les restrictions solutions.
- if (thesegsol.HasFirstPoint() && thesegsol.HasLastPoint()) {
- ComputeInternalPointsOnRstr(theline,paramf,paraml,SFunc);
- }
- LineConstructor(slin,Domain,theline,SFunc.Surface()); //-- lbr
- //-- slin.Append(theline);
- theline.Clear();
- }
-}
-
-void ComputeInternalPointsOnRstr
- (Contap_TheLine& Line,
- const Standard_Real Paramf,
- const Standard_Real Paraml,
- Contap_TheSurfFunction& SFunc)
-{
- // On recherche les points ou la tangente a la ligne de contour et
- // la direction sont alignees.
- // 1ere etape : recherche de changement de signe.
- // 2eme etape : localisation de la solution par dichotomie
-
-
- Standard_Integer indexinf,indexsup,i;
- gp_Vec tgt, vecref, vectest, vtestb, vecregard,d1u,d1v;
- gp_Pnt pcour;
- gp_Pnt2d p2d;
- gp_Vec2d d2d;
- Standard_Boolean found,ok = Standard_False,toutvu,solution;
- Standard_Real paramp = 0.,paraminf,paramsup,toler;
-
- if (Line.TypeContour() != Contap_Restriction) {
- return;
- }
-
- const TheArc& thearc = Line.Arc();
-
- const TheSurface& Surf = SFunc.Surface();
- Contap_TFunction TypeFunc(SFunc.FunctionType());
-
- Standard_Integer Nbpnts = TheContTool::NbSamplesOnArc(thearc);
- indexinf = 1;
- vecregard = SFunc.Direction();
- toler = TheArcTool::Resolution(thearc,Precision::Confusion());
- found = Standard_False;
-
- do {
- paraminf = ((Nbpnts-indexinf)*Paramf + (indexinf-1)*Paraml)/(Nbpnts-1);
- TheArcTool::D1(thearc,paraminf,p2d,d2d);
- TheSurfaceTool::D1(Surf,p2d.X(),p2d.Y(),pcour,d1u,d1v);
- tgt.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
-
- if (tgt.Magnitude() > gp::Resolution()) {
- if (TypeFunc == Contap_ContourPrs || TypeFunc==Contap_DraftPrs) {
- vecregard.SetXYZ(pcour.XYZ()-SFunc.Eye().XYZ());
- }
- vecref = vecregard.Crossed(tgt);
-
- if (vecref.Magnitude() <= gp::Resolution()) {
- indexinf++;
- }
- else {
- found = Standard_True;
- }
- }
- else {
- indexinf++;
- }
- } while ((indexinf <= Nbpnts) && (!found));
-
-
- indexsup = indexinf +1;
- toutvu = (indexsup > Nbpnts);
- while (!toutvu) {
- paramsup = ((Nbpnts-indexsup)*Paramf + (indexsup-1)*Paraml)/(Nbpnts-1);
- TheArcTool::D1(thearc,paramsup,p2d,d2d);
- TheSurfaceTool::D1(Surf,p2d.X(),p2d.Y(),pcour,d1u,d1v);
- tgt.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
-
- if (tgt.Magnitude() > gp::Resolution()) {
- if (TypeFunc == Contap_ContourPrs || TypeFunc==Contap_DraftPrs) {
- vecregard.SetXYZ(pcour.XYZ()-SFunc.Eye().XYZ());
- }
- vectest = vecregard.Crossed(tgt);
- }
- else {
- vectest = gp_Vec(0.,0.,0.);
- }
- if (vectest.Magnitude() <= gp::Resolution()) {
- // On cherche un vrai changement de signe
- indexsup++;
- }
- else {
- if (vectest.Dot(vecref) < 0.) {
- // Essayer de converger
- // cout << "Changement de signe detecte" << endl;
- solution = Standard_False;
- while (!solution) {
- paramp = (paraminf+paramsup)/2.;
- TheArcTool::D1(thearc,paramp,p2d,d2d);
- TheSurfaceTool::D1(Surf,p2d.X(),p2d.Y(),pcour,d1u,d1v);
- tgt.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
-
- if (tgt.Magnitude() > gp::Resolution()) {
- if (TypeFunc == Contap_ContourPrs || TypeFunc==Contap_DraftPrs) {
- vecregard.SetXYZ(pcour.XYZ()-SFunc.Eye().XYZ());
- }
- vtestb = vecregard.Crossed(tgt);
- }
- else {
- vtestb = gp_Vec(0.,0.,0.);
- }
-
- if ((vtestb.Magnitude() <= gp::Resolution())||
- (Abs(paramp-paraminf) <= toler) ||
- (Abs(paramp-paramsup) <= toler)) {
- // on est a la solution
- solution = Standard_True;
- ok = Standard_True;
- }
- else if (vtestb.Dot(vecref) < 0.) {
- paramsup = paramp;
- }
- else {
- paraminf = paramp;
- }
-
- }
-
- if (ok) {
- // On verifie que le point trouve ne correspond pas a un ou des
- // vertex deja existant(s). On teste sur le parametre paramp.
- for (i=1; i<=Line.NbVertex(); i++) {
- Contap_ThePoint& thevtx = Line.Vertex(i);
- if (Abs(thevtx.ParameterOnLine()-paramp) <= toler) {
- thevtx.SetInternal();
- ok = Standard_False; // on a correspondance
- }
- }
- if (ok) { // il faut alors rajouter le point
- Contap_ThePoint internalp(pcour,p2d.X(),p2d.Y());
- internalp.SetParameter(paramp);
- internalp.SetInternal();
- Line.Add(internalp);
- }
- }
- paramsup = ((Nbpnts-indexsup)*Paramf + (indexsup-1)*Paraml)/(Nbpnts-1);
- }
- vecref = vectest;
- indexinf = indexsup;
- indexsup++;
- paraminf = paramsup;
- }
- toutvu = (indexsup > Nbpnts);
- }
-}
-
-
-void ComputeInternalPoints
- (Contap_TheLine& Line,
- Contap_TheSurfFunction& SFunc,
- const Standard_Real ureso,
- const Standard_Real vreso)
-
-{
- // On recherche les points ou la tangente a la ligne de contour et
- // la direction sont alignees.
- // 1ere etape : recheche de changement de signe.
- // 2eme etape : localisation de la solution par simili dichotomie
-
-
- Standard_Integer indexinf,indexsup,index;
- gp_Vec tgt, vecref, vectest, vtestb, vecregard;
- //gp_Pnt pprec,pcour;
- Standard_Boolean found,ok = Standard_False,toutvu,solution;
- Standard_Real paramp = 0.,U,V;
-
- math_Vector XInf(1,2),XSup(1,2),X(1,2),F(1,1);
- math_Matrix DF(1,1,1,2);
- math_Vector toler(1,2),infb(1,2),supb(1,2);
-
- if (Line.TypeContour() != Contap_Walking) {
- return;
- }
-
- Standard_Integer Nbpnts = Line.NbPnts();
- const TheSurface& Surf = SFunc.Surface();
- Contap_TFunction TypeFunc(SFunc.FunctionType());
-
- toler(1) = ureso; //-- Trop long !!! TheSurfaceTool::UResolution(Surf,SFunc.Tolerance());
- toler(2) = vreso; //---Beaucoup trop long !!! TheSurfaceTool::VResolution(Surf,SFunc.Tolerance());
- infb(1) = TheSurfaceTool::FirstUParameter(Surf);
- infb(2) = TheSurfaceTool::FirstVParameter(Surf);
- supb(1) = TheSurfaceTool::LastUParameter(Surf);
- supb(2) = TheSurfaceTool::LastVParameter(Surf);
-
- math_FunctionSetRoot rsnld(SFunc,toler,30);
-
- indexinf = 1;
- vecregard = SFunc.Direction();
-
- found = Standard_False;
- do {
- Line.Point(indexinf).ParametersOnS2(XInf(1),XInf(2));
- SFunc.Values(XInf,F,DF);
- if (!SFunc.IsTangent()) {
- tgt = SFunc.Direction3d();
- if (TypeFunc == Contap_ContourPrs || TypeFunc == Contap_DraftPrs) {
- vecregard.SetXYZ(Line.Point(indexinf).Value().XYZ()-SFunc.Eye().XYZ());
- }
- vecref = vecregard.Crossed(tgt);
-
- if (vecref.Magnitude() <= gp::Resolution()) {
- indexinf++;
- }
- else {
- found = Standard_True;
- }
- }
- else {
- indexinf++;
- }
- } while ((indexinf <= Nbpnts) && (!found));
-
-
- indexsup = indexinf +1;
- toutvu = (indexsup > Nbpnts);
- while (!toutvu) {
- Line.Point(indexsup).ParametersOnS2(XSup(1),XSup(2));
- SFunc.Values(XSup,F,DF);
- if (!SFunc.IsTangent()) {
- tgt = SFunc.Direction3d();
-
- if (TypeFunc == Contap_ContourPrs || TypeFunc == Contap_DraftPrs) {
- vecregard.SetXYZ(Line.Point(indexsup).Value().XYZ()-SFunc.Eye().XYZ());
- }
- vectest = vecregard.Crossed(tgt);
- }
- else {
- vectest = gp_Vec(0.,0.,0.);
- }
- if (vectest.Magnitude() <= gp::Resolution()) {
- // On cherche un vrai changement de signe
- indexsup++;
- }
- else {
- if (vectest.Dot(vecref) < 0.) {
- // Essayer de converger
- // cout << "Changement de signe detecte" << endl;
- solution = Standard_False;
- while (!solution) {
- X(1) = (XInf(1) + XSup(1)) /2.;
- X(2) = (XInf(2) + XSup(2)) /2.;
- rsnld.Perform(SFunc,X,infb,supb);
-
- if (!rsnld.IsDone()) {
- cout << "Echec recherche internal points" << endl;
- solution = Standard_True;
- ok = Standard_False;
- }
- else {
-
- rsnld.Root(X);
- SFunc.Values(X,F,DF);
- if (Abs(F(1)) <= SFunc.Tolerance()) {
-
- if (!SFunc.IsTangent()) {
- tgt = SFunc.Direction3d();
- if (TypeFunc == Contap_ContourPrs ||
- TypeFunc == Contap_DraftPrs) {
- vecregard.SetXYZ(SFunc.Point().XYZ()-SFunc.Eye().XYZ());
- }
- vtestb = vecregard.Crossed(tgt);
- }
- else {
- vtestb = gp_Vec(0.,0.,0.);
- }
- if ((vtestb.Magnitude() <= gp::Resolution())||
- (Abs(X(1)-XInf(1)) <= toler(1)
- && Abs(X(2)-XInf(2)) <= toler(2)) ||
- (Abs(X(1)-XSup(1)) <= toler(1)
- && Abs(X(2)-XSup(2)) <= toler(2))) {
- // on est a la solution
- solution = Standard_True;
- ok = Standard_True;
- }
- else if (vtestb.Dot(vecref) < 0.) {
- XSup = X;
- }
- else {
- XInf = X;
- }
- }
- else { // on n est pas sur une solution
- cout << "Echec recherche internal points" << endl;
- solution = Standard_True;
- ok = Standard_False;
- }
- }
- }
-
- if (ok) {
- Standard_Boolean newpoint = Standard_False;
- Line.Point(indexinf).ParametersOnS2(U,V);
- gp_Vec2d vinf(X(1)-U,X(2)-V);
- if (Abs(vinf.X()) <= toler(1) && Abs(vinf.Y()) <= toler(2)) {
- paramp = indexinf;
- }
- else {
- for (index = indexinf+1; index <= indexsup; index++) {
- Line.Point(index).ParametersOnS2(U,V);
- gp_Vec2d vsup(X(1)-U,X(2)-V);
- if (Abs(vsup.X()) <= toler(1) && Abs(vsup.Y()) <= toler(2)) {
- paramp = index;
- break;
- }
- else if (vinf.Dot(vsup) < 0.) {
- // on est entre les 2 points
- paramp = index;
- IntSurf_PntOn2S pt2s;
- pt2s.SetValue(SFunc.Point(),Standard_False,X(1),X(2));
- Line.LineOn2S()->InsertBefore(index,pt2s);
-
- //-- Il faut decaler les parametres des vertex situes entre
- //-- index et NbPnts ###################################
- for(Standard_Integer v=1; v<=Line.NbVertex(); v++) {
- Contap_ThePoint& Vertex = Line.Vertex(v);
- if(Vertex.ParameterOnLine() >= index) {
- Vertex.SetParameter(Vertex.ParameterOnLine()+1);
- }
- }
-
- Nbpnts = Nbpnts+1;
- indexsup = indexsup+1;
- newpoint = Standard_True;
- break;
- }
- else {
- vinf = vsup;
- }
- }
- }
-
- Standard_Integer v;
- if (!newpoint) {
- // on est sur un point de cheminement. On regarde alors
- // la correspondance avec un vertex existant.
- newpoint = Standard_True;
- for (v=1; v<= Line.NbVertex(); v++) {
- Contap_ThePoint& Vertex = Line.Vertex(v);
- if(Vertex.ParameterOnLine() == paramp) {
- Vertex.SetInternal();
- newpoint = Standard_False;
- }
- }
- }
-
- if (newpoint && paramp >1. && paramp < Nbpnts) {
- // on doit creer un nouveau vertex.
- Contap_ThePoint internalp(SFunc.Point(),X(1),X(2));
- internalp.SetParameter(paramp);
- internalp.SetInternal();
- Line.Add(internalp);
- }
- }
- Line.Point(indexsup).ParametersOnS2(XSup(1),XSup(2));
- }
- vecref = vectest;
- indexinf = indexsup;
- indexsup++;
- XInf = XSup;
- }
- toutvu = (indexsup > Nbpnts);
- }
-}
-
-
-void Contap_ContourGen::Perform
- (const Handle(TheTopolTool)& Domain) {
-
- done = Standard_False;
- slin.Clear();
-
- Standard_Integer i,j,k,Nbvt1,Nbvt2,ivt1,ivt2;
- Standard_Integer NbPointRst,NbPointIns;
- Standard_Integer Nblines, Nbpts, indfirst, indlast;
- Standard_Real U,V;
- gp_Pnt2d pt2d;
- gp_Vec2d d2d;
- gp_Pnt ptonsurf;
- gp_Vec d1u,d1v,normale,tgtrst,tgline;
- Standard_Real currentparam;
- IntSurf_Transition TLine,TArc;
-
- Contap_TheLine theline;
- Contap_ThePoint ptdeb,ptfin;
- Contap_ThePathPointOfTheSearch PStartf,PStartl;
-
-// Standard_Real TolArc = 1.e-5;
- Standard_Real TolArc = Precision::Confusion();
-
- const TheSurface& Surf = mySFunc.Surface();
-
- Standard_Real EpsU = TheSurfaceTool::UResolution(Surf,Precision::Confusion());
- Standard_Real EpsV = TheSurfaceTool::VResolution(Surf,Precision::Confusion());
- Standard_Real Preci = Min(EpsU,EpsV);
-// Standard_Real Fleche = 5.e-1;
-// Standard_Real Pas = 5.e-2;
- Standard_Real Fleche = 0.01;
- Standard_Real Pas = 0.005;
- // lbr: Il y avait Pas 0.2 -> Manque des Inters sur restr ; devrait faire un mini de 5 pts par lignes
- //-- le 23 janvier 98 0.05 -> 0.01
-
-
- //-- ******************************************************************************** Janvier 98
- Bnd_Box B1; Standard_Boolean Box1OK = Standard_True;
-
- Standard_Real Uinf = Surf->FirstUParameter();
- Standard_Real Vinf = Surf->FirstVParameter();
- Standard_Real Usup = Surf->LastUParameter();
- Standard_Real Vsup = Surf->LastVParameter();
-
- Standard_Boolean Uinfinfinite = Precision::IsNegativeInfinite(Uinf);
- Standard_Boolean Usupinfinite = Precision::IsPositiveInfinite(Usup);
- Standard_Boolean Vinfinfinite = Precision::IsNegativeInfinite(Vinf);
- Standard_Boolean Vsupinfinite = Precision::IsPositiveInfinite(Vsup);
-
- if( Uinfinfinite || Usupinfinite || Vinfinfinite || Vsupinfinite) {
- Box1OK = Standard_False;
- }
- else {
- BndLib_AddSurface::Add(Surf->Surface(),1e-8,B1);
- }
- Standard_Real x0,y0,z0,x1,y1,z1,dx,dy,dz;
- if(Box1OK) {
- B1.Get(x0,y0,z0,x1,y1,z1);
- dx=x1-x0;
- dy=y1-y0;
- dz=z1-z0;
- }
- else {
- dx=dy=dz=1.0;
- }
- if(dx<dy) dx=dy;
- if(dx<dz) dx=dz;
- if(dx>10000.0) dx=10000.0;
- Fleche*=dx;
- TolArc*=dx;
- //-- ********************************************************************************
-
-
- //gp_Pnt valpt;
-
-//jag 940616 SFunc.Set(1.e-8); // tolerance sur la fonction
- mySFunc.Set(Precision::Confusion()); // tolerance sur la fonction
-
- Standard_Boolean RecheckOnRegularity = Standard_True;
- solrst.Perform(myAFunc,Domain,TolArc,TolArc,RecheckOnRegularity);
-
- if (!solrst.IsDone()) {
- return;
- }
-
- NbPointRst = solrst.NbPoints();
- IntSurf_SequenceOfPathPoint seqpdep;
- TColStd_Array1OfInteger Destination(1,NbPointRst+1);
- Destination.Init(0);
- if (NbPointRst != 0) {
- ComputeTangency(solrst,Domain,mySFunc,seqpdep,Destination);
- }
-
- //jag 940616 solins.Perform(SFunc,Surf,Domain,1.e-6); // 1.e-6 : tolerance dans l espace.
- solins.Perform(mySFunc,Surf,Domain,Precision::Confusion());
-
- NbPointIns = solins.NbPoints();
- IntSurf_SequenceOfInteriorPoint seqpins;
-
- if (NbPointIns != 0) {
- Standard_Boolean bKeepAllPoints = Standard_False;
- //IFV begin
- if(solrst.NbSegments() <= 0) {
- if(mySFunc.FunctionType() == Contap_ContourStd) {
- const TheSurface& Surf = mySFunc.Surface();
- if(TheSurfaceTool::GetType(Surf) == GeomAbs_Torus) {
- gp_Torus aTor = TheSurfaceTool::Torus(Surf);
- gp_Dir aTorDir = aTor.Axis().Direction();
- gp_Dir aProjDir = mySFunc.Direction();
-
- if(aTorDir.Dot(aProjDir) < Precision::Confusion()) {
- bKeepAllPoints = Standard_True;
- }
- }
- }
- }
-
- if(bKeepAllPoints) {
- Standard_Integer Nbp = solins.NbPoints(), indp;
- for (indp=1; indp <= Nbp; indp++) {
- const IntSurf_InteriorPoint& pti = solins.Value(indp);
- seqpins.Append(pti);
- }
- }
- //IFV - end
- else {
- KeepInsidePoints(solins,solrst,mySFunc,seqpins);
- }
- }
-
- if (seqpdep.Length() != 0 || seqpins.Length() != 0) {
-
- Contap_TheIWalking iwalk(Preci,Fleche,Pas);
- iwalk.Perform(seqpdep,seqpins,mySFunc ,Surf);
- if(!iwalk.IsDone()) {
- return;
- }
-
- Nblines = iwalk.NbLines();
- for (j=1; j<=Nblines; j++) {
- IntSurf_TypeTrans TypeTransOnS = IntSurf_Undecided;
- const Handle(Contap_TheIWLineOfTheIWalking)& iwline = iwalk.Value(j);
- Nbpts = iwline->NbPoints();
- theline.SetLineOn2S(iwline->Line());
-
- // jag 941018 On calcule une seule fois la transition
-
- tgline = iwline->TangentVector(k);
- iwline->Line()->Value(k).ParametersOnS2(U,V);
- TypeTransOnS = ComputeTransitionOnLine(mySFunc,U,V,tgline);
- theline.SetTransitionOnS(TypeTransOnS);
-
- //---------------------------------------------------------------------
- //-- On ajoute a la liste des vertex les 1er et dernier points de la -
- //-- ligne de cheminement si ceux-ci ne sont pas presents -
- //---------------------------------------------------------------------
-
- if (iwline->HasFirstPoint()) {
- indfirst = iwline->FirstPointIndex();
- const IntSurf_PathPoint& PPoint = seqpdep(indfirst);
- Standard_Integer themult = PPoint.Multiplicity();
- for (i=NbPointRst; i>=1; i--) {
- if (Destination(i) == indfirst) {
- PPoint.Parameters(themult,U,V);
- ptdeb.SetValue(PPoint.Value(),U,V);
- ptdeb.SetParameter(1.0);
-
- const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
- const TheArc& currentarc = PStart.Arc();
- currentparam = PStart.Parameter();
- if (!iwline->IsTangentAtBegining()) {
-
- TheArcTool::D1(currentarc,currentparam,pt2d,d2d);
- Contap_TheSurfProps::DerivAndNorm(Surf,pt2d.X(),pt2d.Y(),
- ptonsurf,d1u,d1v,normale);
- tgtrst = d2d.X()*d1u;
- tgtrst.Add(d2d.Y()*d1v);
-
- IntSurf::MakeTransition(PPoint.Direction3d(),tgtrst,normale,
- TLine,TArc);
-
- }
- else {// a voir. En effet, on a cheminer. Si on est sur un point
- // debut, on sait qu'on rentre dans la matiere
- TLine.SetValue();
- TArc.SetValue();
- }
-
- ptdeb.SetArc(currentarc,currentparam,TLine,TArc);
-
- if (!solrst.Point(i).IsNew()) {
- ptdeb.SetVertex(PStart.Vertex());
- }
- theline.Add(ptdeb);
- themult--;
- }
- }
- }
- else {
- iwline->Value(1).ParametersOnS2(U,V);
- ptdeb.SetValue(theline.Point(1).Value(),U,V);
- ptdeb.SetParameter(1.0);
- theline.Add(ptdeb);
- }
-
- if (iwline->HasLastPoint()) {
- indlast = iwline->LastPointIndex();
- const IntSurf_PathPoint& PPoint = seqpdep(indlast);
- Standard_Integer themult = PPoint.Multiplicity();
- for (i=NbPointRst; i>=1; i--) {
- if (Destination(i) == indlast) {
- PPoint.Parameters(themult,U,V);
- ptfin.SetValue(PPoint.Value(),U,V);
- ptfin.SetParameter((Standard_Real)(Nbpts));
- const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
- const TheArc& currentarc = PStart.Arc();
- currentparam = PStart.Parameter();
-
- if (!iwline->IsTangentAtEnd()) {
-
- TheArcTool::D1(currentarc,currentparam,pt2d,d2d);
-
- Contap_TheSurfProps::DerivAndNorm(Surf,pt2d.X(),pt2d.Y(),
- ptonsurf,d1u,d1v,normale);
- tgtrst = d2d.X()*d1u;
- tgtrst.Add(d2d.Y()*d1v);
- IntSurf::MakeTransition(PPoint.Direction3d().Reversed(),
- tgtrst,normale,TLine,TArc);
- }
- else {
- TLine.SetValue();
- TArc.SetValue();
- }
-
- ptfin.SetArc(currentarc,currentparam,TLine,TArc);
-
- if (!solrst.Point(i).IsNew()) {
- ptfin.SetVertex(PStart.Vertex());
- }
- theline.Add(ptfin);
- themult--;
- }
- }
- }
- else {
- iwline->Value(Nbpts).ParametersOnS2(U,V);
- ptfin.SetValue(theline.Point(Nbpts).Value(),U,V);
- ptfin.SetParameter((Standard_Real)(Nbpts));
- theline.Add(ptfin);
- }
-
- ComputeInternalPoints(theline,mySFunc,EpsU,EpsV);
- LineConstructor(slin,Domain,theline,Surf); //-- lbr
- //-- slin.Append(theline);
- theline.ResetSeqOfVertex();
- }
-
-
- Nblines = slin.Length();
- for (j=1; j<=Nblines-1; j++) {
- const Contap_TheLine& theli = slin(j);
- Nbvt1 = theli.NbVertex();
- for (ivt1=1; ivt1<=Nbvt1; ivt1++) {
- if (!theli.Vertex(ivt1).IsOnArc()) {
- const gp_Pnt& pttg1 = theli.Vertex(ivt1).Value();
-
- for (k=j+1; k<=Nblines;k++) {
- const Contap_TheLine& theli2 = slin(k);
- Nbvt2 = theli2.NbVertex();
- for (ivt2=1; ivt2<=Nbvt2; ivt2++) {
- if (!theli2.Vertex(ivt2).IsOnArc()) {
- const gp_Pnt& pttg2 = theli2.Vertex(ivt2).Value();
-
- if (pttg1.Distance(pttg2) <= TolArc) {
- theli.Vertex(ivt1).SetMultiple();
- theli2.Vertex(ivt2).SetMultiple();
- }
- }
- }
- }
- }
- }
- }
- }
-
- // jag 940620 On ajoute le traitement des restrictions solutions.
-
- if (solrst.NbSegments() !=0) {
- ProcessSegments(solrst,slin,TolArc,mySFunc,Domain);
- }
-
-
- // Ajout crad pour depanner CMA en attendant mieux
- if (solrst.NbSegments() !=0) {
-
- Nblines = slin.Length();
- for (j=1; j<=Nblines; j++) {
- const Contap_TheLine& theli = slin(j);
- if (theli.TypeContour() == Contap_Walking) {
- Nbvt1 = theli.NbVertex();
- for (ivt1=1; ivt1<=Nbvt1; ivt1++) {
- Contap_ThePoint& ptvt = theli.Vertex(ivt1);
- if (!ptvt.IsOnArc() && !ptvt.IsMultiple()) {
- Standard_Real Up,Vp;
- ptvt.Parameters(Up,Vp);
- gp_Pnt2d toproj(Up,Vp);
- Standard_Boolean projok;
- for (k=1; k<=Nblines;k++) {
- if (slin(k).TypeContour() == Contap_Restriction) {
- const TheArc& thearc = slin(k).Arc();
- Standard_Real paramproj;
- gp_Pnt2d Ptproj;
- projok = TheContTool::Project(thearc,toproj,paramproj,Ptproj);
-
- if (projok) {
- Standard_Real dist = Ptproj.Distance(gp_Pnt2d(Up,Vp));
- if (dist <= Preci) {
- // Calcul de la transition
-
- TheArcTool::D1(thearc,paramproj,Ptproj,d2d);
-// TheSurfaceTool::D1(Surf,Ptproj.X(),Ptproj.Y(),
-// ptonsurf,d1u,d1v);
-// normale = d1u.Crossed(d1v);
-
- Contap_TheSurfProps::DerivAndNorm
- (Surf,Ptproj.X(),Ptproj.Y(),ptonsurf,d1u,d1v,normale);
-
- tgtrst = d2d.X()*d1u;
- tgtrst.Add(d2d.Y()*d1v);
- Standard_Integer Paraml =
- (Standard_Integer) ptvt.ParameterOnLine();
-
- if (Paraml == theli.NbPnts()) {
- tgline = gp_Vec(theli.Point(Paraml-1).Value(),
- ptvt.Value());
- }
- else {
- tgline = gp_Vec(ptvt.Value(),
- theli.Point(Paraml+1).Value());
- }
- IntSurf::MakeTransition(tgline,tgtrst,normale,
- TLine,TArc);
- ptvt.SetArc(thearc,paramproj,TLine,TArc);
- ptvt.SetMultiple();
- ptdeb.SetValue(ptonsurf,Ptproj.X(),Ptproj.Y());
- ptdeb.SetParameter(paramproj);
- ptdeb.SetMultiple();
- slin(k).Add(ptdeb);
- break;
- }
- else {
- projok = Standard_False;
- }
- }
- }
- else {
- projok = Standard_False;
- }
- if (projok) {
- break;
- }
- }
- }
- }
- }
- }
- }
- done = Standard_True;
-}
-
+++ /dev/null
-// Created on: 1993-02-05
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#define Tolpetit 1.e-10 // pour dist au carre
-#include <ElSLib.hxx>
-
-
-#include <TColStd_SequenceOfInteger.hxx>
-
-static Standard_Boolean FindLine(Contap_TheLine& Line,
- const TheSurface& Surf,
- const gp_Pnt2d& Pt2d,
- gp_Pnt& Ptref,
- Standard_Real& Paramin,
- gp_Vec& Tgmin,
- gp_Vec& Norm)
-{
-// Standard_Integer i;
- gp_Pnt pt,ptmin;
- gp_Vec tg;
- Standard_Real para,dist;
- Standard_Real dismin = RealLast();
-
- Contap_TheSurfProps::Normale(Surf,Pt2d.X(),Pt2d.Y(),Ptref,Norm);
-
- if (Line.TypeContour() == Contap_Lin) {
- gp_Lin lin(Line.Line());
- para = ElCLib::Parameter(lin,Ptref);
- ElCLib::D1(para,lin,pt,tg);
- dist = pt.Distance(Ptref) + Abs(Norm.Dot(lin.Direction()));
- }
- else { // Contap__Circle
- gp_Circ cir(Line.Circle());
- para = ElCLib::Parameter(cir,Ptref);
- ElCLib::D1(para,cir,pt,tg);
- dist = pt.Distance(Ptref)+Abs(Norm.Dot(tg/cir.Radius()));
- }
- if (dist < dismin) {
- dismin = dist;
- Paramin = para;
- ptmin = pt;
- Tgmin = tg;
- }
- if (ptmin.SquareDistance(Ptref) <= Tolpetit) {
- return Standard_True;
- }
- else {
- return Standard_False;
- }
-}
-
-
-static void PutPointsOnLine (const Contap_TheSearch& solrst,
- const TheSurface& Surf,
- Contap_TheSequenceOfLine& slin)
-
-{
- Standard_Integer i,l;//,index;
- Standard_Integer NbPoints = solrst.NbPoints();
-
- Standard_Real theparam;
-
- IntSurf_Transition TLine,TArc;
- Standard_Boolean goon;
-
- gp_Pnt2d pt2d;
- gp_Vec2d d2d;
-
- gp_Pnt ptonsurf;
- gp_Vec vectg,normale,tgtrst;
- Standard_Real paramlin = 0.0;
-
-
- Standard_Integer nbLin = slin.Length();
- for(l=1;l<=nbLin;l++) {
- Contap_TheLine& Line=slin.ChangeValue(l);
- for (i=1; i<= NbPoints; i++) {
-
- const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
- const TheArc& thearc = PStart.Arc();
- theparam = PStart.Parameter();
-
- TheArcTool::D1(thearc,theparam,pt2d,d2d);
- goon = FindLine(Line,Surf,pt2d,ptonsurf,paramlin,vectg,normale);
-
- Contap_ThePoint PPoint;
-
- if (goon) {
- gp_Vec d1u,d1v;
- gp_Pnt bidpt;
- TheSurfaceTool::D1(Surf,pt2d.X(),pt2d.Y(),bidpt,d1u,d1v);
- PPoint.SetValue(ptonsurf,pt2d.X(),pt2d.Y());
- if (normale.Magnitude() < RealEpsilon()) {
- TLine.SetValue();
- TArc.SetValue();
- }
- else {
- // Petit test qui devrait permettre de bien traiter les pointes
- // des cones, et les sommets d`une sphere. Il faudrait peut-etre
- // rajouter une methode dans SurfProps
-
- if (Abs(d2d.Y()) <= Precision::Confusion()) {
- tgtrst = d1v.Crossed(normale);
- if(d2d.X() < 0.0)
- tgtrst.Reverse();
- }
- else {
- tgtrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
- }
- IntSurf::MakeTransition(vectg,tgtrst,normale,TLine,TArc);
- }
-
- PPoint.SetArc(thearc,theparam, TLine, TArc);
- PPoint.SetParameter(paramlin);
- if (!PStart.IsNew()) {
- PPoint.SetVertex(PStart.Vertex());
- }
- Line.Add(PPoint);
- }
- }
- }
-}
-
-
-//----------------------------------------------------------------------------------
-//-- Orientation des contours Apparents quand ceux-ci sont des lignes ou des cercles
-//-- On prend un point de la ligne ou du cercle ---> P
-//-- On projete ce point sur la surface P ---> u,v
-//-- et on evalue la transition au point u,v
-//----------------------------------------------------------------------------------
-
-IntSurf_TypeTrans ComputeTransitionOngpLine
- (Contap_TheSurfFunction& SFunc,
- const gp_Lin& L)
-{
- const TheSurface& Surf=SFunc.Surface();
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
- gp_Pnt P;
- gp_Vec T;
- ElCLib::D1(0.0,L,P,T);
- Standard_Real u = 0.,v = 0.;
- switch (typS) {
- case GeomAbs_Cylinder: {
- ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),P,u,v);
- break;
- }
- case GeomAbs_Cone: {
- ElSLib::Parameters(TheSurfaceTool::Cone(Surf),P,u,v);
- break;
- }
- case GeomAbs_Sphere: {
- ElSLib::Parameters(TheSurfaceTool::Sphere(Surf),P,u,v);
- break;
- }
- default:
- break;
- }
- return(ComputeTransitionOnLine(SFunc,u,v,T));
-}
-
-
-IntSurf_TypeTrans ComputeTransitionOngpCircle
- (Contap_TheSurfFunction& SFunc,
- const gp_Circ& C)
-{
- const TheSurface& Surf=SFunc.Surface();
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
- gp_Pnt P;
- gp_Vec T;
- ElCLib::D1(0.0,C,P,T);
- Standard_Real u = 0.,v = 0.;
- switch (typS) {
- case GeomAbs_Cylinder: {
- ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),P,u,v);
- break;
- }
- case GeomAbs_Cone: {
- ElSLib::Parameters(TheSurfaceTool::Cone(Surf),P,u,v);
- break;
- }
- case GeomAbs_Sphere: {
- ElSLib::Parameters(TheSurfaceTool::Sphere(Surf),P,u,v);
- break;
- }
- default:
- break;
- }
- return(ComputeTransitionOnLine(SFunc,u,v,T));
-}
-
-
-void Contap_ContourGen::PerformAna(const Handle(TheTopolTool)& Domain)
-{
-
- done = Standard_False;
- slin.Clear();
-
- Standard_Real TolArc = 1.e-5;
-
- Standard_Integer nbCont, nbPointRst, i;
- //gp_Circ cirsol;
- //gp_Lin linsol;
- Contap_ContAna contana;
- Contap_TheLine theline;
- const TheSurface& Surf = mySFunc.Surface();
- Contap_TFunction TypeFunc(mySFunc.FunctionType());
- Standard_Boolean PerformSolRst = Standard_True;
-
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
-
- switch (typS) {
- case GeomAbs_Plane:
- {
- gp_Pln pl(TheSurfaceTool::Plane(Surf));
- switch (TypeFunc) {
- case Contap_ContourStd:
- {
- gp_Dir Dirpln(pl.Axis().Direction());
- if (Abs(mySFunc.Direction().Dot(Dirpln)) > Precision::Angular()) {
- // Aucun point du plan n`est solution, en particulier aucun point
- // sur restriction.
- PerformSolRst = Standard_False;
- }
- }
- break;
- case Contap_ContourPrs:
- {
- gp_Pnt Eye(mySFunc.Eye());
- if (pl.Distance(Eye) > Precision::Confusion()) {
- // Aucun point du plan n`est solution, en particulier aucun point
- // sur restriction.
- PerformSolRst = Standard_False;
- }
- }
- break;
- case Contap_DraftStd:
- {
- gp_Dir Dirpln(pl.Axis().Direction());
- Standard_Real Sina = Sin(mySFunc.Angle());
- if (Abs(mySFunc.Direction().Dot(Dirpln)+ Sina) > //voir SurfFunction
- Precision::Angular()) {
-
- PerformSolRst = Standard_False;
- }
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- }
- break;
-
- case GeomAbs_Sphere:
- {
- switch (TypeFunc) {
- case Contap_ContourStd:
- {
- contana.Perform(TheSurfaceTool::Sphere(Surf),mySFunc.Direction());
- }
- break;
- case Contap_ContourPrs:
- {
- contana.Perform(TheSurfaceTool::Sphere(Surf),mySFunc.Eye());
- }
- break;
- case Contap_DraftStd:
- {
- contana.Perform(TheSurfaceTool::Sphere(Surf),
- mySFunc.Direction(),mySFunc.Angle());
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- }
- break;
-
- case GeomAbs_Cylinder:
- {
- switch (TypeFunc) {
- case Contap_ContourStd:
- {
- contana.Perform(TheSurfaceTool::Cylinder(Surf),mySFunc.Direction());
- }
- break;
- case Contap_ContourPrs:
- {
- contana.Perform(TheSurfaceTool::Cylinder(Surf),mySFunc.Eye());
- }
- break;
- case Contap_DraftStd:
- {
- contana.Perform(TheSurfaceTool::Cylinder(Surf),
- mySFunc.Direction(),mySFunc.Angle());
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- }
- break;
-
- case GeomAbs_Cone:
- {
- switch (TypeFunc) {
- case Contap_ContourStd:
- {
- contana.Perform(TheSurfaceTool::Cone(Surf),mySFunc.Direction());
- }
- break;
- case Contap_ContourPrs:
- {
- contana.Perform(TheSurfaceTool::Cone(Surf),mySFunc.Eye());
- }
- break;
- case Contap_DraftStd:
- {
- contana.Perform(TheSurfaceTool::Cone(Surf),
- mySFunc.Direction(),mySFunc.Angle());
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- default:
- break;
- }
- break;
- }
-
- if (typS != GeomAbs_Plane) {
-
- if (!contana.IsDone()) {
- return;
- }
-
- nbCont = contana.NbContours();
-
- if (contana.NbContours() == 0) {
- done = Standard_True;
- return;
- }
-
- GeomAbs_CurveType typL = contana.TypeContour();
- if (typL == GeomAbs_Circle) {
- theline.SetValue(contana.Circle());
- IntSurf_TypeTrans TransCircle;
- TransCircle = ComputeTransitionOngpCircle(mySFunc,contana.Circle());
- theline.SetTransitionOnS(TransCircle);
- slin.Append(theline);
- }
- else if (typL == GeomAbs_Line) {
- for (i=1; i<=nbCont; i++) {
- theline.SetValue(contana.Line(i));
- IntSurf_TypeTrans TransLine;
- TransLine = ComputeTransitionOngpLine(mySFunc,contana.Line(i));
- theline.SetTransitionOnS(TransLine);
- slin.Append(theline);
- theline.Clear();
- }
-
-/*
- if (typS == GeomAbs_Cone) {
- Standard_Real u,v;
- gp_Cone thecone(TheSurfaceTool::Cone(Surf));
- ElSLib::Parameters(thecone,thecone.Apex(),u,v);
- Contap_ThePoint vtxapex(thecone.Apex(),u,v);
- vtxapex.SetInternal();
- vtxapex.SetMultiple();
- for (i=1; i<=nbCont i++) {
- slin.ChangeValue(i).Add(vtxapex);
- }
- }
-*/
- }
- }
-
- if(PerformSolRst) {
-
- solrst.Perform(myAFunc,Domain,TolArc,TolArc);
- if (!solrst.IsDone()) {
- return;
- }
- nbPointRst = solrst.NbPoints();
-
- if (nbPointRst != 0) {
- PutPointsOnLine(solrst,Surf,slin);
- }
-
- if (solrst.NbSegments() !=0) {
- ProcessSegments(solrst,slin,TolArc,mySFunc,Domain);
- }
-
-
- //-- lbr
- //Standard_Boolean oneremov;
- Standard_Integer nblinto = slin.Length();
- TColStd_SequenceOfInteger SeqToDestroy;
-
- //-- cout<<" Construct Contour_3 nblin = "<<nblinto<<endl;
- for(i=1; i<= nblinto ; i++) {
- //-- cout<<" nbvtx : "<<slin.Value(i).NbVertex()<<endl;
- //--if(slin.Value(i).NbVertex() > 1) {
- if(slin.Value(i).TypeContour() != Contap_Restriction) {
- LineConstructor(slin,Domain,slin.ChangeValue(i),Surf);
- SeqToDestroy.Append(i);
- }
- //-- }
- }
- for(i=SeqToDestroy.Length(); i>=1; i--) {
- slin.Remove(SeqToDestroy.Value(i));
- }
- }
-
- done = Standard_True;
-}
-
-
-
-
-
--- /dev/null
+-- Created on: 1995-07-02
+-- Created by: Laurent BUCHARD
+-- Copyright (c) 1995-1999 Matra Datavision
+-- Copyright (c) 1999-2014 OPEN CASCADE SAS
+--
+-- This file is part of Open CASCADE Technology software library.
+--
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
+-- by the Free Software Foundation, with special exception defined in the file
+-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+-- distribution for complete text of the license and disclaimer of any warranty.
+--
+-- Alternatively, this file may be used under the terms of Open CASCADE
+-- commercial license or contractual agreement.
+
+class HContTool from Contap
+
+ ---Purpose: Tool for the intersection between 2 surfaces.
+ -- Regroupe pour l instant les methodes hors Adaptor3d...
+
+
+uses
+ Pnt2d from gp,
+ Pnt from gp,
+ HVertex from Adaptor3d,
+ HCurve2d from Adaptor2d,
+ HSurface from Adaptor3d,
+ HCurve2dTool from Contap,
+ HSurfaceTool from Adaptor3d
+
+is
+
+ NbSamplesU(myclass; S: HSurface from Adaptor3d; u1,u2: Real from Standard)
+ returns Integer from Standard;
+
+ NbSamplesV(myclass; S: HSurface from Adaptor3d; v1,v2: Real from Standard)
+ returns Integer from Standard;
+
+-- Methodes pour recherche des points interieurs
+
+ NbSamplePoints(myclass; S: HSurface from Adaptor3d)
+
+ returns Integer from Standard;
+
+
+ SamplePoint(myclass; S : HSurface from Adaptor3d;
+ Index: Integer from Standard;
+ U,V: out Real from Standard);
+
+
+-- Methodes sur un arc de restriction
+
+ HasBeenSeen(myclass; C: HCurve2d from Adaptor2d)
+
+ ---Purpose: Returns True if all the intersection point and edges
+ -- are known on the Arc.
+ -- The intersection point are given as vertices.
+ -- The intersection edges are given as intervals between
+ -- two vertices.
+
+ returns Boolean from Standard;
+
+ NbSamplesOnArc(myclass; A: HCurve2d from Adaptor2d)
+
+ ---Purpose: returns the number of points which is used to make
+ -- a sample on the arc. this number is a function of
+ -- the Surface and the CurveOnSurface complexity.
+
+ returns Integer from Standard;
+
+
+ Bounds(myclass; C: HCurve2d from Adaptor2d;
+ Ufirst,Ulast: out Real from Standard);
+
+ ---Purpose: Returns the parametric limits on the arc C.
+ -- These limits must be finite : they are either
+ -- the real limits of the arc, for a finite arc,
+ -- or a bounding box for an infinite arc.
+
+
+ Project(myclass; C: HCurve2d from Adaptor2d;
+ P: Pnt2d from gp;
+ Paramproj: out Real from Standard;
+ Ptproj : out Pnt2d from gp)
+
+ ---Purpose: Projects the point P on the arc C.
+ -- If the methods returns Standard_True, the projection is
+ -- successful, and Paramproj is the parameter on the arc
+ -- of the projected point, Ptproj is the projected Point.
+ -- If the method returns Standard_False, Param proj and Ptproj
+ -- are not significant.
+ --
+
+ returns Boolean from Standard;
+
+
+-- Methods on a vertex
+
+
+ Tolerance(myclass; V: HVertex from Adaptor3d; C: HCurve2d from Adaptor2d)
+
+ ---Purpose: Returns the parametric tolerance used to consider
+ -- that the vertex and another point meet, i-e
+ -- if Abs(parameter(Vertex) - parameter(OtherPnt))<=
+ -- Tolerance, the points are "merged".
+
+ returns Real from Standard;
+
+
+ Parameter(myclass; V: HVertex from Adaptor3d; C: HCurve2d from Adaptor2d)
+
+ ---Purpose: Returns the parameter of the vertex V on the arc A.
+
+ returns Real from Standard;
+
+
+-- The following methods are used when HasBeenSeen returns Standard_True
+
+ NbPoints(myclass; C: HCurve2d from Adaptor2d)
+
+ ---Purpose: Returns the number of intersection points on the arc A.
+
+ returns Integer from Standard;
+
+
+ Value(myclass; C: HCurve2d from Adaptor2d; Index: Integer from Standard;
+ Pt: out Pnt from gp; Tol: out Real from Standard;
+ U: out Real from Standard);
+
+ ---Purpose: Returns the value (Pt), the tolerance (Tol), and
+ -- the parameter (U) on the arc A , of the intersection
+ -- point of range Index.
+
+
+ IsVertex(myclass; C: HCurve2d from Adaptor2d;
+ Index: Integer from Standard)
+
+ ---Purpose: Returns True if the intersection point of range Index
+ -- corresponds with a vertex on the arc A.
+
+ returns Boolean from Standard;
+
+
+ Vertex(myclass; C: HCurve2d from Adaptor2d; Index: Integer from Standard;
+ V: out HVertex from Adaptor3d);
+
+ ---Purpose: When IsVertex returns True, this method returns the
+ -- vertex on the arc A.
+
+
+ NbSegments(myclass; C: HCurve2d from Adaptor2d)
+
+ ---Purpose: returns the number of part of A solution of the
+ -- of intersection problem.
+
+ returns Integer from Standard;
+
+
+ HasFirstPoint(myclass; C: HCurve2d from Adaptor2d;
+ Index: Integer from Standard;
+ IndFirst: out Integer from Standard)
+
+ ---Purpose: Returns True when the segment of range Index is not
+ -- open at the left side. In that case, IndFirst is the
+ -- range in the list intersection points (see NbPoints)
+ -- of the one which defines the left bound of the segment.
+ -- Otherwise, the method has to return False, and IndFirst
+ -- has no meaning.
+
+ returns Boolean from Standard;
+
+
+ HasLastPoint(myclass; C: HCurve2d from Adaptor2d;
+ Index: Integer from Standard;
+ IndLast: out Integer from Standard)
+
+ ---Purpose: Returns True when the segment of range Index is not
+ -- open at the right side. In that case, IndLast is the
+ -- range in the list intersection points (see NbPoints)
+ -- of the one which defines the right bound of the segment.
+ -- Otherwise, the method has to return False, and IndLast
+ -- has no meaning.
+
+ returns Boolean from Standard;
+
+
+ IsAllSolution(myclass; C: HCurve2d from Adaptor2d)
+
+ ---Purpose: Returns True when the whole restriction is solution
+ -- of the intersection problem.
+
+ returns Boolean from Standard;
+
+
+end HContTool;
--- /dev/null
+// Created on: 1995-07-02
+// Created by: Laurent BUCHARD
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_HContTool.ixx>
+
+#include <Extrema_EPCOfExtPC2d.hxx>
+#include <Extrema_POnCurv2d.hxx>
+
+static Standard_Real uinf,vinf,usup,vsup;
+
+Standard_Integer Contap_HContTool::NbSamplesV
+(const Handle(Adaptor3d_HSurface)& S,
+ const Standard_Real ,
+ const Standard_Real )
+{
+ Standard_Integer nbs;
+ GeomAbs_SurfaceType typS = S->GetType();
+ switch(typS) {
+ case GeomAbs_Plane:
+ {
+ nbs = 2;
+ }
+ break;
+ case GeomAbs_BezierSurface:
+ {
+ nbs = 3 + S->NbVPoles();
+ }
+ break;
+ case GeomAbs_BSplineSurface:
+ {
+ //-- Handle_Geom_BSplineSurface& HBS=S->BSpline();
+ nbs = S->NbVKnots();
+ nbs*= S->VDegree();
+ if(nbs < 2) nbs=2;
+
+ }
+ break;
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ case GeomAbs_Torus:
+ case GeomAbs_SurfaceOfRevolution:
+ case GeomAbs_SurfaceOfExtrusion:
+ {
+ nbs = 15;
+ }
+ break;
+
+ default:
+ {
+ nbs = 10;
+ }
+ break;
+ }
+ return(nbs);
+}
+
+Standard_Integer Contap_HContTool::NbSamplesU
+(const Handle(Adaptor3d_HSurface)& S,
+ const Standard_Real ,
+ const Standard_Real )
+{
+ Standard_Integer nbs;
+ GeomAbs_SurfaceType typS = S->GetType();
+ switch(typS) {
+ case GeomAbs_Plane:
+ {
+ nbs = 2;
+ }
+ break;
+ case GeomAbs_BezierSurface:
+ {
+ nbs = 3 + S->NbUPoles();
+ }
+ break;
+ case GeomAbs_BSplineSurface:
+ {
+ //-- Handle_Geom_BSplineSurface& HBS=S->BSpline();
+ nbs = S->NbUKnots();
+ nbs*= S->UDegree();
+ if(nbs < 2) nbs=2;
+
+ }
+ break;
+ case GeomAbs_Torus:
+ {
+ nbs = 20;
+ }
+ break;
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ case GeomAbs_SurfaceOfRevolution:
+ case GeomAbs_SurfaceOfExtrusion:
+ {
+ nbs = 10;
+ }
+ break;
+
+ default:
+ {
+ nbs = 10;
+ }
+ break;
+ }
+ return(nbs);
+}
+
+Standard_Integer Contap_HContTool::NbSamplePoints
+(const Handle(Adaptor3d_HSurface)& S)
+{
+ uinf = S->FirstUParameter();
+ usup = S->LastUParameter();
+ vinf = S->FirstVParameter();
+ vsup = S->LastVParameter();
+
+ if (usup < uinf) {
+ Standard_Real temp = uinf;
+ uinf = usup;
+ usup = temp;
+ }
+ if (vsup < vinf) {
+ Standard_Real temp = vinf;
+ vinf = vsup;
+ vsup = temp;
+ }
+ if (uinf == RealFirst() && usup == RealLast()) {
+ uinf = -1.e5;
+ usup = 1.e5;
+ }
+ else if (uinf == RealFirst()) {
+ uinf = usup - 2.e5;
+ }
+ else if (usup == RealLast()) {
+ usup = uinf + 2.e5;
+ }
+
+ if (vinf == RealFirst() && vsup == RealLast()) {
+ vinf = -1.e5;
+ vsup = 1.e5;
+ }
+ else if (vinf == RealFirst()) {
+ vinf = vsup - 2.e5;
+ }
+ else if (vsup == RealLast()) {
+ vsup = vinf + 2.e5;
+ }
+ if(S->GetType() == GeomAbs_BSplineSurface) {
+ Standard_Integer m = (NbSamplesU(S,uinf,usup)/3) * (NbSamplesV(S,vinf,vsup)/3);
+ if(m>5) return(m);
+ else return(5);
+ }
+ else
+ return 5;
+}
+
+void Contap_HContTool::SamplePoint (const Handle(Adaptor3d_HSurface)& S,
+ const Standard_Integer Index,
+ Standard_Real& U,
+ Standard_Real& V )
+{
+ if(S->GetType() == GeomAbs_BSplineSurface) {
+ Standard_Integer nbIntU = NbSamplesU(S,uinf,usup)/3;
+ Standard_Integer nbIntV = NbSamplesV(S,vinf,vsup)/3;
+ if(nbIntU * nbIntV >5) {
+ Standard_Integer indU = (Index-1)/nbIntU; //---- 0 --> nbIntV
+ Standard_Integer indV = (Index-1) - indU*nbIntU; //---- 0 --> nbIntU
+
+ U = uinf + ((usup-uinf)/((Standard_Real)(nbIntU+1)))*(Standard_Real)(indU+1);
+ V = vinf + ((vsup-vinf)/((Standard_Real)(nbIntV+2)))*(Standard_Real)(indV+1);
+
+ //-- cout<<"Index :"<<Index<<" uinf:"<<uinf<<" usup:"<<usup<<" vinf:"<<vinf<<" vsup:"<<vsup<<" ";
+ //-- cout<<" ("<<indU<<"/"<<nbIntU<<" ->U:"<<U<<" ";
+ //-- cout<<" ("<<indV<<"/"<<nbIntV<<" ->V:"<<V<<endl;
+ return;
+ }
+ }
+
+ switch (Index) {
+ case 1:
+ U = 0.75*uinf + 0.25*usup; //0.25;
+ V = 0.75*vinf + 0.25*vsup; //0.25;
+ break;
+ case 2:
+ U = 0.75*uinf + 0.25*usup; //0.25;
+ V = 0.25*vinf + 0.75*vsup; //0.75;
+ break;
+ case 3:
+ U = 0.25*uinf + 0.75*usup; //0.75;
+ V = 0.75*vinf + 0.25*vsup; //0.25;
+ break;
+ case 4:
+ U = 0.25*uinf + 0.75*usup; //0.75;
+ V = 0.25*vinf + 0.75*vsup; //0.75;
+ break;
+ default:
+ U = 0.5*(uinf+usup); //0.5;
+ V = 0.5*(vinf+vsup); //0.5;
+ }
+}
+
+
+Standard_Integer Contap_HContTool::NbSamplesOnArc
+(const Handle(Adaptor2d_HCurve2d)& A) {
+
+ GeomAbs_CurveType CurveType = A->GetType();
+
+ Standard_Real nbsOnC = 5;
+ switch(CurveType) {
+ case GeomAbs_Line:
+ nbsOnC = 2;
+ break;
+ case GeomAbs_Circle:
+ case GeomAbs_Ellipse:
+ case GeomAbs_Hyperbola:
+ case GeomAbs_Parabola:
+ nbsOnC = 10;
+ break;
+ case GeomAbs_BezierCurve:
+ nbsOnC = A->NbPoles();
+ break;
+ case GeomAbs_BSplineCurve: {
+ //-- Handle_Geom2d_BSplineCurve& BSC=A->BSpline();
+ nbsOnC = 2 + A->NbKnots() * A->Degree();
+ break;
+ }
+ default:
+ nbsOnC = 10;
+ }
+ return (Standard_Integer)(nbsOnC);
+}
+
+
+void Contap_HContTool::Bounds(const Handle(Adaptor2d_HCurve2d)& A,
+ Standard_Real& Ufirst,
+ Standard_Real& Ulast)
+{
+ Ufirst = A->FirstParameter();
+ Ulast = A->LastParameter();
+}
+
+
+Standard_Boolean Contap_HContTool::Project (const Handle(Adaptor2d_HCurve2d)& C,
+ const gp_Pnt2d& P,
+ Standard_Real& Paramproj,
+ gp_Pnt2d& Ptproj)
+
+{
+
+ Standard_Real epsX = 1.e-8;
+ Standard_Integer Nbu = 20;
+ Standard_Real Tol = 1.e-5;
+ Standard_Real Dist2;
+
+ Extrema_EPCOfExtPC2d extrema(P,C->Curve2d(),Nbu,epsX,Tol);
+ if (!extrema.IsDone()) {
+ return Standard_False;
+ }
+ Standard_Integer Nbext = extrema.NbExt();
+ if (Nbext == 0) {
+ return Standard_False;
+ }
+ Standard_Integer indexmin = 1;
+ Dist2 = extrema.SquareDistance(1);
+ for (Standard_Integer i=2; i<=Nbext; i++) {
+ if (extrema.SquareDistance(i) < Dist2) {
+ indexmin = i;
+ Dist2 = extrema.SquareDistance(i);
+ }
+ }
+ Paramproj = extrema.Point(indexmin).Parameter();
+ Ptproj = extrema.Point(indexmin).Value();
+ return Standard_True;
+}
+
+
+Standard_Real Contap_HContTool::Tolerance (const Handle(Adaptor3d_HVertex)& V,
+ const Handle(Adaptor2d_HCurve2d)& C)
+{
+ // return BRepAdaptor2d_Curve2dTool::Resolution(C,BRep_Tool::Tolerance(V));
+ return V->Resolution(C);
+}
+
+Standard_Real Contap_HContTool::Parameter (const Handle(Adaptor3d_HVertex)& V,
+ const Handle(Adaptor2d_HCurve2d)& C)
+{
+ // return BRep_Tool::Parameter(V,C.Edge());
+ return V->Parameter(C);
+}
+
+
+
+Standard_Boolean Contap_HContTool::HasBeenSeen
+(const Handle(Adaptor2d_HCurve2d)&)
+{
+ return Standard_False;
+}
+
+Standard_Integer Contap_HContTool::NbPoints(const Handle(Adaptor2d_HCurve2d)&)
+{
+ return 0;
+}
+
+void Contap_HContTool::Value(const Handle(Adaptor2d_HCurve2d)&,
+ const Standard_Integer,
+ gp_Pnt&,
+ Standard_Real&,
+ Standard_Real&)
+{
+ Standard_OutOfRange::Raise();
+}
+
+Standard_Boolean Contap_HContTool::IsVertex(const Handle(Adaptor2d_HCurve2d)&,
+ const Standard_Integer)
+{
+ return Standard_False;
+}
+
+void Contap_HContTool::Vertex(const Handle(Adaptor2d_HCurve2d)&,
+ const Standard_Integer,
+ Handle(Adaptor3d_HVertex)&)
+{
+ Standard_OutOfRange::Raise();
+}
+
+Standard_Integer Contap_HContTool::NbSegments(const Handle(Adaptor2d_HCurve2d)&)
+{
+ return 0;
+}
+
+Standard_Boolean Contap_HContTool::HasFirstPoint
+(const Handle(Adaptor2d_HCurve2d)&,
+ const Standard_Integer,
+ Standard_Integer&)
+{
+ Standard_OutOfRange::Raise();
+ return Standard_False;
+}
+
+Standard_Boolean Contap_HContTool::HasLastPoint
+(const Handle(Adaptor2d_HCurve2d)&,
+ const Standard_Integer,
+ Standard_Integer&)
+{
+ Standard_OutOfRange::Raise();
+ return Standard_False;
+}
+
+Standard_Boolean Contap_HContTool::IsAllSolution
+(const Handle(Adaptor2d_HCurve2d)&)
+
+{
+ return Standard_False;
+}
+
+++ /dev/null
--- Created on: 1995-07-02
--- Created by: Laurent BUCHARD
--- Copyright (c) 1995-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-generic class HContToolGen from Contap (
- TheHVertex as any;
- TheHCurve2d as any;
- TheHSurface as any;
- TheHCurve2dTool as any;
- TheHSurfaceTool as any)
-
- ---Purpose: Tool for the intersection between 2 surfaces.
- -- Regroupe pour l instant les methodes hors Adaptor3d...
-
-
-
-uses
- Pnt2d from gp,
- Pnt from gp
-
-is
-
-
- NbSamplesU(myclass; S: TheHSurface; u1,u2: Real from Standard)
- returns Integer from Standard;
-
- NbSamplesV(myclass; S: TheHSurface; v1,v2: Real from Standard)
- returns Integer from Standard;
-
--- Methodes pour recherche des points interieurs
-
- NbSamplePoints(myclass; S: TheHSurface)
-
- returns Integer from Standard;
-
-
- SamplePoint(myclass; S : TheHSurface;
- Index: Integer from Standard;
- U,V: out Real from Standard);
-
-
--- Methodes sur un arc de restriction
-
- HasBeenSeen(myclass; C: TheHCurve2d)
-
- ---Purpose: Returns True if all the intersection point and edges
- -- are known on the Arc.
- -- The intersection point are given as vertices.
- -- The intersection edges are given as intervals between
- -- two vertices.
-
- returns Boolean from Standard;
-
- NbSamplesOnArc(myclass; A: TheHCurve2d)
-
- ---Purpose: returns the number of points which is used to make
- -- a sample on the arc. this number is a function of
- -- the Surface and the CurveOnSurface complexity.
-
- returns Integer from Standard;
-
-
- Bounds(myclass; C: TheHCurve2d;
- Ufirst,Ulast: out Real from Standard);
-
- ---Purpose: Returns the parametric limits on the arc C.
- -- These limits must be finite : they are either
- -- the real limits of the arc, for a finite arc,
- -- or a bounding box for an infinite arc.
-
-
- Project(myclass; C: TheHCurve2d;
- P: Pnt2d from gp;
- Paramproj: out Real from Standard;
- Ptproj : out Pnt2d from gp)
-
- ---Purpose: Projects the point P on the arc C.
- -- If the methods returns Standard_True, the projection is
- -- successful, and Paramproj is the parameter on the arc
- -- of the projected point, Ptproj is the projected Point.
- -- If the method returns Standard_False, Param proj and Ptproj
- -- are not significant.
- --
-
- returns Boolean from Standard;
-
-
--- Methods on a vertex
-
-
- Tolerance(myclass; V: TheHVertex; C: TheHCurve2d)
-
- ---Purpose: Returns the parametric tolerance used to consider
- -- that the vertex and another point meet, i-e
- -- if Abs(parameter(Vertex) - parameter(OtherPnt))<=
- -- Tolerance, the points are "merged".
-
- returns Real from Standard;
-
-
- Parameter(myclass; V: TheHVertex; C: TheHCurve2d)
-
- ---Purpose: Returns the parameter of the vertex V on the arc A.
-
- returns Real from Standard;
-
-
--- The following methods are used when HasBeenSeen returns Standard_True
-
- NbPoints(myclass; C: TheHCurve2d)
-
- ---Purpose: Returns the number of intersection points on the arc A.
-
- returns Integer from Standard;
-
-
- Value(myclass; C: TheHCurve2d; Index: Integer from Standard;
- Pt: out Pnt from gp; Tol: out Real from Standard;
- U: out Real from Standard);
-
- ---Purpose: Returns the value (Pt), the tolerance (Tol), and
- -- the parameter (U) on the arc A , of the intersection
- -- point of range Index.
-
-
- IsVertex(myclass; C: TheHCurve2d;
- Index: Integer from Standard)
-
- ---Purpose: Returns True if the intersection point of range Index
- -- corresponds with a vertex on the arc A.
-
- returns Boolean from Standard;
-
-
- Vertex(myclass; C: TheHCurve2d; Index: Integer from Standard;
- V: out TheHVertex);
-
- ---Purpose: When IsVertex returns True, this method returns the
- -- vertex on the arc A.
-
-
- NbSegments(myclass; C: TheHCurve2d)
-
- ---Purpose: returns the number of part of A solution of the
- -- of intersection problem.
-
- returns Integer from Standard;
-
-
- HasFirstPoint(myclass; C: TheHCurve2d;
- Index: Integer from Standard;
- IndFirst: out Integer from Standard)
-
- ---Purpose: Returns True when the segment of range Index is not
- -- open at the left side. In that case, IndFirst is the
- -- range in the list intersection points (see NbPoints)
- -- of the one which defines the left bound of the segment.
- -- Otherwise, the method has to return False, and IndFirst
- -- has no meaning.
-
- returns Boolean from Standard;
-
-
- HasLastPoint(myclass; C: TheHCurve2d;
- Index: Integer from Standard;
- IndLast: out Integer from Standard)
-
- ---Purpose: Returns True when the segment of range Index is not
- -- open at the right side. In that case, IndLast is the
- -- range in the list intersection points (see NbPoints)
- -- of the one which defines the right bound of the segment.
- -- Otherwise, the method has to return False, and IndLast
- -- has no meaning.
-
- returns Boolean from Standard;
-
-
- IsAllSolution(myclass; C: TheHCurve2d)
-
- ---Purpose: Returns True when the whole restriction is solution
- -- of the intersection problem.
-
- returns Boolean from Standard;
-
-
-end HContToolGen;
+++ /dev/null
-// Created on: 1995-07-02
-// Created by: Laurent BUCHARD
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Extrema_EPCOfExtPC2d.hxx>
-#include <Extrema_POnCurv2d.hxx>
-
-#include <GeomAbs_SurfaceType.hxx>
-#include <Standard_OutOfRange.hxx>
-
-#include <Geom_BezierSurface.hxx>
-#include <Geom_BSplineSurface.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-
-#include <Geom_BezierSurface.hxx>
-#include <Geom_BSplineSurface.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-
-static Standard_Real uinf,vinf,usup,vsup;
-
-#include TheHSurface_hxx
-#include TheHCurve2d_hxx
-#include TheHVertex_hxx
-
-
-Standard_Integer Contap_HContToolGen::NbSamplesV
- (const TheHSurface& S,
- const Standard_Real ,
- const Standard_Real )
-{
- Standard_Integer nbs;
- GeomAbs_SurfaceType typS = S->GetType();
- switch(typS) {
- case GeomAbs_Plane:
- {
- nbs = 2;
- }
- break;
- case GeomAbs_BezierSurface:
- {
- nbs = 3 + S->NbVPoles();
- }
- break;
- case GeomAbs_BSplineSurface:
- {
- //-- Handle_Geom_BSplineSurface& HBS=S->BSpline();
- nbs = S->NbVKnots();
- nbs*= S->VDegree();
- if(nbs < 2) nbs=2;
-
- }
- break;
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- case GeomAbs_Torus:
- case GeomAbs_SurfaceOfRevolution:
- case GeomAbs_SurfaceOfExtrusion:
- {
- nbs = 15;
- }
- break;
-
- default:
- {
- nbs = 10;
- }
- break;
- }
- return(nbs);
-}
-
-Standard_Integer Contap_HContToolGen::NbSamplesU
- (const TheHSurface& S,
- const Standard_Real ,
- const Standard_Real )
-{
- Standard_Integer nbs;
- GeomAbs_SurfaceType typS = S->GetType();
- switch(typS) {
- case GeomAbs_Plane:
- {
- nbs = 2;
- }
- break;
- case GeomAbs_BezierSurface:
- {
- nbs = 3 + S->NbUPoles();
- }
- break;
- case GeomAbs_BSplineSurface:
- {
- //-- Handle_Geom_BSplineSurface& HBS=S->BSpline();
- nbs = S->NbUKnots();
- nbs*= S->UDegree();
- if(nbs < 2) nbs=2;
-
- }
- break;
- case GeomAbs_Torus:
- {
- nbs = 20;
- }
- break;
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- case GeomAbs_SurfaceOfRevolution:
- case GeomAbs_SurfaceOfExtrusion:
- {
- nbs = 10;
- }
- break;
-
- default:
- {
- nbs = 10;
- }
- break;
- }
- return(nbs);
-}
-
-Standard_Integer Contap_HContToolGen::NbSamplePoints
- (const TheHSurface& S)
-{
- uinf = S->FirstUParameter();
- usup = S->LastUParameter();
- vinf = S->FirstVParameter();
- vsup = S->LastVParameter();
-
- if (usup < uinf) {
- Standard_Real temp = uinf;
- uinf = usup;
- usup = temp;
- }
- if (vsup < vinf) {
- Standard_Real temp = vinf;
- vinf = vsup;
- vsup = temp;
- }
- if (uinf == RealFirst() && usup == RealLast()) {
- uinf = -1.e5;
- usup = 1.e5;
- }
- else if (uinf == RealFirst()) {
- uinf = usup - 2.e5;
- }
- else if (usup == RealLast()) {
- usup = uinf + 2.e5;
- }
-
- if (vinf == RealFirst() && vsup == RealLast()) {
- vinf = -1.e5;
- vsup = 1.e5;
- }
- else if (vinf == RealFirst()) {
- vinf = vsup - 2.e5;
- }
- else if (vsup == RealLast()) {
- vsup = vinf + 2.e5;
- }
- if(S->GetType() == GeomAbs_BSplineSurface) {
- Standard_Integer m = (NbSamplesU(S,uinf,usup)/3) * (NbSamplesV(S,vinf,vsup)/3);
- if(m>5) return(m);
- else return(5);
- }
- else
- return 5;
-}
-
-void Contap_HContToolGen::SamplePoint (const TheHSurface& S,
- const Standard_Integer Index,
- Standard_Real& U,
- Standard_Real& V )
-{
- if(S->GetType() == GeomAbs_BSplineSurface) {
- Standard_Integer nbIntU = NbSamplesU(S,uinf,usup)/3;
- Standard_Integer nbIntV = NbSamplesV(S,vinf,vsup)/3;
- if(nbIntU * nbIntV >5) {
- Standard_Integer indU = (Index-1)/nbIntU; //---- 0 --> nbIntV
- Standard_Integer indV = (Index-1) - indU*nbIntU; //---- 0 --> nbIntU
-
- U = uinf + ((usup-uinf)/((Standard_Real)(nbIntU+1)))*(Standard_Real)(indU+1);
- V = vinf + ((vsup-vinf)/((Standard_Real)(nbIntV+2)))*(Standard_Real)(indV+1);
-
- //-- cout<<"Index :"<<Index<<" uinf:"<<uinf<<" usup:"<<usup<<" vinf:"<<vinf<<" vsup:"<<vsup<<" ";
- //-- cout<<" ("<<indU<<"/"<<nbIntU<<" ->U:"<<U<<" ";
- //-- cout<<" ("<<indV<<"/"<<nbIntV<<" ->V:"<<V<<endl;
- return;
- }
- }
-
- switch (Index) {
- case 1:
- U = 0.75*uinf + 0.25*usup; //0.25;
- V = 0.75*vinf + 0.25*vsup; //0.25;
- break;
- case 2:
- U = 0.75*uinf + 0.25*usup; //0.25;
- V = 0.25*vinf + 0.75*vsup; //0.75;
- break;
- case 3:
- U = 0.25*uinf + 0.75*usup; //0.75;
- V = 0.75*vinf + 0.25*vsup; //0.25;
- break;
- case 4:
- U = 0.25*uinf + 0.75*usup; //0.75;
- V = 0.25*vinf + 0.75*vsup; //0.75;
- break;
- default:
- U = 0.5*(uinf+usup); //0.5;
- V = 0.5*(vinf+vsup); //0.5;
- }
-}
-
-
-Standard_Integer Contap_HContToolGen::NbSamplesOnArc
- (const TheHCurve2d& A) {
-
- GeomAbs_CurveType CurveType = A->GetType();
-
- Standard_Real nbsOnC = 5;
- switch(CurveType) {
- case GeomAbs_Line:
- nbsOnC = 2;
- break;
- case GeomAbs_Circle:
- case GeomAbs_Ellipse:
- case GeomAbs_Hyperbola:
- case GeomAbs_Parabola:
- nbsOnC = 10;
- break;
- case GeomAbs_BezierCurve:
- nbsOnC = A->NbPoles();
- break;
- case GeomAbs_BSplineCurve: {
- //-- Handle_Geom2d_BSplineCurve& BSC=A->BSpline();
- nbsOnC = 2 + A->NbKnots() * A->Degree();
- break;
- }
- default:
- nbsOnC = 10;
- }
- return (Standard_Integer)(nbsOnC);
-}
-
-
-void Contap_HContToolGen::Bounds(const TheHCurve2d& A,
- Standard_Real& Ufirst,
- Standard_Real& Ulast)
-{
- Ufirst = A->FirstParameter();
- Ulast = A->LastParameter();
-}
-
-
-Standard_Boolean Contap_HContToolGen::Project (const TheHCurve2d& C,
- const gp_Pnt2d& P,
- Standard_Real& Paramproj,
- gp_Pnt2d& Ptproj)
-
-{
-
- Standard_Real epsX = 1.e-8;
- Standard_Integer Nbu = 20;
- Standard_Real Tol = 1.e-5;
- Standard_Real Dist2;
-
- Extrema_EPCOfExtPC2d extrema(P,C->Curve2d(),Nbu,epsX,Tol);
- if (!extrema.IsDone()) {
- return Standard_False;
- }
- Standard_Integer Nbext = extrema.NbExt();
- if (Nbext == 0) {
- return Standard_False;
- }
- Standard_Integer indexmin = 1;
- Dist2 = extrema.SquareDistance(1);
- for (Standard_Integer i=2; i<=Nbext; i++) {
- if (extrema.SquareDistance(i) < Dist2) {
- indexmin = i;
- Dist2 = extrema.SquareDistance(i);
- }
- }
- Paramproj = extrema.Point(indexmin).Parameter();
- Ptproj = extrema.Point(indexmin).Value();
- return Standard_True;
-}
-
-
-Standard_Real Contap_HContToolGen::Tolerance (const TheHVertex& V,
- const TheHCurve2d& C)
-{
-// return BRepAdaptor2d_Curve2dTool::Resolution(C,BRep_Tool::Tolerance(V));
- return V->Resolution(C);
-}
-
-Standard_Real Contap_HContToolGen::Parameter (const TheHVertex& V,
- const TheHCurve2d& C)
-{
-// return BRep_Tool::Parameter(V,C.Edge());
- return V->Parameter(C);
-}
-
-
-
-Standard_Boolean Contap_HContToolGen::HasBeenSeen
- (const TheHCurve2d&)
-{
- return Standard_False;
-}
-
-Standard_Integer Contap_HContToolGen::NbPoints(const TheHCurve2d&)
-{
- return 0;
-}
-
-void Contap_HContToolGen::Value(const TheHCurve2d&,
- const Standard_Integer,
- gp_Pnt&,
- Standard_Real&,
- Standard_Real&)
-{
- Standard_OutOfRange::Raise();
-}
-
-Standard_Boolean Contap_HContToolGen::IsVertex(const TheHCurve2d&,
- const Standard_Integer)
-{
- return Standard_False;
-}
-
-void Contap_HContToolGen::Vertex(const TheHCurve2d&,
- const Standard_Integer,
- TheHVertex&)
-{
- Standard_OutOfRange::Raise();
-}
-
-Standard_Integer Contap_HContToolGen::NbSegments(const TheHCurve2d&)
-{
- return 0;
-}
-
-Standard_Boolean Contap_HContToolGen::HasFirstPoint
- (const TheHCurve2d&,
- const Standard_Integer,
- Standard_Integer&)
-{
- Standard_OutOfRange::Raise();
- return Standard_False;
-}
-
-Standard_Boolean Contap_HContToolGen::HasLastPoint
- (const TheHCurve2d&,
- const Standard_Integer,
- Standard_Integer&)
-{
- Standard_OutOfRange::Raise();
- return Standard_False;
-}
-
-Standard_Boolean Contap_HContToolGen::IsAllSolution
- (const TheHCurve2d&)
-
-{
- return Standard_False;
-}
-
--- /dev/null
+-- Created on: 1995-07-17
+-- Created by: Laurent BUCHARD
+-- Copyright (c) 1995-1999 Matra Datavision
+-- Copyright (c) 1999-2014 OPEN CASCADE SAS
+--
+-- This file is part of Open CASCADE Technology software library.
+--
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
+-- by the Free Software Foundation, with special exception defined in the file
+-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+-- distribution for complete text of the license and disclaimer of any warranty.
+--
+-- Alternatively, this file may be used under the terms of Open CASCADE
+-- commercial license or contractual agreement.
+
+class HCurve2dTool from Contap
+
+uses
+ Array1OfReal from TColStd,
+ Shape from GeomAbs,
+ CurveType from GeomAbs,
+ Vec2d from gp,
+ Pnt2d from gp,
+ Circ2d from gp,
+ Elips2d from gp,
+ Hypr2d from gp,
+ Parab2d from gp,
+ Lin2d from gp,
+ BezierCurve from Geom2d,
+ BSplineCurve from Geom2d,
+ HCurve2d from Adaptor2d
+
+raises
+
+ OutOfRange from Standard,
+ NoSuchObject from Standard,
+ DomainError from Standard
+
+is
+
+ --
+ -- Global methods - Apply to the whole curve.
+ --
+
+ FirstParameter(myclass; C: HCurve2d from Adaptor2d) returns Real
+ ---C++: inline
+ ;
+
+
+ LastParameter(myclass; C: HCurve2d from Adaptor2d) returns Real
+ ---C++: inline
+ ;
+
+ --
+ -- Services to break the curves to the expected continuity
+ --
+ -- If for example you need the curve to be C2 and the method
+ -- Continuity returns you something lower than C2 (say C1 for
+ -- example).
+ --
+ -- First compute the number of intervals with the requested
+ -- continuity with the method NbIntervals(). Note that if the
+ -- continuity is higher than the one you need NbIntervals will
+ -- return 1.
+ --
+ -- Then you get the parameters bounding the intervals with the
+ -- method Intervals, using an array of length at least
+ -- NbIntervals()+1.
+ --
+ -- If you need to create a curve with a restricted span you can
+ -- use the method Trim().
+
+
+ Continuity(myclass; C: HCurve2d from Adaptor2d) returns Shape from GeomAbs
+ ---Purpose:
+ ---C++: inline
+ ;
+
+ NbIntervals(myclass; C: HCurve2d from Adaptor2d; S : Shape from GeomAbs) returns Integer
+ ---Purpose: Returns the number of intervals for continuity
+ -- <S>. May be one if Continuity(myclass) >= <S>
+ ---C++: inline
+ ;
+
+ Intervals(myclass; C: HCurve2d from Adaptor2d; T : in out Array1OfReal from TColStd;
+ S : Shape from GeomAbs)
+ ---Purpose: Stores in <T> the parameters bounding the intervals
+ -- of continuity <S>.
+ --
+ -- The array must provide enough room to accomodate
+ -- for the parameters. i.e. T.Length() > NbIntervals()
+ raises
+ OutOfRange from Standard
+ ---C++: inline
+ ;
+
+ IsClosed(myclass; C: HCurve2d from Adaptor2d) returns Boolean
+ ---C++: inline
+ ;
+
+ IsPeriodic(myclass; C: HCurve2d from Adaptor2d) returns Boolean
+ ---C++: inline
+ ;
+
+ Period(myclass; C: HCurve2d from Adaptor2d) returns Real
+ raises
+ DomainError from Standard -- if the curve is not periodic
+ ---C++: inline
+ ;
+
+ Value(myclass; C: HCurve2d from Adaptor2d; U : Real) returns Pnt2d from gp
+ --- Purpose : Computes the point of parameter U on the curve.
+ ---C++: inline
+ ;
+
+ D0 (myclass; C: HCurve2d from Adaptor2d; U : Real; P : out Pnt2d from gp)
+ --- Purpose : Computes the point of parameter U on the curve.
+ ---C++: inline
+ ;
+
+ D1 (myclass; C: HCurve2d from Adaptor2d; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
+ --- Purpose : Computes the point of parameter U on the curve with its
+ -- first derivative.
+ raises
+ DomainError from Standard
+ --- Purpose : Raised if the continuity of the current interval
+ -- is not C1.
+ ---C++: inline
+ ;
+
+ D2 (myclass; C: HCurve2d from Adaptor2d; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
+ --- Purpose :
+ -- Returns the point P of parameter U, the first and second
+ -- derivatives V1 and V2.
+ raises
+ DomainError from Standard
+ --- Purpose : Raised if the continuity of the current interval
+ -- is not C2.
+ ---C++: inline
+ ;
+
+ D3 (myclass; C: HCurve2d from Adaptor2d; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
+ --- Purpose :
+ -- Returns the point P of parameter U, the first, the second
+ -- and the third derivative.
+ raises
+ DomainError from Standard
+ --- Purpose : Raised if the continuity of the current interval
+ -- is not C3.
+ ---C++: inline
+ ;
+
+ DN (myclass; C: HCurve2d from Adaptor2d; U : Real; N : Integer) returns Vec2d from gp
+ --- Purpose :
+ -- The returned vector gives the value of the derivative for the
+ -- order of derivation N.
+ raises
+ DomainError from Standard,
+ --- Purpose : Raised if the continuity of the current interval
+ -- is not CN.
+ OutOfRange from Standard
+ --- Purpose : Raised if N < 1.
+ ---C++: inline
+ ;
+
+ Resolution(myclass; C: HCurve2d from Adaptor2d; R3d : Real) returns Real
+ ---Purpose : Returns the parametric resolution corresponding
+ -- to the real space resolution <R3d>.
+ ---C++: inline
+ ;
+
+ GetType(myclass; C: HCurve2d from Adaptor2d) returns CurveType from GeomAbs
+ ---Purpose: Returns the type of the curve in the current
+ -- interval : Line, Circle, Ellipse, Hyperbola,
+ -- Parabola, BezierCurve, BSplineCurve, OtherCurve.
+ ---C++: inline
+ ;
+
+ --
+ -- The following methods must be called when GetType returned
+ -- the corresponding type.
+ --
+
+ Line(myclass; C: HCurve2d from Adaptor2d) returns Lin2d from gp
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+ Circle(myclass; C: HCurve2d from Adaptor2d) returns Circ2d from gp
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+ Ellipse(myclass; C: HCurve2d from Adaptor2d) returns Elips2d from gp
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+ Hyperbola(myclass; C: HCurve2d from Adaptor2d) returns Hypr2d from gp
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+ Parabola(myclass; C: HCurve2d from Adaptor2d) returns Parab2d from gp
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+ Bezier(myclass; C: HCurve2d from Adaptor2d) returns BezierCurve from Geom2d
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+ BSpline(myclass; C: HCurve2d from Adaptor2d) returns BSplineCurve from Geom2d
+ raises
+ NoSuchObject from Standard
+ ---C++: inline
+ ;
+
+
+
+
+
+ NbSamples(myclass; C: HCurve2d from Adaptor2d; U0,U1: Real from Standard)
+ returns Integer from Standard;
+
+end HCurve2dTool;
--- /dev/null
+// Created on: 1995-07-17
+// Created by: Modelistation
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_HCurve2dTool.ixx>
+
+//============================================================
+Standard_Integer Contap_HCurve2dTool::NbSamples (const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U0,
+ const Standard_Real U1)
+{
+ Standard_Real nbs = 10.0;
+ switch (C->GetType())
+ {
+ case GeomAbs_Line:
+ nbs = 2.;
+ break;
+ case GeomAbs_BezierCurve:
+ nbs = 3. + C->NbPoles();
+ break;
+ case GeomAbs_BSplineCurve:
+ nbs = C->NbKnots();
+ nbs*= C->Degree();
+ nbs*= C->LastParameter()- C->FirstParameter();
+ nbs/= U1-U0;
+ if(nbs < 2.0) nbs = 2.;
+ break;
+ default:
+ break;
+ }
+ if (nbs>50.)
+ nbs = 50.;
+ return((Standard_Integer)nbs);
+}
--- /dev/null
+// Created on: 1992-10-22
+// Created by: Laurent BUCHARD
+// Copyright (c) 1992-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Adaptor2d_HCurve2d.hxx>
+
+#include <GeomAbs_CurveType.hxx>
+#include <GeomAbs_Shape.hxx>
+
+#include <gp_Vec2d.hxx>
+#include <gp_Lin2d.hxx>
+#include <gp_Circ2d.hxx>
+#include <gp_Elips2d.hxx>
+#include <gp_Parab2d.hxx>
+#include <gp_Hypr2d.hxx>
+
+
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+
+#include <TColStd_Array1OfReal.hxx>
+
+//============================================================
+inline Standard_Real Contap_HCurve2dTool::FirstParameter (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->FirstParameter());
+}
+//============================================================
+inline Standard_Real Contap_HCurve2dTool::LastParameter (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->LastParameter());
+}
+//============================================================
+inline GeomAbs_Shape Contap_HCurve2dTool::Continuity (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Continuity());
+}
+//============================================================
+inline Standard_Integer Contap_HCurve2dTool::NbIntervals(const Handle(Adaptor2d_HCurve2d)& C,const GeomAbs_Shape Sh) {
+ return(C->NbIntervals(Sh));
+}
+//============================================================
+inline void Contap_HCurve2dTool::Intervals(const Handle(Adaptor2d_HCurve2d)& C,
+ TColStd_Array1OfReal& Tab,
+ const GeomAbs_Shape Sh) {
+ C->Intervals(Tab,Sh);
+}
+//============================================================
+inline Standard_Boolean Contap_HCurve2dTool::IsClosed(const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->IsClosed());
+}
+//============================================================
+inline Standard_Boolean Contap_HCurve2dTool::IsPeriodic(const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->IsPeriodic());
+}
+//============================================================
+inline Standard_Real Contap_HCurve2dTool::Period(const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Period());
+}
+//============================================================
+inline gp_Pnt2d Contap_HCurve2dTool::Value (const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U) {
+ return(C->Value(U));
+}
+//============================================================
+inline void Contap_HCurve2dTool::D0(const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U,
+ gp_Pnt2d& P) {
+ C->D0(U,P);
+}
+//============================================================
+inline void Contap_HCurve2dTool::D1 (const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U,
+ gp_Pnt2d& P,
+ gp_Vec2d& T) {
+ C->D1(U,P,T);
+}
+//============================================================
+inline void Contap_HCurve2dTool::D2 (const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U,
+ gp_Pnt2d& P,
+ gp_Vec2d& T,
+ gp_Vec2d& N) {
+
+ C->D2(U,P,T,N);
+}
+//============================================================
+inline void Contap_HCurve2dTool::D3 (const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U,
+ gp_Pnt2d& P,
+ gp_Vec2d& V1,
+ gp_Vec2d& V2,
+ gp_Vec2d& V3) {
+
+ C->D3(U,P,V1,V2,V3);
+}
+//============================================================
+inline gp_Vec2d Contap_HCurve2dTool::DN (const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real U,
+ const Standard_Integer N) {
+
+ return(C->DN(U,N));
+}
+//============================================================
+inline Standard_Real Contap_HCurve2dTool::Resolution(const Handle(Adaptor2d_HCurve2d)& C,
+ const Standard_Real R3d) {
+ return(C->Resolution(R3d));
+}
+//============================================================
+inline GeomAbs_CurveType Contap_HCurve2dTool::GetType(const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->GetType());
+}
+//============================================================
+inline gp_Lin2d Contap_HCurve2dTool::Line (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Line());
+}
+//============================================================
+inline gp_Circ2d Contap_HCurve2dTool::Circle (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Circle());
+}
+//============================================================
+inline gp_Elips2d Contap_HCurve2dTool::Ellipse (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Ellipse());
+}
+//============================================================
+inline gp_Parab2d Contap_HCurve2dTool::Parabola (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Parabola());
+}
+//============================================================
+inline gp_Hypr2d Contap_HCurve2dTool::Hyperbola (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Hyperbola());
+}
+//============================================================
+inline Handle(Geom2d_BezierCurve) Contap_HCurve2dTool::Bezier (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->Bezier());
+}
+//============================================================
+inline Handle(Geom2d_BSplineCurve) Contap_HCurve2dTool::BSpline (const Handle(Adaptor2d_HCurve2d)& C) {
+ return(C->BSpline());
+}
+//============================================================
+++ /dev/null
--- Created on: 1995-07-17
--- Created by: Laurent BUCHARD
--- Copyright (c) 1995-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-generic class HCurve2dToolGen from Contap (
- CurveGen as any)
-
-uses
- Array1OfReal from TColStd,
- Shape from GeomAbs,
- CurveType from GeomAbs,
- Vec2d from gp,
- Pnt2d from gp,
- Circ2d from gp,
- Elips2d from gp,
- Hypr2d from gp,
- Parab2d from gp,
- Lin2d from gp,
- BezierCurve from Geom2d,
- BSplineCurve from Geom2d
-
-raises
-
- OutOfRange from Standard,
- NoSuchObject from Standard,
- DomainError from Standard
-
-is
-
- --
- -- Global methods - Apply to the whole curve.
- --
-
- FirstParameter(myclass; C: CurveGen) returns Real
- ---C++: inline
- ;
-
-
- LastParameter(myclass; C: CurveGen) returns Real
- ---C++: inline
- ;
-
- --
- -- Services to break the curves to the expected continuity
- --
- -- If for example you need the curve to be C2 and the method
- -- Continuity returns you something lower than C2 (say C1 for
- -- example).
- --
- -- First compute the number of intervals with the requested
- -- continuity with the method NbIntervals(). Note that if the
- -- continuity is higher than the one you need NbIntervals will
- -- return 1.
- --
- -- Then you get the parameters bounding the intervals with the
- -- method Intervals, using an array of length at least
- -- NbIntervals()+1.
- --
- -- If you need to create a curve with a restricted span you can
- -- use the method Trim().
-
-
- Continuity(myclass; C: CurveGen) returns Shape from GeomAbs
- ---Purpose:
- ---C++: inline
- ;
-
- NbIntervals(myclass; C: CurveGen; S : Shape from GeomAbs) returns Integer
- ---Purpose: Returns the number of intervals for continuity
- -- <S>. May be one if Continuity(myclass) >= <S>
- ---C++: inline
- ;
-
- Intervals(myclass; C: CurveGen; T : in out Array1OfReal from TColStd;
- S : Shape from GeomAbs)
- ---Purpose: Stores in <T> the parameters bounding the intervals
- -- of continuity <S>.
- --
- -- The array must provide enough room to accomodate
- -- for the parameters. i.e. T.Length() > NbIntervals()
- raises
- OutOfRange from Standard
- ---C++: inline
- ;
-
- IsClosed(myclass; C: CurveGen) returns Boolean
- ---C++: inline
- ;
-
- IsPeriodic(myclass; C: CurveGen) returns Boolean
- ---C++: inline
- ;
-
- Period(myclass; C: CurveGen) returns Real
- raises
- DomainError from Standard -- if the curve is not periodic
- ---C++: inline
- ;
-
- Value(myclass; C: CurveGen; U : Real) returns Pnt2d from gp
- --- Purpose : Computes the point of parameter U on the curve.
- ---C++: inline
- ;
-
- D0 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp)
- --- Purpose : Computes the point of parameter U on the curve.
- ---C++: inline
- ;
-
- D1 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
- --- Purpose : Computes the point of parameter U on the curve with its
- -- first derivative.
- raises
- DomainError from Standard
- --- Purpose : Raised if the continuity of the current interval
- -- is not C1.
- ---C++: inline
- ;
-
- D2 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
- --- Purpose :
- -- Returns the point P of parameter U, the first and second
- -- derivatives V1 and V2.
- raises
- DomainError from Standard
- --- Purpose : Raised if the continuity of the current interval
- -- is not C2.
- ---C++: inline
- ;
-
- D3 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
- --- Purpose :
- -- Returns the point P of parameter U, the first, the second
- -- and the third derivative.
- raises
- DomainError from Standard
- --- Purpose : Raised if the continuity of the current interval
- -- is not C3.
- ---C++: inline
- ;
-
- DN (myclass; C: CurveGen; U : Real; N : Integer) returns Vec2d from gp
- --- Purpose :
- -- The returned vector gives the value of the derivative for the
- -- order of derivation N.
- raises
- DomainError from Standard,
- --- Purpose : Raised if the continuity of the current interval
- -- is not CN.
- OutOfRange from Standard
- --- Purpose : Raised if N < 1.
- ---C++: inline
- ;
-
- Resolution(myclass; C: CurveGen; R3d : Real) returns Real
- ---Purpose : Returns the parametric resolution corresponding
- -- to the real space resolution <R3d>.
- ---C++: inline
- ;
-
- GetType(myclass; C: CurveGen) returns CurveType from GeomAbs
- ---Purpose: Returns the type of the curve in the current
- -- interval : Line, Circle, Ellipse, Hyperbola,
- -- Parabola, BezierCurve, BSplineCurve, OtherCurve.
- ---C++: inline
- ;
-
- --
- -- The following methods must be called when GetType returned
- -- the corresponding type.
- --
-
- Line(myclass; C: CurveGen) returns Lin2d from gp
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
- Circle(myclass; C: CurveGen) returns Circ2d from gp
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
- Ellipse(myclass; C: CurveGen) returns Elips2d from gp
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
- Hyperbola(myclass; C: CurveGen) returns Hypr2d from gp
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
- Parabola(myclass; C: CurveGen) returns Parab2d from gp
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
- Bezier(myclass; C: CurveGen) returns BezierCurve from Geom2d
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
- BSpline(myclass; C: CurveGen) returns BSplineCurve from Geom2d
- raises
- NoSuchObject from Standard
- ---C++: inline
- ;
-
-
-
-
-
- NbSamples(myclass; C: CurveGen; U0,U1: Real from Standard)
- returns Integer from Standard;
-
-end HCurve2dToolGen;
+++ /dev/null
-// Created on: 1995-07-17
-// Created by: Modelistation
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include CurveGen_hxx
-#include <GeomAbs_CurveType.hxx>
-#include <GeomAbs_Shape.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-
-#include <TColStd_Array1OfReal.hxx>
-
-//============================================================
-Standard_Integer Contap_HCurve2dToolGen::NbSamples (const CurveGen& C,
- const Standard_Real U0,
- const Standard_Real U1)
-{
- Standard_Real nbs = 10.0;
- switch (C->GetType())
- {
- case GeomAbs_Line:
- nbs = 2.;
- break;
- case GeomAbs_BezierCurve:
- nbs = 3. + C->NbPoles();
- break;
- case GeomAbs_BSplineCurve:
- nbs = C->NbKnots();
- nbs*= C->Degree();
- nbs*= C->LastParameter()- C->FirstParameter();
- nbs/= U1-U0;
- if(nbs < 2.0) nbs = 2.;
- break;
- default:
- break;
- }
- if (nbs>50.)
- nbs = 50.;
- return((Standard_Integer)nbs);
-}
+++ /dev/null
-// Created on: 1992-10-22
-// Created by: Laurent BUCHARD
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include CurveGen_hxx
-
-#include <GeomAbs_CurveType.hxx>
-#include <GeomAbs_Shape.hxx>
-
-#include <gp_Vec2d.hxx>
-#include <gp_Lin2d.hxx>
-#include <gp_Circ2d.hxx>
-#include <gp_Elips2d.hxx>
-#include <gp_Parab2d.hxx>
-#include <gp_Hypr2d.hxx>
-
-
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-
-#include <TColStd_Array1OfReal.hxx>
-
-//============================================================
-inline Standard_Real Contap_HCurve2dToolGen::FirstParameter (const CurveGen& C) {
- return(C->FirstParameter());
-}
-//============================================================
-inline Standard_Real Contap_HCurve2dToolGen::LastParameter (const CurveGen& C) {
- return(C->LastParameter());
-}
-//============================================================
-inline GeomAbs_Shape Contap_HCurve2dToolGen::Continuity (const CurveGen& C) {
- return(C->Continuity());
-}
-//============================================================
-inline Standard_Integer Contap_HCurve2dToolGen::NbIntervals(const CurveGen& C,const GeomAbs_Shape Sh) {
- return(C->NbIntervals(Sh));
-}
-//============================================================
-inline void Contap_HCurve2dToolGen::Intervals(const CurveGen& C,
- TColStd_Array1OfReal& Tab,
- const GeomAbs_Shape Sh) {
- C->Intervals(Tab,Sh);
-}
-//============================================================
-inline Standard_Boolean Contap_HCurve2dToolGen::IsClosed(const CurveGen& C) {
- return(C->IsClosed());
-}
-//============================================================
-inline Standard_Boolean Contap_HCurve2dToolGen::IsPeriodic(const CurveGen& C) {
- return(C->IsPeriodic());
-}
-//============================================================
-inline Standard_Real Contap_HCurve2dToolGen::Period(const CurveGen& C) {
- return(C->Period());
-}
-//============================================================
-inline gp_Pnt2d Contap_HCurve2dToolGen::Value (const CurveGen& C,
- const Standard_Real U) {
- return(C->Value(U));
-}
-//============================================================
-inline void Contap_HCurve2dToolGen::D0(const CurveGen& C,
- const Standard_Real U,
- gp_Pnt2d& P) {
- C->D0(U,P);
-}
-//============================================================
-inline void Contap_HCurve2dToolGen::D1 (const CurveGen& C,
- const Standard_Real U,
- gp_Pnt2d& P,
- gp_Vec2d& T) {
- C->D1(U,P,T);
-}
-//============================================================
-inline void Contap_HCurve2dToolGen::D2 (const CurveGen& C,
- const Standard_Real U,
- gp_Pnt2d& P,
- gp_Vec2d& T,
- gp_Vec2d& N) {
-
- C->D2(U,P,T,N);
-}
-//============================================================
-inline void Contap_HCurve2dToolGen::D3 (const CurveGen& C,
- const Standard_Real U,
- gp_Pnt2d& P,
- gp_Vec2d& V1,
- gp_Vec2d& V2,
- gp_Vec2d& V3) {
-
- C->D3(U,P,V1,V2,V3);
-}
-//============================================================
-inline gp_Vec2d Contap_HCurve2dToolGen::DN (const CurveGen& C,
- const Standard_Real U,
- const Standard_Integer N) {
-
- return(C->DN(U,N));
-}
-//============================================================
-inline Standard_Real Contap_HCurve2dToolGen::Resolution(const CurveGen& C,
- const Standard_Real R3d) {
- return(C->Resolution(R3d));
-}
-//============================================================
-inline GeomAbs_CurveType Contap_HCurve2dToolGen::GetType(const CurveGen& C) {
- return(C->GetType());
-}
-//============================================================
-inline gp_Lin2d Contap_HCurve2dToolGen::Line (const CurveGen& C) {
- return(C->Line());
-}
-//============================================================
-inline gp_Circ2d Contap_HCurve2dToolGen::Circle (const CurveGen& C) {
- return(C->Circle());
-}
-//============================================================
-inline gp_Elips2d Contap_HCurve2dToolGen::Ellipse (const CurveGen& C) {
- return(C->Ellipse());
-}
-//============================================================
-inline gp_Parab2d Contap_HCurve2dToolGen::Parabola (const CurveGen& C) {
- return(C->Parabola());
-}
-//============================================================
-inline gp_Hypr2d Contap_HCurve2dToolGen::Hyperbola (const CurveGen& C) {
- return(C->Hyperbola());
-}
-//============================================================
-inline Handle(Geom2d_BezierCurve) Contap_HCurve2dToolGen::Bezier (const CurveGen& C) {
- return(C->Bezier());
-}
-//============================================================
-inline Handle(Geom2d_BSplineCurve) Contap_HCurve2dToolGen::BSpline (const CurveGen& C) {
- return(C->BSpline());
-}
-//============================================================
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-generic class Line from Contap
- (TheVertex as any;
- TheArc as any;
- ThePoint as any; --as Point from Contap(TheVertex,TheArc)
- TheHSequenceOfPoint as Transient) --as HSequence from TCollection
- -- (ThePoint)
+class Line from Contap
---Purpose:
Lin from gp,
Circ from gp,
Dir from gp,
- IType from Contap -- duplique IntPatch_IType. Mettre ds IntSurf
+ IType from Contap, -- duplique IntPatch_IType. Mettre ds IntSurf
+ HVertex from Adaptor3d,
+ HCurve2d from Adaptor2d,
+ Point from Contap,
+ TheHSequenceOfPoint from Contap
raises DomainError from Standard,
OutOfRange from Standard
is static;
- SetValue(me: in out; A: TheArc)
+ SetValue(me: in out; A: HCurve2d from Adaptor2d)
is static;
- Add(me: in out; P: ThePoint)
+ Add(me: in out; P: Point from Contap)
is static;
Vertex(me; Index: Integer from Standard)
- returns ThePoint
+ returns Point from Contap
---C++: return &
---C++: inline
Arc(me)
- returns any TheArc
+ returns any HCurve2d from Adaptor2d
---C++: return const&
raises DomainError from Standard
Trans : TypeTrans from IntSurf;
curv : LineOn2S from IntSurf;
- svtx : TheHSequenceOfPoint;
- thearc : TheArc;
+ svtx : TheHSequenceOfPoint from Contap;
+ thearc : HCurve2d from Adaptor2d;
typL : IType from Contap;
pt : Pnt from gp;
dir1 : Dir from gp;
--- /dev/null
+// Created on: 1993-02-05
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1993-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_Line.ixx>
+
+Contap_Line::Contap_Line () {
+ svtx = new Contap_TheHSequenceOfPoint ();
+ Trans = IntSurf_Undecided;
+}
+
+void Contap_Line::ResetSeqOfVertex() {
+ svtx = new Contap_TheHSequenceOfPoint ();
+}
+
+void Contap_Line::Add(const Contap_Point& P) {
+ Standard_Integer n = svtx->Length();
+ if(n==0) {
+ svtx->Append(P);
+ }
+ else {
+ Standard_Real prm = P.ParameterOnLine();
+ if(prm > svtx->Value(n).ParameterOnLine()) {
+ svtx->Append(P);
+ }
+ else {
+ for(Standard_Integer i=n-1;i>0;i--) {
+ if(prm> svtx->Value(i).ParameterOnLine()) {
+ svtx->InsertBefore(i+1,P);
+ return;
+ }
+ }
+ svtx->Prepend(P);
+ }
+ }
+}
+
+void Contap_Line::Clear () {
+ if(!curv.IsNull())
+ curv->Clear();
+ svtx = new Contap_TheHSequenceOfPoint ();
+ typL = Contap_Walking;
+}
+
+void Contap_Line::SetValue(const gp_Lin& L)
+{
+ pt = L.Location();
+ dir1 = L.Direction();
+ typL = Contap_Lin;
+}
+
+void Contap_Line::SetValue(const gp_Circ& C)
+{
+ pt = C.Location();
+ dir1 = C.Position().Direction();
+ dir2 = C.Position().XDirection();
+ rad = C.Radius();
+ typL = Contap_Circle;
+}
+
+void Contap_Line::SetValue(const Handle(Adaptor2d_HCurve2d)& A)
+{
+ thearc = A;
+ typL = Contap_Restriction;
+}
+
+void Contap_Line::SetLineOn2S(const Handle(IntSurf_LineOn2S)& L) {
+ curv = L;
+ typL = Contap_Walking;
+}
+
+void Contap_Line::SetTransitionOnS(const IntSurf_TypeTrans T) {
+ Trans = T;
+}
+
+IntSurf_TypeTrans Contap_Line::TransitionOnS() const {
+ return(Trans);
+}
+
+const Handle(Adaptor2d_HCurve2d)& Contap_Line::Arc () const
+{
+ if (typL != Contap_Restriction) {Standard_DomainError::Raise();}
+ return thearc;
+}
+++ /dev/null
-// Created on: 1993-02-05
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-Contap_Line::Contap_Line () {
- svtx = new TheHSequenceOfPoint ();
- Trans = IntSurf_Undecided;
-}
-
-void Contap_Line::ResetSeqOfVertex() {
- svtx = new TheHSequenceOfPoint ();
-}
-
-void Contap_Line::Add(const ThePoint& P) {
- Standard_Integer n = svtx->Length();
- if(n==0) {
- svtx->Append(P);
- }
- else {
- Standard_Real prm = P.ParameterOnLine();
- if(prm > svtx->Value(n).ParameterOnLine()) {
- svtx->Append(P);
- }
- else {
- for(Standard_Integer i=n-1;i>0;i--) {
- if(prm> svtx->Value(i).ParameterOnLine()) {
- svtx->InsertBefore(i+1,P);
- return;
- }
- }
- svtx->Prepend(P);
- }
- }
-}
-
-void Contap_Line::Clear () {
- if(!curv.IsNull())
- curv->Clear();
- svtx = new TheHSequenceOfPoint ();
- typL = Contap_Walking;
-}
-
-void Contap_Line::SetValue(const gp_Lin& L)
-{
- pt = L.Location();
- dir1 = L.Direction();
- typL = Contap_Lin;
-}
-
-void Contap_Line::SetValue(const gp_Circ& C)
-{
- pt = C.Location();
- dir1 = C.Position().Direction();
- dir2 = C.Position().XDirection();
- rad = C.Radius();
- typL = Contap_Circle;
-}
-
-void Contap_Line::SetValue(const TheArc& A)
-{
- thearc = A;
- typL = Contap_Restriction;
-}
-
-void Contap_Line::SetLineOn2S(const Handle(IntSurf_LineOn2S)& L) {
- curv = L;
- typL = Contap_Walking;
-}
-
-void Contap_Line::SetTransitionOnS(const IntSurf_TypeTrans T) {
- Trans = T;
-}
-
-IntSurf_TypeTrans Contap_Line::TransitionOnS() const {
- return(Trans);
-}
-
-const TheArc& Contap_Line::Arc () const
-{
- if (typL != Contap_Restriction) {Standard_DomainError::Raise();}
- return thearc;
-}
#include <IntSurf_PntOn2S.hxx>
#include <IntSurf_LineOn2S.hxx>
-#include TheHSequenceOfPoint_hxx
+#include <Contap_Point.hxx>
+#include <Contap_TheHSequenceOfPoint.hxx>
inline const Handle(IntSurf_LineOn2S)& Contap_Line::LineOn2S () const
{
return svtx->Length();
}
-inline ThePoint& Contap_Line::Vertex (const Standard_Integer Index) const
+inline Contap_Point& Contap_Line::Vertex (const Standard_Integer Index) const
{
return svtx->ChangeSequence()(Index);
}
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-generic class Point from Contap
- (TheVertex as any;
- TheArc as any)
+class Point from Contap
---Purpose: Definition of a vertex on the contour line.
uses Pnt from gp,
- Transition from IntSurf
+ Transition from IntSurf,
+ HVertex from Adaptor3d,
+ HCurve2d from Adaptor2d
raises DomainError from Standard
is static;
- SetVertex(me: in out; V: TheVertex)
+ SetVertex(me: in out; V: HVertex from Adaptor3d)
---Purpose: Sets the values of a point which is a vertex on
-- the initial facet of restriction of one
is static;
- SetArc(me: in out; A: TheArc; Param: Real from Standard;
+ SetArc(me: in out; A: HCurve2d from Adaptor2d; Param: Real from Standard;
TLine,TArc: Transition from IntSurf)
---Purpose: Sets the value of the arc and of the parameter on
---Purpose: Returns the arc of restriction containing the
-- vertex.
- returns any TheArc
+ returns any HCurve2d from Adaptor2d
---C++: return const&
---C++: inline
-- IsVertex returns True.
-- Otherwise, an exception is raised.
- returns any TheVertex
+ returns any HVertex from Adaptor3d
---C++: return const&
---C++: inline
vparam : Real from Standard;
paraline : Real from Standard;
onarc : Boolean from Standard;
- arc : TheArc;
+ arc : HCurve2d from Adaptor2d;
traline : Transition from IntSurf;
traarc : Transition from IntSurf;
prmarc : Real from Standard;
isvtx : Boolean from Standard;
- vtx : TheVertex;
+ vtx : HVertex from Adaptor3d;
ismult : Boolean from Standard;
myInternal : Boolean from Standard;
--- /dev/null
+// Created on: 1993-03-04
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1993-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_Point.ixx>
+
+Contap_Point::Contap_Point ():
+ onarc(Standard_False),isvtx(Standard_False),ismult(Standard_False),
+ myInternal(Standard_False)
+{}
+
+Contap_Point::Contap_Point (const gp_Pnt& Pt,
+ const Standard_Real U,
+ const Standard_Real V):
+pt(Pt),uparam(U),vparam(V),onarc(Standard_False),isvtx(Standard_False),
+ismult(Standard_False),myInternal(Standard_False)
+{}
+++ /dev/null
-// Created on: 1993-03-04
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-Contap_Point::Contap_Point ():
- onarc(Standard_False),isvtx(Standard_False),ismult(Standard_False),
- myInternal(Standard_False)
-{}
-
-Contap_Point::Contap_Point (const gp_Pnt& Pt,
- const Standard_Real U,
- const Standard_Real V):
- pt(Pt),uparam(U),vparam(V),onarc(Standard_False),isvtx(Standard_False),
- ismult(Standard_False),myInternal(Standard_False)
-{}
paraline = Para;
}
-inline void Contap_Point::SetVertex(const TheVertex& V) {
+inline void Contap_Point::SetVertex(const Handle(Adaptor3d_HVertex)& V) {
isvtx = Standard_True;
vtx = V;
}
-inline void Contap_Point::SetArc (const TheArc& A,
+inline void Contap_Point::SetArc (const Handle(Adaptor2d_HCurve2d)& A,
const Standard_Real Param,
const IntSurf_Transition& TLine,
const IntSurf_Transition& TArc) {
return onarc;
}
-inline const TheArc& Contap_Point::Arc () const {
+inline const Handle_Adaptor2d_HCurve2d& Contap_Point::Arc () const {
if (!onarc) {Standard_DomainError::Raise();}
return arc;
return isvtx;
}
-inline const TheVertex& Contap_Point::Vertex () const {
+inline const Handle_Adaptor3d_HVertex& Contap_Point::Vertex () const {
if (!isvtx) {Standard_DomainError::Raise();}
return vtx;
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-generic class SurfFunction from Contap
- (TheSurface as any;
- TheSurfaceTool as any;
- TheSurfProps as any; -- as SurfProps from Contap(TheSurface,
- -- TheSurfaceTool)
- TheContTool as any)
-
-inherits FunctionSetWithDerivatives from math
+class SurfFunction from Contap inherits FunctionSetWithDerivatives from math
---Purpose: This class describes the function on a parametric surface.
-- the form of the function is F(u,v) = 0 where u and v are
-- the parameteric coordinates of a point on the surface,
-- to compute the contours of the surface.
-uses Vector from math,
- Matrix from math,
- Pnt from gp,
- Vec from gp,
- Dir from gp,
- Dir2d from gp,
- TFunction from Contap
+uses Vector from math,
+ Matrix from math,
+ Pnt from gp,
+ Vec from gp,
+ Dir from gp,
+ Dir2d from gp,
+ TFunction from Contap,
+ HSurface from Adaptor3d,
+ HSurfaceTool from Adaptor3d,
+ HContTool from Contap
raises UndefinedDerivative from StdFail
returns SurfFunction from Contap;
- Set(me: in out; S: TheSurface)
+ Set(me: in out; S: HSurface from Adaptor3d)
is static;
Surface(me)
- returns any TheSurface
+ returns any HSurface from Adaptor3d
---C++: return const&
---C++: inline
is static;
fields
- mySurf : TheSurface;
+ mySurf : HSurface from Adaptor3d;
myMean : Real from Standard;
myType : TFunction from Contap;
myDir : Dir from gp;
--- /dev/null
+// Created on: 1993-06-03
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1993-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+// jag 940616 #define Tolpetit 1.e-16
+
+#include <Contap_SurfFunction.ixx>
+
+#include <Contap_SurfProps.hxx>
+#include <Contap_HContTool.hxx>
+#include <Adaptor3d_HSurfaceTool.hxx>
+
+Contap_SurfFunction::Contap_SurfFunction ():
+ myMean(1.),
+ myType(Contap_ContourStd),
+ myDir(0.,0.,1.),
+ myCosAng(0.), // PI/2 - Angle de depouille
+ tol(1.e-6),
+ computed(Standard_False),
+ derived(Standard_False)
+{}
+
+void Contap_SurfFunction::Set(const Handle(Adaptor3d_HSurface)& S)
+{
+ mySurf = S;
+ Standard_Integer i;
+ Standard_Integer nbs = Contap_HContTool::NbSamplePoints(S);
+ Standard_Real U,V;
+ gp_Vec norm;
+ if (nbs > 0) {
+ myMean = 0.;
+ for (i = 1; i <= nbs; i++) {
+ Contap_HContTool::SamplePoint(S,i,U,V);
+ // Adaptor3d_HSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
+ // myMean = myMean + d1u.Crossed(d1v).Magnitude();
+ Contap_SurfProps::Normale(S,U,V,solpt,norm);
+ myMean = myMean + norm.Magnitude();
+ }
+ myMean = myMean / ((Standard_Real)nbs);
+ }
+ computed = Standard_False;
+ derived = Standard_False;
+}
+
+
+Standard_Integer Contap_SurfFunction::NbVariables () const
+{
+ return 2;
+}
+
+Standard_Integer Contap_SurfFunction::NbEquations () const
+{
+ return 1;
+}
+
+
+Standard_Boolean Contap_SurfFunction::Value(const math_Vector& X,
+ math_Vector& F)
+{
+ Usol = X(1); Vsol = X(2);
+ // Adaptor3d_HSurfaceTool::D1(mySurf,Usol,Vsol,solpt,d1u,d1v);
+ // gp_Vec norm(d1u.Crossed(d1v));
+ gp_Vec norm;
+ Contap_SurfProps::Normale(mySurf,Usol,Vsol,solpt,norm);
+ switch (myType) {
+ case Contap_ContourStd:
+ {
+ F(1) = valf = (norm.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ F(1) = valf = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ F(1) = valf = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
+ }
+ break;
+ default:
+ {
+ }
+ }
+ computed = Standard_False;
+ derived = Standard_False;
+ return Standard_True;
+}
+
+
+Standard_Boolean Contap_SurfFunction::Derivatives(const math_Vector& X,
+ math_Matrix& Grad)
+{
+ // gp_Vec d2u,d2v,d2uv;
+ Usol = X(1); Vsol = X(2);
+ // Adaptor3d_HSurfaceTool::D2(mySurf,Usol,Vsol,solpt,d1u,d1v,d2u,d2v,d2uv);
+
+ gp_Vec norm,dnu,dnv;
+ Contap_SurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
+
+ switch (myType) {
+ case Contap_ContourStd:
+ {
+ // Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
+ // Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
+ Grad(1,1) = (dnu.Dot(myDir))/myMean;
+ Grad(1,2) = (dnv.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ gp_Vec Ep(myEye,solpt);
+ Grad(1,1) = (dnu.Dot(Ep))/myMean;
+ Grad(1,2) = (dnv.Dot(Ep))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ // gp_Vec norm(d1u.Crossed(d1v).Normalized());
+ // gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
+ // Grad(1,1) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ // dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
+ // Grad(1,2) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ norm.Normalize();
+ Grad(1,1) = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
+ Grad(1,2) = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ Fpu = Grad(1,1); Fpv = Grad(1,2);
+ computed = Standard_False;
+ derived = Standard_True;
+ return Standard_True;
+}
+
+
+Standard_Boolean Contap_SurfFunction::Values (const math_Vector& X,
+ math_Vector& F,
+ math_Matrix& Grad)
+{
+ // gp_Vec d2u,d2v,d2uv;
+
+ Usol = X(1); Vsol = X(2);
+ // Adaptor3d_HSurfaceTool::D2(mySurf,Usol,Vsol,solpt,d1u,d1v,d2u,d2v,d2uv);
+ // gp_Vec norm(d1u.Crossed(d1v));
+ gp_Vec norm,dnu,dnv;
+ Contap_SurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
+
+ switch (myType) {
+
+ case Contap_ContourStd:
+ {
+ F(1) = (norm.Dot(myDir))/myMean;
+ // Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
+ // Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
+ Grad(1,1) = (dnu.Dot(myDir))/myMean;
+ Grad(1,2) = (dnv.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ gp_Vec Ep(myEye,solpt);
+ F(1) = (norm.Dot(Ep))/myMean;
+ // Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
+ // Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
+ Grad(1,1) = (dnu.Dot(Ep))/myMean;
+ Grad(1,2) = (dnv.Dot(Ep))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ F(1) = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
+ norm.Normalize();
+ /*
+ gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
+ Grad(1,1) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
+ Grad(1,2) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ */
+ Grad(1,1) = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
+ Grad(1,2) = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ valf = F(1);
+ Fpu = Grad(1,1); Fpv = Grad(1,2);
+ computed = Standard_False;
+ derived = Standard_True;
+ return Standard_True;
+}
+
+
+Standard_Boolean Contap_SurfFunction::IsTangent ()
+{
+ if (!computed) {
+ computed = Standard_True;
+ if(!derived) {
+ // gp_Vec d2u,d2v,d2uv;
+ // Adaptor3d_HSurfaceTool::D2(mySurf, Usol, Vsol, solpt, d1u, d1v, d2u, d2v, d2uv);
+ gp_Vec norm,dnu,dnv;
+ Contap_SurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
+
+ switch (myType) {
+ case Contap_ContourStd:
+ {
+ // Fpu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
+ // Fpv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
+ Fpu = (dnu.Dot(myDir))/myMean;
+ Fpv = (dnv.Dot(myDir))/myMean;
+ }
+ break;
+ case Contap_ContourPrs:
+ {
+ gp_Vec Ep(myEye,solpt);
+ // Fpu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
+ // Fpv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
+ Fpu = (dnu.Dot(Ep))/myMean;
+ Fpv = (dnv.Dot(Ep))/myMean;
+ }
+ break;
+ case Contap_DraftStd:
+ {
+ /*
+ gp_Vec norm(d1u.Crossed(d1v).Normalized());
+ gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
+ Fpu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
+ Fpv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
+ */
+ norm.Normalize();
+ Fpu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
+ Fpv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
+ }
+ break;
+ case Contap_DraftPrs:
+ default:
+ {
+ }
+ }
+ derived = Standard_True;
+ }
+ tangent = Standard_False;
+ Standard_Real D = Sqrt (Fpu * Fpu + Fpv * Fpv);
+
+ if (D <= gp::Resolution()) {
+ tangent = Standard_True;
+ }
+ else {
+ d2d = gp_Dir2d(-Fpv,Fpu);
+ gp_Vec d1u,d1v;
+ Adaptor3d_HSurfaceTool::D1(mySurf, Usol, Vsol, solpt, d1u, d1v); // ajout jag 02.95
+
+ gp_XYZ d3dxyz(-Fpv*d1u.XYZ());
+ d3dxyz.Add(Fpu*d1v.XYZ());
+ d3d.SetXYZ(d3dxyz);
+
+ //jag 940616 if (d3d.Magnitude() <= Tolpetit) {
+ if (d3d.Magnitude() <= tol) {
+ tangent = Standard_True;
+ }
+ }
+ }
+ return tangent;
+}
+++ /dev/null
-// Created on: 1993-06-03
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// jag 940616 #define Tolpetit 1.e-16
-
-
-#include <gp.hxx>
-
-
-Contap_SurfFunction::Contap_SurfFunction ():
- myMean(1.),
- myType(Contap_ContourStd),
- myDir(0.,0.,1.),
- myCosAng(0.), // PI/2 - Angle de depouille
- tol(1.e-6),
- computed(Standard_False),
- derived(Standard_False)
-{}
-
-void Contap_SurfFunction::Set(const TheSurface& S)
-{
- mySurf = S;
- Standard_Integer i;
- Standard_Integer nbs = TheContTool::NbSamplePoints(S);
- Standard_Real U,V;
- gp_Vec norm;
- if (nbs > 0) {
- myMean = 0.;
- for (i = 1; i <= nbs; i++) {
- TheContTool::SamplePoint(S,i,U,V);
-// TheSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
-// myMean = myMean + d1u.Crossed(d1v).Magnitude();
- TheSurfProps::Normale(S,U,V,solpt,norm);
- myMean = myMean + norm.Magnitude();
- }
- myMean = myMean / ((Standard_Real)nbs);
- }
- computed = Standard_False;
- derived = Standard_False;
-}
-
-
-Standard_Integer Contap_SurfFunction::NbVariables () const
-{
- return 2;
-}
-
-Standard_Integer Contap_SurfFunction::NbEquations () const
-{
- return 1;
-}
-
-
-Standard_Boolean Contap_SurfFunction::Value(const math_Vector& X,
- math_Vector& F)
-{
- Usol = X(1); Vsol = X(2);
-// TheSurfaceTool::D1(mySurf,Usol,Vsol,solpt,d1u,d1v);
-// gp_Vec norm(d1u.Crossed(d1v));
- gp_Vec norm;
- TheSurfProps::Normale(mySurf,Usol,Vsol,solpt,norm);
- switch (myType) {
- case Contap_ContourStd:
- {
- F(1) = valf = (norm.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- F(1) = valf = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
- F(1) = valf = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
- }
- break;
- default:
- {
- }
- }
- computed = Standard_False;
- derived = Standard_False;
- return Standard_True;
-}
-
-
-Standard_Boolean Contap_SurfFunction::Derivatives(const math_Vector& X,
- math_Matrix& Grad)
-{
-// gp_Vec d2u,d2v,d2uv;
- Usol = X(1); Vsol = X(2);
-// TheSurfaceTool::D2(mySurf,Usol,Vsol,solpt,d1u,d1v,d2u,d2v,d2uv);
-
- gp_Vec norm,dnu,dnv;
- TheSurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
-
- switch (myType) {
- case Contap_ContourStd:
- {
-// Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
-// Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
- Grad(1,1) = (dnu.Dot(myDir))/myMean;
- Grad(1,2) = (dnv.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- gp_Vec Ep(myEye,solpt);
- Grad(1,1) = (dnu.Dot(Ep))/myMean;
- Grad(1,2) = (dnv.Dot(Ep))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
-// gp_Vec norm(d1u.Crossed(d1v).Normalized());
-// gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
-// Grad(1,1) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
-// dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
-// Grad(1,2) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
- norm.Normalize();
- Grad(1,1) = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
- Grad(1,2) = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- Fpu = Grad(1,1); Fpv = Grad(1,2);
- computed = Standard_False;
- derived = Standard_True;
- return Standard_True;
-}
-
-
-Standard_Boolean Contap_SurfFunction::Values (const math_Vector& X,
- math_Vector& F,
- math_Matrix& Grad)
-{
-// gp_Vec d2u,d2v,d2uv;
-
- Usol = X(1); Vsol = X(2);
-// TheSurfaceTool::D2(mySurf,Usol,Vsol,solpt,d1u,d1v,d2u,d2v,d2uv);
-// gp_Vec norm(d1u.Crossed(d1v));
- gp_Vec norm,dnu,dnv;
- TheSurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
-
- switch (myType) {
-
- case Contap_ContourStd:
- {
- F(1) = (norm.Dot(myDir))/myMean;
-// Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
-// Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
- Grad(1,1) = (dnu.Dot(myDir))/myMean;
- Grad(1,2) = (dnv.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- gp_Vec Ep(myEye,solpt);
- F(1) = (norm.Dot(Ep))/myMean;
-// Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
-// Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
- Grad(1,1) = (dnu.Dot(Ep))/myMean;
- Grad(1,2) = (dnv.Dot(Ep))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
- F(1) = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
- norm.Normalize();
-/*
- gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
- Grad(1,1) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
- dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
- Grad(1,2) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
-*/
- Grad(1,1) = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
- Grad(1,2) = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- valf = F(1);
- Fpu = Grad(1,1); Fpv = Grad(1,2);
- computed = Standard_False;
- derived = Standard_True;
- return Standard_True;
-}
-
-
-Standard_Boolean Contap_SurfFunction::IsTangent ()
-{
- if (!computed) {
- computed = Standard_True;
- if(!derived) {
-// gp_Vec d2u,d2v,d2uv;
-// TheSurfaceTool::D2(mySurf, Usol, Vsol, solpt, d1u, d1v, d2u, d2v, d2uv);
- gp_Vec norm,dnu,dnv;
- TheSurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
-
- switch (myType) {
- case Contap_ContourStd:
- {
-// Fpu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
-// Fpv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
- Fpu = (dnu.Dot(myDir))/myMean;
- Fpv = (dnv.Dot(myDir))/myMean;
- }
- break;
- case Contap_ContourPrs:
- {
- gp_Vec Ep(myEye,solpt);
-// Fpu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
-// Fpv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
- Fpu = (dnu.Dot(Ep))/myMean;
- Fpv = (dnv.Dot(Ep))/myMean;
- }
- break;
- case Contap_DraftStd:
- {
-/*
- gp_Vec norm(d1u.Crossed(d1v).Normalized());
- gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
- Fpu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
- dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
- Fpv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
-*/
- norm.Normalize();
- Fpu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
- Fpv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
- }
- break;
- case Contap_DraftPrs:
- default:
- {
- }
- }
- derived = Standard_True;
- }
- tangent = Standard_False;
- Standard_Real D = Sqrt (Fpu * Fpu + Fpv * Fpv);
-
- if (D <= gp::Resolution()) {
- tangent = Standard_True;
- }
- else {
- d2d = gp_Dir2d(-Fpv,Fpu);
- gp_Vec d1u,d1v;
- TheSurfaceTool::D1(mySurf, Usol, Vsol, solpt, d1u, d1v); // ajout jag 02.95
-
- gp_XYZ d3dxyz(-Fpv*d1u.XYZ());
- d3dxyz.Add(Fpu*d1v.XYZ());
- d3d.SetXYZ(d3dxyz);
-
- //jag 940616 if (d3d.Magnitude() <= Tolpetit) {
- if (d3d.Magnitude() <= tol) {
- tangent = Standard_True;
- }
- }
- }
- return tangent;
-}
return d2d;
}
-inline const TheSurface& Contap_SurfFunction::Surface() const
+inline const Handle_Adaptor3d_HSurface& Contap_SurfFunction::Surface() const
{
return mySurf;
}
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-generic class SurfProps from Contap
- (TheSurface as any;
- TheSurfaceTool as any)
+class SurfProps from Contap
---Purpose: Internal tool used to compute the normal and its
-- derivatives.
-uses Pnt from gp,
- Vec from gp
+uses Pnt from gp,
+ Vec from gp,
+ HSurface from Adaptor3d,
+ HSurfaceTool from Adaptor3d
is
- Normale(myclass; S: TheSurface; U,V: Real from Standard;
+ Normale(myclass; S: HSurface from Adaptor3d; U,V: Real from Standard;
P: out Pnt from gp;
N: out Vec from gp);
- DerivAndNorm(myclass; S: TheSurface; U,V: Real from Standard;
+ DerivAndNorm(myclass; S: HSurface from Adaptor3d; U,V: Real from Standard;
P : out Pnt from gp;
d1u,d1v: out Vec from gp;
N : out Vec from gp);
- NormAndDn(myclass; S: TheSurface; U,V: Real from Standard;
+ NormAndDn(myclass; S: HSurface from Adaptor3d; U,V: Real from Standard;
P : out Pnt from gp;
N,Dnu,Dnv: out Vec from gp);
--- /dev/null
+// Created on: 1995-02-24
+// Created by: Jacques GOUSSARD
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Contap_SurfProps.ixx>
+
+#include <ElSLib.hxx>
+#include <Adaptor3d_HSurfaceTool.hxx>
+
+//=======================================================================
+//function : Normale
+//purpose :
+//=======================================================================
+
+void Contap_SurfProps::Normale(const Handle(Adaptor3d_HSurface)& S,
+ const Standard_Real U,
+ const Standard_Real V,
+ gp_Pnt& P,
+ gp_Vec& Norm)
+{
+
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(S);
+ switch (typS) {
+ case GeomAbs_Plane:
+ {
+ gp_Pln pl(Adaptor3d_HSurfaceTool::Plane(S));
+ Norm = pl.Axis().Direction();
+ P = ElSLib::Value(U,V,pl);
+ if (!pl.Direct()) {
+ Norm.Reverse();
+ }
+ }
+ break;
+
+
+ case GeomAbs_Sphere:
+ {
+ gp_Sphere sp(Adaptor3d_HSurfaceTool::Sphere(S));
+ P = ElSLib::Value(U,V,sp);
+ Norm = gp_Vec(sp.Location(),P);
+ if (sp.Direct()) {
+ Norm.Divide(sp.Radius());
+ }
+ else {
+ Norm.Divide(-sp.Radius());
+ }
+ }
+ break;
+
+ case GeomAbs_Cylinder:
+ {
+ gp_Cylinder cy(Adaptor3d_HSurfaceTool::Cylinder(S));
+ P = ElSLib::Value(U,V,cy);
+ Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
+ Sin(U),cy.YAxis().Direction());
+ if (!cy.Direct()) {
+ Norm.Reverse();
+ }
+ }
+ break;
+
+
+ case GeomAbs_Cone:
+ {
+ gp_Cone co(Adaptor3d_HSurfaceTool::Cone(S));
+ P = ElSLib::Value(U,V,co);
+ Standard_Real Angle = co.SemiAngle();
+ Standard_Real Sina = sin(Angle);
+ Standard_Real Cosa = cos(Angle);
+ Standard_Real Rad = co.RefRadius();
+
+ Standard_Real Vcalc = V;
+ if (Abs(V*Sina + Rad) <= 1e-12) { // on est a l`apex
+ /*
+ Standard_Real Vfi = Adaptor3d_HSurfaceTool::FirstVParameter(S);
+ if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
+ Vcalc = V - 1;
+ }
+ else {
+ Vcalc = V + 1.;
+ }
+ */
+ Norm.SetCoord(0,0,0);
+ return;
+ }
+
+ if (Rad + Vcalc*Sina < 0.) {
+ Norm.SetLinearForm(Sina, co.Axis().Direction(),
+ Cosa*cos(U),co.XAxis().Direction(),
+ Cosa*sin(U),co.YAxis().Direction());
+ }
+ else {
+ Norm.SetLinearForm(-Sina, co.Axis().Direction(),
+ Cosa*cos(U),co.XAxis().Direction(),
+ Cosa*sin(U),co.YAxis().Direction());
+ }
+ if (!co.Direct()) {
+ Norm.Reverse();
+ }
+ }
+ break;
+ default:
+ {
+ gp_Vec d1u,d1v;
+ Adaptor3d_HSurfaceTool::D1(S,U,V,P,d1u,d1v);
+ Norm = d1u.Crossed(d1v);
+ }
+ break;
+
+
+ }
+}
+
+
+//=======================================================================
+//function : DerivAndNorm
+//purpose :
+//=======================================================================
+
+void Contap_SurfProps::DerivAndNorm(const Handle(Adaptor3d_HSurface)& S,
+ const Standard_Real U,
+ const Standard_Real V,
+ gp_Pnt& P,
+ gp_Vec& d1u,
+ gp_Vec& d1v,
+ gp_Vec& Norm)
+{
+
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(S);
+ switch (typS) {
+ case GeomAbs_Plane:
+ {
+ gp_Pln pl(Adaptor3d_HSurfaceTool::Plane(S));
+ Norm = pl.Axis().Direction();
+ ElSLib::D1(U,V,pl,P,d1u,d1v);
+ if (!pl.Direct()) {
+ Norm.Reverse();
+ }
+ }
+ break;
+
+
+ case GeomAbs_Sphere:
+ {
+ gp_Sphere sp(Adaptor3d_HSurfaceTool::Sphere(S));
+ ElSLib::D1(U,V,sp,P,d1u,d1v);
+ Norm = gp_Vec(sp.Location(),P);
+ if (sp.Direct()) {
+ Norm.Divide(sp.Radius());
+ }
+ else {
+ Norm.Divide(-sp.Radius());
+ }
+ }
+ break;
+
+ case GeomAbs_Cylinder:
+ {
+ gp_Cylinder cy(Adaptor3d_HSurfaceTool::Cylinder(S));
+ ElSLib::D1(U,V,cy,P,d1u,d1v);
+ Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
+ Sin(U),cy.YAxis().Direction());
+ if (!cy.Direct()) {
+ Norm.Reverse();
+ }
+ }
+ break;
+
+
+ case GeomAbs_Cone:
+ {
+ gp_Cone co(Adaptor3d_HSurfaceTool::Cone(S));
+ ElSLib::D1(U,V,co,P,d1u,d1v);
+ Standard_Real Angle = co.SemiAngle();
+ Standard_Real Sina = Sin(Angle);
+ Standard_Real Cosa = Cos(Angle);
+ Standard_Real Rad = co.RefRadius();
+
+ Standard_Real Vcalc = V;
+ if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
+ Standard_Real Vfi = Adaptor3d_HSurfaceTool::FirstVParameter(S);
+ if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
+ Vcalc = V - 1;
+ }
+ else {
+ Vcalc = V + 1.;
+ }
+ }
+
+ if (Rad + Vcalc*Sina < 0.) {
+ Norm.SetLinearForm(Sina, co.Axis().Direction(),
+ Cosa*Cos(U),co.XAxis().Direction(),
+ Cosa*Sin(U),co.YAxis().Direction());
+ }
+ else {
+ Norm.SetLinearForm(-Sina, co.Axis().Direction(),
+ Cosa*Cos(U),co.XAxis().Direction(),
+ Cosa*Sin(U),co.YAxis().Direction());
+ }
+ if (!co.Direct()) {
+ Norm.Reverse();
+ }
+ }
+ break;
+ default:
+ {
+ Adaptor3d_HSurfaceTool::D1(S,U,V,P,d1u,d1v);
+ Norm = d1u.Crossed(d1v);
+ }
+ break;
+ }
+}
+
+
+//=======================================================================
+//function : NormAndDn
+//purpose :
+//=======================================================================
+
+void Contap_SurfProps::NormAndDn(const Handle(Adaptor3d_HSurface)& S,
+ const Standard_Real U,
+ const Standard_Real V,
+ gp_Pnt& P,
+ gp_Vec& Norm,
+ gp_Vec& Dnu,
+ gp_Vec& Dnv)
+{
+
+ GeomAbs_SurfaceType typS = Adaptor3d_HSurfaceTool::GetType(S);
+ switch (typS) {
+ case GeomAbs_Plane:
+ {
+ gp_Pln pl(Adaptor3d_HSurfaceTool::Plane(S));
+ P = ElSLib::Value(U,V,pl);
+ Norm = pl.Axis().Direction();
+ if (!pl.Direct()) {
+ Norm.Reverse();
+ }
+ Dnu = Dnv = gp_Vec(0.,0.,0.);
+ }
+ break;
+
+ case GeomAbs_Sphere:
+ {
+ gp_Sphere sp(Adaptor3d_HSurfaceTool::Sphere(S));
+ ElSLib::D1(U,V,sp,P,Dnu,Dnv);
+ Norm = gp_Vec(sp.Location(),P);
+ Standard_Real Rad = sp.Radius();
+ if (!sp.Direct()) {
+ Rad = -Rad;
+ }
+ Norm.Divide(Rad);
+ Dnu.Divide(Rad);
+ Dnv.Divide(Rad);
+ }
+ break;
+
+ case GeomAbs_Cylinder:
+ {
+ gp_Cylinder cy(Adaptor3d_HSurfaceTool::Cylinder(S));
+ P = ElSLib::Value(U,V,cy);
+ Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
+ Sin(U),cy.YAxis().Direction());
+ Dnu.SetLinearForm(-Sin(U),cy.XAxis().Direction(),
+ Cos(U),cy.YAxis().Direction());
+ if (!cy.Direct()) {
+ Norm.Reverse();
+ Dnu.Reverse();
+ }
+ Dnv = gp_Vec(0.,0.,0.);
+ }
+ break;
+
+ case GeomAbs_Cone:
+ {
+
+ gp_Cone co(Adaptor3d_HSurfaceTool::Cone(S));
+ P = ElSLib::Value(U,V,co);
+ Standard_Real Angle = co.SemiAngle();
+ Standard_Real Sina = Sin(Angle);
+ Standard_Real Cosa = Cos(Angle);
+ Standard_Real Rad = co.RefRadius();
+ Standard_Real Vcalc = V;
+ if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
+ Standard_Real Vfi = Adaptor3d_HSurfaceTool::FirstVParameter(S);
+ if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
+ Vcalc = V - 1;
+ }
+ else {
+ Vcalc = V + 1.;
+ }
+ }
+
+ if (Rad + Vcalc*Sina < 0.) {
+ Norm.SetLinearForm(Sina, co.Axis().Direction(),
+ Cosa*Cos(U),co.XAxis().Direction(),
+ Cosa*Sin(U),co.YAxis().Direction());
+ }
+ else {
+ Norm.SetLinearForm(-Sina, co.Axis().Direction(),
+ Cosa*Cos(U),co.XAxis().Direction(),
+ Cosa*Sin(U),co.YAxis().Direction());
+ }
+ Dnu.SetLinearForm(-Cosa*Sin(U),co.XAxis().Direction(),
+ Cosa*Cos(U),co.YAxis().Direction());
+ if (!co.Direct()) {
+ Norm.Reverse();
+ Dnu.Reverse();
+ }
+ Dnv = gp_Vec(0.,0.,0.);
+ }
+ break;
+
+ default:
+ {
+ gp_Vec d1u,d1v,d2u,d2v,d2uv;
+ Adaptor3d_HSurfaceTool::D2(S,U,V,P,d1u,d1v,d2u,d2v,d2uv);
+ Norm = d1u.Crossed(d1v);
+ Dnu = d2u.Crossed(d1v) + d1u.Crossed(d2uv);
+ Dnv = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
+ }
+ break;
+ }
+}
+++ /dev/null
-// Created on: 1995-02-24
-// Created by: Jacques GOUSSARD
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <ElSLib.hxx>
-
-//=======================================================================
-//function : Normale
-//purpose :
-//=======================================================================
-
-void Contap_SurfProps::Normale(const TheSurface& S,
- const Standard_Real U,
- const Standard_Real V,
- gp_Pnt& P,
- gp_Vec& Norm)
-{
-
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
- switch (typS) {
- case GeomAbs_Plane:
- {
- gp_Pln pl(TheSurfaceTool::Plane(S));
- Norm = pl.Axis().Direction();
- P = ElSLib::Value(U,V,pl);
- if (!pl.Direct()) {
- Norm.Reverse();
- }
- }
- break;
-
-
- case GeomAbs_Sphere:
- {
- gp_Sphere sp(TheSurfaceTool::Sphere(S));
- P = ElSLib::Value(U,V,sp);
- Norm = gp_Vec(sp.Location(),P);
- if (sp.Direct()) {
- Norm.Divide(sp.Radius());
- }
- else {
- Norm.Divide(-sp.Radius());
- }
- }
- break;
-
- case GeomAbs_Cylinder:
- {
- gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
- P = ElSLib::Value(U,V,cy);
- Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
- Sin(U),cy.YAxis().Direction());
- if (!cy.Direct()) {
- Norm.Reverse();
- }
- }
- break;
-
-
- case GeomAbs_Cone:
- {
- gp_Cone co(TheSurfaceTool::Cone(S));
- P = ElSLib::Value(U,V,co);
- Standard_Real Angle = co.SemiAngle();
- Standard_Real Sina = sin(Angle);
- Standard_Real Cosa = cos(Angle);
- Standard_Real Rad = co.RefRadius();
-
- Standard_Real Vcalc = V;
- if (Abs(V*Sina + Rad) <= 1e-12) { // on est a l`apex
- /*
- Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
- if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
- Vcalc = V - 1;
- }
- else {
- Vcalc = V + 1.;
- }
- */
- Norm.SetCoord(0,0,0);
- return;
- }
-
- if (Rad + Vcalc*Sina < 0.) {
- Norm.SetLinearForm(Sina, co.Axis().Direction(),
- Cosa*cos(U),co.XAxis().Direction(),
- Cosa*sin(U),co.YAxis().Direction());
- }
- else {
- Norm.SetLinearForm(-Sina, co.Axis().Direction(),
- Cosa*cos(U),co.XAxis().Direction(),
- Cosa*sin(U),co.YAxis().Direction());
- }
- if (!co.Direct()) {
- Norm.Reverse();
- }
- }
- break;
- default:
- {
- gp_Vec d1u,d1v;
- TheSurfaceTool::D1(S,U,V,P,d1u,d1v);
- Norm = d1u.Crossed(d1v);
- }
- break;
-
-
- }
-}
-
-
-//=======================================================================
-//function : DerivAndNorm
-//purpose :
-//=======================================================================
-
-void Contap_SurfProps::DerivAndNorm(const TheSurface& S,
- const Standard_Real U,
- const Standard_Real V,
- gp_Pnt& P,
- gp_Vec& d1u,
- gp_Vec& d1v,
- gp_Vec& Norm)
-{
-
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
- switch (typS) {
- case GeomAbs_Plane:
- {
- gp_Pln pl(TheSurfaceTool::Plane(S));
- Norm = pl.Axis().Direction();
- ElSLib::D1(U,V,pl,P,d1u,d1v);
- if (!pl.Direct()) {
- Norm.Reverse();
- }
- }
- break;
-
-
- case GeomAbs_Sphere:
- {
- gp_Sphere sp(TheSurfaceTool::Sphere(S));
- ElSLib::D1(U,V,sp,P,d1u,d1v);
- Norm = gp_Vec(sp.Location(),P);
- if (sp.Direct()) {
- Norm.Divide(sp.Radius());
- }
- else {
- Norm.Divide(-sp.Radius());
- }
- }
- break;
-
- case GeomAbs_Cylinder:
- {
- gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
- ElSLib::D1(U,V,cy,P,d1u,d1v);
- Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
- Sin(U),cy.YAxis().Direction());
- if (!cy.Direct()) {
- Norm.Reverse();
- }
- }
- break;
-
-
- case GeomAbs_Cone:
- {
- gp_Cone co(TheSurfaceTool::Cone(S));
- ElSLib::D1(U,V,co,P,d1u,d1v);
- Standard_Real Angle = co.SemiAngle();
- Standard_Real Sina = Sin(Angle);
- Standard_Real Cosa = Cos(Angle);
- Standard_Real Rad = co.RefRadius();
-
- Standard_Real Vcalc = V;
- if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
- Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
- if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
- Vcalc = V - 1;
- }
- else {
- Vcalc = V + 1.;
- }
- }
-
- if (Rad + Vcalc*Sina < 0.) {
- Norm.SetLinearForm(Sina, co.Axis().Direction(),
- Cosa*Cos(U),co.XAxis().Direction(),
- Cosa*Sin(U),co.YAxis().Direction());
- }
- else {
- Norm.SetLinearForm(-Sina, co.Axis().Direction(),
- Cosa*Cos(U),co.XAxis().Direction(),
- Cosa*Sin(U),co.YAxis().Direction());
- }
- if (!co.Direct()) {
- Norm.Reverse();
- }
- }
- break;
- default:
- {
- TheSurfaceTool::D1(S,U,V,P,d1u,d1v);
- Norm = d1u.Crossed(d1v);
- }
- break;
- }
-}
-
-
-//=======================================================================
-//function : NormAndDn
-//purpose :
-//=======================================================================
-
-void Contap_SurfProps::NormAndDn(const TheSurface& S,
- const Standard_Real U,
- const Standard_Real V,
- gp_Pnt& P,
- gp_Vec& Norm,
- gp_Vec& Dnu,
- gp_Vec& Dnv)
-{
-
- GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
- switch (typS) {
- case GeomAbs_Plane:
- {
- gp_Pln pl(TheSurfaceTool::Plane(S));
- P = ElSLib::Value(U,V,pl);
- Norm = pl.Axis().Direction();
- if (!pl.Direct()) {
- Norm.Reverse();
- }
- Dnu = Dnv = gp_Vec(0.,0.,0.);
- }
- break;
-
- case GeomAbs_Sphere:
- {
- gp_Sphere sp(TheSurfaceTool::Sphere(S));
- ElSLib::D1(U,V,sp,P,Dnu,Dnv);
- Norm = gp_Vec(sp.Location(),P);
- Standard_Real Rad = sp.Radius();
- if (!sp.Direct()) {
- Rad = -Rad;
- }
- Norm.Divide(Rad);
- Dnu.Divide(Rad);
- Dnv.Divide(Rad);
- }
- break;
-
- case GeomAbs_Cylinder:
- {
- gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
- P = ElSLib::Value(U,V,cy);
- Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
- Sin(U),cy.YAxis().Direction());
- Dnu.SetLinearForm(-Sin(U),cy.XAxis().Direction(),
- Cos(U),cy.YAxis().Direction());
- if (!cy.Direct()) {
- Norm.Reverse();
- Dnu.Reverse();
- }
- Dnv = gp_Vec(0.,0.,0.);
- }
- break;
-
- case GeomAbs_Cone:
- {
-
- gp_Cone co(TheSurfaceTool::Cone(S));
- P = ElSLib::Value(U,V,co);
- Standard_Real Angle = co.SemiAngle();
- Standard_Real Sina = Sin(Angle);
- Standard_Real Cosa = Cos(Angle);
- Standard_Real Rad = co.RefRadius();
- Standard_Real Vcalc = V;
- if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
- Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
- if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
- Vcalc = V - 1;
- }
- else {
- Vcalc = V + 1.;
- }
- }
-
- if (Rad + Vcalc*Sina < 0.) {
- Norm.SetLinearForm(Sina, co.Axis().Direction(),
- Cosa*Cos(U),co.XAxis().Direction(),
- Cosa*Sin(U),co.YAxis().Direction());
- }
- else {
- Norm.SetLinearForm(-Sina, co.Axis().Direction(),
- Cosa*Cos(U),co.XAxis().Direction(),
- Cosa*Sin(U),co.YAxis().Direction());
- }
- Dnu.SetLinearForm(-Cosa*Sin(U),co.XAxis().Direction(),
- Cosa*Cos(U),co.YAxis().Direction());
- if (!co.Direct()) {
- Norm.Reverse();
- Dnu.Reverse();
- }
- Dnv = gp_Vec(0.,0.,0.);
- }
- break;
-
- default:
- {
- gp_Vec d1u,d1v,d2u,d2v,d2uv;
- TheSurfaceTool::D2(S,U,V,P,d1u,d1v,d2u,d2v,d2uv);
- Norm = d1u.Crossed(d1v);
- Dnu = d2u.Crossed(d1v) + d1u.Crossed(d2uv);
- Dnv = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
- }
- break;
- }
-}
+++ /dev/null
-Contap_ContourGen_1.gxx
-Contap_ContourGen_2.gxx
-Contap_ContourGen_3.gxx
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
- ThePointOfContour from Contap,
+ Point from Contap,
Contour from Contap,
Data from HLRTopoBRep,
MapOfShapeTool from BRepTopAdaptor
is private;
MakeVertex(myclass;
- P : ThePointOfContour from Contap;
+ P : Point from Contap;
tol : Real from Standard;
DS : in out Data from HLRTopoBRep)
returns Vertex from TopoDS
is private;
InsertVertex(myclass;
- P : ThePointOfContour from Contap;
+ P : Point from Contap;
tol : Real from Standard;
E : Edge from TopoDS;
DS : in out Data from HLRTopoBRep)
#include <BRepTopAdaptor_HVertex.hxx>
#include <BRepTopAdaptor_TopolTool.hxx>
#include <BRepTopAdaptor_Tool.hxx>
-#include <Contap_TheLineOfContour.hxx>
+#include <Contap_Line.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <Standard_ProgramError.hxx>
#include <Precision.hxx>
Standard_Integer CurLine;
for (CurLine = 1; CurLine <= NbLines; CurLine++)
{
- const Contap_TheLineOfContour& Line = FO.Line(CurLine);
+ const Contap_Line& Line = FO.Line(CurLine);
const Standard_Integer NbPoints = Line.NbVertex();
Standard_Integer CurPoint;
if (Line.TypeContour() == Contap_Restriction)
// insert the Internal points.
for (CurPoint = 1; CurPoint <= NbPoints; CurPoint++) {
- Contap_ThePointOfContour P = Line.Vertex(CurPoint);
+ Contap_Point P = Line.Vertex(CurPoint);
if (P.IsInternal()) {
if (P.Value().IsEqual(BRep_Tool::Pnt(VF),BRep_Tool::Tolerance(VF))) {
if (P.Value().IsEqual(BRep_Tool::Pnt(VL),BRep_Tool::Tolerance(VL))) {
{
for (CurPoint = 1; CurPoint <= NbPoints; CurPoint++) {
- const Contap_ThePointOfContour PF = Line.Vertex(CurPoint);
+ const Contap_Point PF = Line.Vertex(CurPoint);
if (PF.IsInternal() && CurPoint != 1)
VF = VL;
else
const Standard_Real parF = PF.ParameterOnLine();
if (CurPoint < NbPoints) {
- const Contap_ThePointOfContour PL = Line.Vertex(CurPoint+1);
+ const Contap_Point PL = Line.Vertex(CurPoint+1);
VL = MakeVertex(PL,tol,DS);
const Standard_Real parL = PL.ParameterOnLine();
/*
else if(ipL-ipF < 6) {
// compute the tangents
- Contap_TheSurfFunctionOfContour& SFunc =
+ Contap_SurfFunction& SFunc =
FO.SurfaceFunction();
Standard_Boolean isTg1,isTg2;
//=======================================================================
TopoDS_Vertex
-HLRTopoBRep_DSFiller::MakeVertex (const Contap_ThePointOfContour& P,
+HLRTopoBRep_DSFiller::MakeVertex (const Contap_Point& P,
const Standard_Real tol,
HLRTopoBRep_Data& DS)
{
//=======================================================================
void
-HLRTopoBRep_DSFiller::InsertVertex (const Contap_ThePointOfContour& P,
+HLRTopoBRep_DSFiller::InsertVertex (const Contap_Point& P,
const Standard_Real tol,
const TopoDS_Edge& E,
HLRTopoBRep_Data& DS)