1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

79
src/DrawDim/DrawDim.cdl Executable file
View File

@@ -0,0 +1,79 @@
-- File: DrawDim.cdl
-- Created: Tue Jan 9 16:39:53 1996
-- Author: Denis PASCAL
-- <dp@zerox>
---Copyright: Matra Datavision 1996
package DrawDim
---Purpose: This package provides Drawable Dimensions.
--
-- The classes PlanarDimension and subclasses provide
-- services to build drawable dimensions between
-- point line and circle in a given 3d plane.
--
-- The classes Dimension and subclasses provide
-- services to build drawable dimensions between
-- plane and cylindrical surfaces.
uses Draw, gp, TColgp, TopoDS, TCollection
is
deferred class Dimension;
---Purpose: Dimension between planes and cylinder
-- =====================================
class Angle;
class Distance;
class Radius;
---Purpose: Dimensions between point, line and circle ON a plane
-- ====================================================
deferred class PlanarDimension;
class PlanarAngle;
class PlanarDistance;
class PlanarRadius;
class PlanarDiameter;
---Purpose: Commands
-- ========
DrawShapeName (ashape : Shape from TopoDS; aname : CString);
AllCommands (I : in out Interpretor from Draw);
PlanarDimensionCommands (I : in out Interpretor from Draw);
---Purpose: tools
-- =====
Nearest (aShape : Shape from TopoDS; apoint : Pnt from gp)
returns Pnt from gp;
Lin (e : Edge from TopoDS; l : in out Lin from gp;
infinite : in out Boolean from Standard;
first, last : in out Real from Standard)
---Purpose: false if <e> is not a linear edge
returns Boolean from Standard;
Circ (e : Edge from TopoDS; l : in out Circ from gp; first, last : in out Real from Standard)
---Purpose: false if <e> is not a circular edge
returns Boolean from Standard;
Pln (f : Face from TopoDS; p : in out Pln from gp)
---Purpose: false if <f> is not a planar face
returns Boolean from Standard;
end DrawDim;

182
src/DrawDim/DrawDim.cxx Executable file
View File

@@ -0,0 +1,182 @@
// File: DrawDim.cxx
// Created: Wed Jan 10 14:26:40 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <DrawDim.ixx>
#include <Draw_Text3D.hxx>
#include <gp_Pnt.hxx>
#include <TCollection_AsciiString.hxx>
#include <Geom_Curve.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Plane.hxx>
#include <ElCLib.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <TopoDS_Vertex.hxx>
#ifdef WNT
Standard_IMPORT Draw_Viewer dout;
#endif
//=======================================================================
//function : AllCommands
//purpose :
//=======================================================================
void DrawDim::AllCommands (Draw_Interpretor& theCommands)
{
PlanarDimensionCommands (theCommands);
}
//=======================================================================
//function : DrawShapeName
//purpose :
//=======================================================================
void DrawDim::DrawShapeName (const TopoDS_Shape& ashape,
const Standard_CString aname)
{
gp_Pnt position;
TCollection_AsciiString t (" ");
switch (ashape.ShapeType()) {
case TopAbs_EDGE :
{
Standard_Real f,l,parameter;
Handle(Geom_Curve) curve = BRep_Tool::Curve(TopoDS::Edge(ashape),f,l);
if (curve->IsKind(STANDARD_TYPE(Geom_Line))) {
parameter = (f+l)/2.;
position = ElCLib::Value(parameter,Handle(Geom_Line)::DownCast(curve)->Lin());
}
else if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
parameter = (f+l)/2.;
if (f > l) parameter = parameter + PI;
position = ElCLib::Value(parameter,Handle(Geom_Circle)::DownCast(curve)->Circ());
}
}
break;
case TopAbs_VERTEX :
{
position = BRep_Tool::Pnt(TopoDS::Vertex(ashape));
}
break;
#ifndef DEB
default:
break;
#endif
}
t+=aname; //Name();
Handle(Draw_Text3D) text = new Draw_Text3D (position,t.ToCString(),Draw_blanc);
dout << text;
}
//=======================================================================
//function : Pln
//purpose :
//=======================================================================
Standard_Boolean DrawDim::Pln (const TopoDS_Face& f, gp_Pln& p)
{
Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(f));
if (!P.IsNull()) {
p = P->Pln();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Lin
//purpose :
//=======================================================================
Standard_Boolean DrawDim::Lin (const TopoDS_Edge& e,
gp_Lin& l,
Standard_Boolean& infinite,
Standard_Real& first,
Standard_Real& last)
{
Standard_Real f1,l1;
Handle(Geom_Line) L = Handle(Geom_Line)::DownCast(BRep_Tool::Curve(e,f1,l1));
if (!L.IsNull()) {
TopoDS_Vertex vf, vl;
TopExp::Vertices(TopoDS::Edge(e),vf,vl);
if (vf.IsNull() && vl.IsNull()) {
infinite = Standard_True;
l = L->Lin();
return Standard_True;
}
else if (vf.IsNull() || vl.IsNull()) {
Standard_DomainError::Raise("DrawDim::Lin : semi infinite edge");
}
else {
l = L->Lin();
infinite = Standard_True;
first = f1;
last = l1;
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : Lin
//purpose :
//=======================================================================
Standard_Boolean DrawDim::Circ (const TopoDS_Edge& e,
gp_Circ& c,
Standard_Real& first,
Standard_Real& last)
{
Standard_Real f1,l1;
Handle(Geom_Circle) C = Handle(Geom_Circle)::DownCast(BRep_Tool::Curve(e,f1,l1));
if (!C.IsNull()) {
c = C->Circ();
first = f1;
last = l1;
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Nearest
//purpose :
//=======================================================================
gp_Pnt DrawDim::Nearest(const TopoDS_Shape& ashape, const gp_Pnt& apoint)
{
Standard_Real dist = RealLast();
Standard_Real curdist;
gp_Pnt result;
gp_Pnt curpnt;
TopExp_Explorer explo(ashape,TopAbs_VERTEX);
while (explo.More()) {
curpnt = BRep_Tool::Pnt(TopoDS::Vertex(explo.Current()));
curdist = apoint.Distance(curpnt);
if (curdist < dist) {
result = curpnt;
dist = curdist;
}
explo.Next();
}
return result;
}

39
src/DrawDim/DrawDim_Angle.cdl Executable file
View File

@@ -0,0 +1,39 @@
-- File: DrawDim_Angle.cdl
-- Created: Tue May 28 12:27:28 1996
-- Author: Denis PASCAL
-- <dp@zerox>
---Copyright: Matra Datavision 1996
class Angle from DrawDim inherits Dimension from DrawDim
---Purpose:
uses Face from TopoDS,
Display from Draw
is
Create (plane1 : Face from TopoDS;
plane2 : Face from TopoDS)
returns mutable Angle from DrawDim;
Plane1 (me) returns Face from TopoDS;
---C++: return const&
Plane1 (me : mutable; plane : Face from TopoDS);
Plane2 (me) returns Face from TopoDS;
---C++: return const&
Plane2 (me : mutable; plane : Face from TopoDS);
DrawOn (me; dis : in out Display);
fields
myPlane1 : Face from TopoDS;
myPlane2 : Face from TopoDS;
end Angle;

215
src/DrawDim/DrawDim_Angle.cxx Executable file
View File

@@ -0,0 +1,215 @@
// File: DrawDim_Angle.cxx
// Created: Tue May 28 12:36:20 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <DrawDim_Angle.ixx>
#include <DrawDim.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Tool.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
#include <gp_Lin.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <TopoDS.hxx>
#include <IntAna_QuadQuadGeo.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Vertex.hxx>
#include <IntAna_QuadQuadGeo.hxx>
//=======================================================================
//function : DrawDim_Angle
//purpose :
//=======================================================================
DrawDim_Angle::DrawDim_Angle(const TopoDS_Face& plane1, const TopoDS_Face& plane2)
{
myPlane1 = plane1;
myPlane2 = plane2;
}
//=======================================================================
//function : Plane1
//purpose :
//=======================================================================
const TopoDS_Face& DrawDim_Angle::Plane1() const
{
return myPlane1;
}
//=======================================================================
//function : Plane1
//purpose :
//=======================================================================
void DrawDim_Angle::Plane1(const TopoDS_Face& plane)
{
myPlane1 = plane;
}
//=======================================================================
//function : Plane2
//purpose :
//=======================================================================
const TopoDS_Face& DrawDim_Angle::Plane2() const
{
return myPlane2;
}
//=======================================================================
//function : Plane2
//purpose :
//=======================================================================
void DrawDim_Angle::Plane2(const TopoDS_Face& plane)
{
myPlane2 = plane;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DrawDim_Angle::DrawOn(Draw_Display& ) const
{
// input
TopoDS_Shape myFShape = myPlane1;
TopoDS_Shape mySShape = myPlane2;
Standard_Real myVal = GetValue();
gp_Ax1 myAxis;
// output
#ifdef DEB
gp_Dir myDirAttach;
#endif
gp_Pnt myFAttach;
gp_Pnt mySAttach;
gp_Pnt myPosition(0.,0.,0.);
gp_Pnt myCenter;
gp_Dir myFDir;
gp_Dir mySDir;
Standard_Boolean myAutomaticPosition = Standard_True;
// calcul de myAxis
gp_Pln pln1, pln2;
if (!DrawDim::Pln(myPlane1,pln1)) return;
if (!DrawDim::Pln(myPlane2,pln2)) return;
IntAna_QuadQuadGeo ip (pln1,pln2,Precision::Confusion(), Precision::Angular());
if (!ip.IsDone()) return;
#ifdef DEB
gp_Lin linter =
#endif
ip.Line(1);
//Handle(Geom_Surface) curve1 = BRep_Tool::Surface(myPlane1);
//Handle(Geom_PlaneLine) line1 = Handle(Geom_Line)::DownCast(curve1);
//=======================================================================
//function : ComputeTwoFacesAngle
//purpose :
//=======================================================================
// void AIS_AngleDimension::ComputeTwoFacesAngle(const Handle(Prs3d_Presentation)& aPresentation)
// {
// Recuperation des plans
gp_Pnt curpos;
gp_Ax1 AxePos = myAxis;
gp_Dir theAxisDir = AxePos.Direction();
gp_Lin theaxis= gp_Lin (myAxis);
if (myAutomaticPosition) {
TopExp_Explorer explo1(myFShape,TopAbs_VERTEX);
Standard_Real curdist = 0;
while (explo1.More()) {
TopoDS_Vertex vertref = TopoDS::Vertex(explo1.Current());
gp_Pnt curpt = BRep_Tool::Pnt(vertref);
if (theaxis.Distance(curpt) > curdist) {
curdist = theaxis.Distance(curpt);
myFAttach = BRep_Tool::Pnt(vertref);
}
explo1.Next();
}
curpos = myFAttach.Rotated(AxePos,myVal/2.);
myCenter = ElCLib::Value(ElCLib::Parameter(theaxis,curpos),theaxis);
Standard_Real thedista = myCenter.Distance(myFAttach);
if (thedista > Precision::Confusion()) {
curpos.Scale(myCenter,1.05);
}
myPosition = curpos;
myAutomaticPosition = Standard_True;
}
else {
curpos = myPosition;
//myFAttach = le point de myFShape le plus proche de curpos (sauf si c'est un point sur l'axe)
Standard_Real dist = RealLast();
TopExp_Explorer explo1(myFShape,TopAbs_VERTEX);
gp_Pnt AxePosition = AxePos.Location();
gp_Vec AxeVector (theAxisDir);
gp_XYZ AxeXYZ = AxeVector.XYZ();
while (explo1.More()) {
gp_Pnt curpt = BRep_Tool::Pnt(TopoDS::Vertex(explo1.Current()));
gp_Vec curvec (AxePosition, curpt);
gp_XYZ curXYZ = curvec.XYZ();
gp_XYZ Norm (curXYZ.Crossed(AxeXYZ));
#ifdef DEB
Standard_Real NormMod =
#endif
Norm.Modulus();
if (Norm.Modulus() > gp::Resolution()) {
Standard_Real curdist = curpos.Distance (curpt);
if (curdist < dist) {
myFAttach = curpt;
dist = curdist;
}
}
explo1.Next();
}
myCenter = ElCLib::Value(ElCLib::Parameter(theaxis,myFAttach),theaxis);
}
mySAttach = myFAttach.Rotated(AxePos,myVal);
gp_Vec FVec (myCenter, myFAttach);
myFDir.SetXYZ (FVec.XYZ());
gp_Vec SVec (myCenter, mySAttach);
mySDir.SetXYZ (SVec.XYZ());
if (!myAutomaticPosition) {
//Projection de la position sur le plan defini par myFDir mySDir et de normale theAxisDir
gp_Pln aPln (myCenter, theAxisDir);
Standard_Real U,V;
ElSLib::Parameters (aPln, curpos, U, V);
curpos = ElSLib::Value (U, V, aPln);
}
// DISPLAY
// Add (myVal, myText,myCenter,myFAttach,mySAttach,myFDir,mySDir,theAxisDir,curpos)
}

View File

@@ -0,0 +1,42 @@
-- File: DrawDim_Dimension.cdl
-- Created: Mon Apr 21 13:29:26 1997
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
deferred class Dimension from DrawDim inherits Drawable3D from Draw
---Purpose:
uses
Real from Standard,
Pnt from gp,
Color from Draw,
Display from Draw
is
Initialize;
SetValue (me : mutable; avalue : Real from Standard);
GetValue (me)
returns Real from Standard;
IsValued (me)
returns Boolean from Standard;
TextColor(me : mutable; C : Color from Draw);
TextColor(me) returns Color from Draw;
DrawText(me; Pos : Pnt from gp; D : in out Display from Draw);
fields
is_valued : Boolean from Standard is protected;
myValue : Real from Standard is protected;
myTextColor : Color from Draw is protected;
end Dimension;

View File

@@ -0,0 +1,95 @@
// File: DrawDim_Dimension.cxx
// Created: Mon Apr 21 15:30:02 1997
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <DrawDim_Dimension.ixx>
#include <Standard_DomainError.hxx>
#include <Draw_Interpretor.hxx>
#include <TCollection_AsciiString.hxx>
//=======================================================================
//function : DrawDim_Dimension
//purpose :
//=======================================================================
DrawDim_Dimension::DrawDim_Dimension()
: is_valued(Standard_False),
myTextColor(Draw_blanc)
{
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void DrawDim_Dimension::SetValue (const Standard_Real avalue)
{
is_valued = Standard_True;
myValue = avalue;
}
//=======================================================================
//function : GetValue
//purpose :
//=======================================================================
Standard_Real DrawDim_Dimension::GetValue() const
{
if (!is_valued) Standard_DomainError::Raise();
return myValue;
}
//=======================================================================
//function : IsValued
//purpose :
//=======================================================================
Standard_Boolean DrawDim_Dimension::IsValued() const
{
return is_valued;
}
//=======================================================================
//function : TextColor
//purpose :
//=======================================================================
Draw_Color DrawDim_Dimension::TextColor() const
{
return myTextColor;
}
//=======================================================================
//function : TextColor
//purpose :
//=======================================================================
void DrawDim_Dimension::TextColor(const Draw_Color& C)
{
myTextColor = C;
}
//=======================================================================
//function : DrawText
//purpose :
//=======================================================================
void DrawDim_Dimension::DrawText(const gp_Pnt& P, Draw_Display& D) const
{
TCollection_AsciiString t = Name();
if (is_valued) {
t+="=";
Standard_Integer l = t.Length();
t+= myValue;
for (Standard_Integer i = l; i <= t.Length(); i++) {
if (t.Value(i) == '.') { t.Trunc(i+2); break; }
}
}
D.SetColor(myTextColor);
D.DrawString(P,t.ToCString());
}

View File

@@ -0,0 +1,39 @@
-- File: DrawDim_Distance.cdl
-- Created: Mon Apr 21 13:30:11 1997
-- Author: Denis PASCAL
---Copyright: Matra Datavision 1997
class Distance from DrawDim inherits Dimension from DrawDim
---Purpose:
uses Face from TopoDS,
Display from Draw
is
Create (plane1 : Face from TopoDS; plane2 : Face from TopoDS)
returns mutable Distance from DrawDim;
Create (plane1 : Face from TopoDS)
returns mutable Distance from DrawDim;
Plane1 (me) returns Face from TopoDS;
---C++: return const&
Plane1 (me : mutable; face : Face from TopoDS);
Plane2 (me) returns Face from TopoDS;
---C++: return const&
Plane2 (me : mutable; face : Face from TopoDS);
DrawOn (me; dis : in out Display);
fields
myPlane1 : Face from TopoDS;
myPlane2 : Face from TopoDS;
end Distance;

137
src/DrawDim/DrawDim_Distance.cxx Executable file
View File

@@ -0,0 +1,137 @@
// File: DrawDim_Distance.cxx
// Created: Mon Apr 21 14:38:30 1997
// Author: Denis PASCAL
#include <DrawDim_Distance.ixx>
#include <DrawDim.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <gp_Pln.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <TCollection_AsciiString.hxx>
//=======================================================================
//function : DrawDim_Distance
//purpose :
//=======================================================================
DrawDim_Distance::DrawDim_Distance (const TopoDS_Face& plane1,
const TopoDS_Face& plane2)
{
myPlane1 = plane1;
myPlane2 = plane2;
}
//=======================================================================
//function : DrawDim_Distance
//purpose :
//=======================================================================
DrawDim_Distance::DrawDim_Distance (const TopoDS_Face& plane1)
{
myPlane1 = plane1;
}
//=======================================================================
//function : Plane1
//purpose :
//=======================================================================
const TopoDS_Face& DrawDim_Distance::Plane1() const
{
return myPlane1;
}
//=======================================================================
//function : Plane1
//purpose :
//=======================================================================
void DrawDim_Distance::Plane1(const TopoDS_Face& face)
{
myPlane1 = face;
}
//=======================================================================
//function : Plane2
//purpose :
//=======================================================================
const TopoDS_Face& DrawDim_Distance::Plane2() const
{
return myPlane2;
}
//=======================================================================
//function : Plane2
//purpose :
//=======================================================================
void DrawDim_Distance::Plane2(const TopoDS_Face& face)
{
myPlane2 = face;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DrawDim_Distance::DrawOn(Draw_Display& dis) const
{
// compute the points and the direction
BRepAdaptor_Surface surf1(myPlane1);
// today we process only planar faces
if (surf1.GetType() != GeomAbs_Plane)
return;
const gp_Ax1& anAx1 = surf1.Plane().Axis();
gp_Vec V = anAx1.Direction();
// output
gp_Pnt FAttach; // first attach point
gp_Pnt SAttach; // second attach point
// first point, try a vertex
TopExp_Explorer explo(myPlane1,TopAbs_VERTEX);
if (explo.More()) {
FAttach = BRep_Tool::Pnt(TopoDS::Vertex(explo.Current()));
}
else {
// no vertex, use the origin
FAttach = anAx1.Location();
}
if (!myPlane2.IsNull()) {
// translate the point until the second face
BRepAdaptor_Surface surf2(myPlane2);
surf2.D0(0,0,SAttach);
Standard_Real r = V.Dot(gp_Vec(FAttach,SAttach));
V *= r;
}
SAttach = FAttach;
SAttach.Translate(V);
// DISPLAY
dis.Draw (FAttach,SAttach);
V *= 0.5;
FAttach.Translate(V);
dis.DrawMarker(FAttach, Draw_Losange);
DrawText(FAttach,dis);
}

View File

@@ -0,0 +1,43 @@
-- File: DrawDim_PlanarAngle.cdl
-- Created: Fri Jan 12 17:47:31 1996
-- Author: Denis PASCAL
-- <dp@zerox>
---Copyright: Matra Datavision 1996
class PlanarAngle from DrawDim inherits PlanarDimension from DrawDim
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Color from Draw,
Display from Draw
is
Create (plane : Face from TopoDS;
line1 : Shape from TopoDS;
line2 : Shape from TopoDS)
returns mutable PlanarAngle from DrawDim;
Create (line1 : Shape from TopoDS;
line2 : Shape from TopoDS)
returns mutable PlanarAngle from DrawDim;
Sector (me : mutable; inverted, reversed : Boolean from Standard);
Position (me : mutable; value : Real from Standard);
DrawOn (me; dis : in out Display);
fields
myLine1 : Shape from TopoDS;
myLine2 : Shape from TopoDS;
myIsReversed : Boolean from Standard;
myIsInverted : Boolean from Standard;
myPosition : Real from Standard; -- par rapport au point d'intersection
end PlanarAngle;

View File

@@ -0,0 +1,167 @@
// File: DrawDim_PlanarAngle.cxx
// Created: Fri Jan 12 17:49:33 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <DrawDim_PlanarAngle.ixx>
#include <TCollection_AsciiString.hxx>
#include <DrawDim.hxx>
#include <Draw.hxx>
#include <Draw_MarkerShape.hxx>
#include <gp_Pnt.hxx>
#include <gp.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt2d.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Circle.hxx>
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <GeomAPI.hxx>
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <ElSLib.hxx>
#include <ElCLib.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir2d.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopoDS_Edge.hxx>
#include <DBRep_DrawableShape.hxx>
#include <TopoDS.hxx>
#ifdef DEB
static Standard_Integer DISCRET = 100;
static Standard_Integer NBISOS = 2;
static Standard_Real SIZE = 100.;
static Standard_Real DEFLECTION = 0.0;
static Standard_Real RAP = 0.4;
#endif
//=======================================================================
//function : DrawDim_PlanarAngle
//purpose :
//=======================================================================
DrawDim_PlanarAngle::DrawDim_PlanarAngle (const TopoDS_Face& face,
const TopoDS_Shape& line1,
const TopoDS_Shape& line2)
{
myPlane = face;
myLine1 = line1;
myLine2 = line2;
myPosition = 100;
}
//=======================================================================
//function : DrawDim_PlanarAngle
//purpose :
//=======================================================================
DrawDim_PlanarAngle::DrawDim_PlanarAngle (const TopoDS_Shape& line1,
const TopoDS_Shape& line2)
{
myLine1 = line1;
myLine2 = line2;
myPosition = 100;
}
//=======================================================================
//function : Sector
//purpose :
//=======================================================================
void DrawDim_PlanarAngle::Sector (const Standard_Boolean reversed, const Standard_Boolean inverted)
{
myIsReversed = reversed;
myIsInverted = inverted;
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
void DrawDim_PlanarAngle::Position (const Standard_Real value)
{
myPosition = value;
}
//=======================================================================
//function : DrawOn
//purpose : line1^line2 suppose positifs
//=======================================================================
void DrawDim_PlanarAngle::DrawOn(Draw_Display& dis) const
{
Standard_Boolean clockwise = myIsReversed;
Standard_Boolean parallel = !myIsInverted;
// geometrie
gp_Pln plane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(myPlane))->Pln();
//if (plane.IsNull()) return;
if (!(myLine1.ShapeType() == TopAbs_EDGE)) return;
if (!(myLine2.ShapeType() == TopAbs_EDGE)) return;
Standard_Real s1,e1,s2,e2;
Handle(Geom_Curve) curve1 = BRep_Tool::Curve(TopoDS::Edge(myLine1),s1,e1);
Handle(Geom_Curve) curve2 = BRep_Tool::Curve(TopoDS::Edge(myLine2),s2,e2);
if (!curve1->IsKind(STANDARD_TYPE(Geom_Line)) || !curve2->IsKind(STANDARD_TYPE(Geom_Line))) return;
Handle(Geom2d_Geometry) L1 = GeomAPI::To2d (curve1,plane);
if (L1->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
L1 = ((Handle(Geom2d_TrimmedCurve)&) L1)->BasisCurve();
}
gp_Lin2d l1 = ((Handle(Geom2d_Line)&) L1)->Lin2d();
Handle(Geom2d_Geometry) L2 = GeomAPI::To2d (curve2,plane);
if (L2->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
L2 = ((Handle(Geom2d_TrimmedCurve)&) L2)->BasisCurve();
}
gp_Lin2d l2 = ((Handle(Geom2d_Line)&) L2)->Lin2d();
//
IntAna2d_AnaIntersection inter;
inter.Perform(l1,l2);
if (!inter.IsDone() || !inter.NbPoints()) return;
gp_Pnt2d pinter = inter.Point(1).Value();
//
Standard_Real angle;
angle = Abs(l1.Direction().Angle(l2.Direction()));
gp_Circ2d c (gp_Ax2d (pinter,l1.Direction()),myPosition);
// retour au plan
Handle(Geom_Curve) C = GeomAPI::To3d (new Geom2d_Circle(c),plane);
gp_Circ circle = ((Handle(Geom_Circle)&) C)->Circ();
//
Standard_Real p1=0., p2=0.;
angle = Abs(angle);
if (parallel && !clockwise) {
p1 = 0.0;
p2 = angle;
dis.Draw(circle,0.0,angle);
}
if (!parallel && !clockwise) {
p1 = angle;
p2 = PI;
}
if (parallel && clockwise) {
p1 = PI;
p2 = PI+angle;
}
if (!parallel && clockwise) {
p1 = PI+angle;
p2 = 2*PI;
}
// affichage
dis.Draw(circle,p1,p2);
Standard_Real ptext = (p1+p2)/2;
gp_Pnt pnttext = ElCLib::Value(ptext,circle);
//
DrawText(pnttext,dis);
}

View File

@@ -0,0 +1,33 @@
-- File: DrawDim_PlanarDiameter.cdl
-- Created: Wed Nov 25 11:36:39 1998
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class PlanarDiameter from DrawDim inherits PlanarDimension from DrawDim
---Purpose:
uses Vertex from TopoDS,
Face from TopoDS,
Shape from TopoDS,
Color from Draw,
Display from Draw
is
Create (plane : Face from TopoDS;
circle : Shape from TopoDS)
returns mutable PlanarDiameter from DrawDim;
Create (circle : Shape from TopoDS)
returns mutable PlanarDiameter from DrawDim;
DrawOn(me; dis : in out Display);
fields
myCircle : Shape from TopoDS;
end PlanarDiameter;

View File

@@ -0,0 +1,70 @@
// File: DrawDim_PlanarDiameter.cxx
// Created: Wed Nov 25 11:37:21 1998
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <DrawDim_PlanarDiameter.ixx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <BRep_Tool.hxx>
#include <TCollection_AsciiString.hxx>
#include <Draw_Color.hxx>
#include <ElCLib.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
//=======================================================================
//function : DrawDim_PlanarDiameter
//purpose :
//=======================================================================
DrawDim_PlanarDiameter::DrawDim_PlanarDiameter(const TopoDS_Face& face, const TopoDS_Shape& c)
{
myPlane = face;
myCircle = c;
}
//=======================================================================
//function : DrawDim_PlanarDiameter
//purpose :
//=======================================================================
DrawDim_PlanarDiameter::DrawDim_PlanarDiameter(const TopoDS_Shape& c)
{
myCircle = c;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DrawDim_PlanarDiameter::DrawOn(Draw_Display& dis) const
{
if (myCircle.ShapeType() == TopAbs_EDGE) {
Standard_Real f,l;
Handle(Geom_Curve) curve = BRep_Tool::Curve (TopoDS::Edge(myCircle),f,l);
if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
gp_Circ circle = Handle(Geom_Circle)::DownCast(curve)->Circ();
TopoDS_Vertex vf, vl;
TopExp::Vertices(TopoDS::Edge(myCircle),vf,vl);
const gp_Pnt first = BRep_Tool::Pnt(vf);
Standard_Real parfirst = ElCLib::Parameter(circle,first);
Standard_Real parlast = (parfirst + PI);
gp_Pnt last = ElCLib::Value(parlast,circle);
//
dis.Draw (first,last);
gp_Pnt p ((first.X()+ last.X())/2,(first.Y()+ last.Y())/2,(first.Z()+ last.Z())/2);
DrawText(p,dis);
return;
}
}
cout << " DrawDim_PlanarDiameter::DrawOn : dimension error" << endl;
}

View File

@@ -0,0 +1,46 @@
-- File: DrawDim_PlanarDimension.cdl
-- Created: Tue Jan 9 16:44:39 1996
-- Author: Denis PASCAL
-- <dp@zerox>
---Copyright: Matra Datavision 1996
deferred class PlanarDimension from DrawDim inherits Dimension from DrawDim
---Purpose:
uses Face from TopoDS
is
SetPlane (me : mutable; plane : Face from TopoDS);
GetPlane (me)
returns Face from TopoDS;
-- Point (myclass; s : Shape from TopoDS; p : in out Pnt from gp)
-- returns Boolean from Standard;
-- Line (myclass; s : Shape from TopoDS; l : in out Lin from gp)
-- returns Boolean from Standard;
-- Circle (myclass; s : Shape from TopoDS; c : in out Circ from gp)
-- returns Boolean from Standard;
-- Ellipse (myclass; s : Shape from TopoDS; c : in out Elips from gp)
-- returns Boolean from Standard;
fields
myPlane : Face from TopoDS is protected;
end PlanarDimension;

View File

@@ -0,0 +1,33 @@
// File: DrawPlanarDim_PlanarDimension.cxx
// Created: Wed Jan 10 16:16:34 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <DrawDim_PlanarDimension.ixx>
#include <Standard_DomainError.hxx>
#include <Draw_Interpretor.hxx>
//=======================================================================
//function : SetPlane
//purpose :
//=======================================================================
void DrawDim_PlanarDimension::SetPlane(const TopoDS_Face& plane)
{
myPlane = plane;
}
//=======================================================================
//function : GetPlane
//purpose :
//=======================================================================
TopoDS_Face DrawDim_PlanarDimension::GetPlane() const
{
return myPlane;
}

View File

@@ -0,0 +1,341 @@
// File: DrawDim_PlanarDimensionCommands.cxx
// Created: Mon Jun 3 09:37:27 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <stdio.h>
#include <DrawDim.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_Appli.hxx>
#include <BRep_Tool.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <DBRep.hxx>
#include <DrawDim_PlanarDistance.hxx>
#include <DrawDim_PlanarRadius.hxx>
#include <DrawDim_PlanarAngle.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>
#include <BRep_Builder.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
#include <gp_Ax3.hxx>
#include <gp_Pln.hxx>
#include <DrawTrSurf.hxx>
#ifdef WNT
#include <stdio.h>
#endif
//=======================================================================
//function : DrawDim_DISTANCE
//purpose :
//=======================================================================
static Standard_Integer DrawDim_DISTANCE (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 1) {
di << "distance (name, profile[face],point1[vertex],point2[vertex])\n";
di << "distance (name, profile[face],line1[edge],line2[edge])\n";
di << "distance (name, profile[face],line[edge],point[vertex])\n";
}
else {
Handle(DrawDim_PlanarDistance) DIST;
if (nb == 5) {
TopoDS_Shape aLocalShape = DBRep::Get(arg[2],TopAbs_FACE);
TopoDS_Face plan = TopoDS::Face(aLocalShape);
// TopoDS_Face plan = TopoDS::Face(DBRep::Get(arg[2],TopAbs_FACE));
TopoDS_Shape geom1 = DBRep::Get(arg[3]);
TopoDS_Shape geom2 = DBRep::Get(arg[4]);
if (!plan.IsNull() && !geom1.IsNull() && !geom2.IsNull()) {
if (geom1.ShapeType() == TopAbs_VERTEX && geom2.ShapeType() == TopAbs_VERTEX) {
DIST = new DrawDim_PlanarDistance(TopoDS::Vertex(geom1),TopoDS::Vertex(geom2));
}
else if (geom1.ShapeType() == TopAbs_VERTEX && geom2.ShapeType() == TopAbs_EDGE) {
DIST = new DrawDim_PlanarDistance(TopoDS::Vertex(geom1),TopoDS::Edge(geom2));
}
else if (geom1.ShapeType() == TopAbs_EDGE && geom2.ShapeType() == TopAbs_EDGE) {
DIST = new DrawDim_PlanarDistance(TopoDS::Edge(geom1),TopoDS::Edge(geom2));
}
if (!DIST.IsNull()) {
Draw::Set(arg[1],DIST);
return 0;
}
}
}
}
di << "DrawDim_DISTANCE : error" << "\n";
return 1;
}
//=======================================================================
//function : DrawDim_ANGLE
//purpose :
//=======================================================================
static Standard_Integer DrawDim_ANGLE (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 1) {
di << "angle (name, profile[face],line1[edge],line2[edge])\n";
}
else {
Handle(DrawDim_PlanarAngle) DIST;
if (nb == 5) {
TopoDS_Shape aLocalShape = DBRep::Get(arg[2],TopAbs_FACE);
TopoDS_Face plan = TopoDS::Face(aLocalShape);
aLocalShape = DBRep::Get(arg[3],TopAbs_EDGE);
TopoDS_Edge line1 = TopoDS::Edge(aLocalShape);
aLocalShape = DBRep::Get(arg[4],TopAbs_EDGE);
TopoDS_Edge line2 = TopoDS::Edge(aLocalShape);
// TopoDS_Face plan = TopoDS::Face(DBRep::Get(arg[2],TopAbs_FACE));
// TopoDS_Edge line1 = TopoDS::Edge(DBRep::Get(arg[3],TopAbs_EDGE));
// TopoDS_Edge line2 = TopoDS::Edge(DBRep::Get(arg[4],TopAbs_EDGE));
if (!plan.IsNull() && !line1.IsNull() && !line2.IsNull()) {
DIST = new DrawDim_PlanarAngle(plan,line1,line2);
}
if (!DIST.IsNull()) {
Draw::Set(arg[1],DIST);
return 0;
}
}
}
di << "DrawDim_PlanarAngle : error" << "\n";
return 1;
}
//=======================================================================
//function : DrawDim_RADIUS
//purpose :
//=======================================================================
static Standard_Integer DrawDim_RADIUS (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 1) {
di << "radius (name, profile[face],cercle[edge])\n";
}
else {
Handle(DrawDim_PlanarRadius) DIST;
if (nb == 4) {
TopoDS_Shape aLocalShape = DBRep::Get(arg[2],TopAbs_FACE);
TopoDS_Face plan = TopoDS::Face(aLocalShape);
aLocalShape = DBRep::Get(arg[3],TopAbs_EDGE);
TopoDS_Edge cercle = TopoDS::Edge(aLocalShape);
// TopoDS_Face plan = TopoDS::Face(DBRep::Get(arg[2],TopAbs_FACE));
// TopoDS_Edge cercle = TopoDS::Edge(DBRep::Get(arg[3],TopAbs_EDGE));
if (!plan.IsNull() && !cercle.IsNull()) {
DIST = new DrawDim_PlanarRadius(cercle);
}
}
if (!DIST.IsNull()) {
Draw::Set(arg[1],DIST);
return 0;
}
}
di << "DrawDim_PlanarRadius : error" << "\n";
return 1;
}
//=======================================================================
//function : DrawDim_CENTER
//purpose :
//=======================================================================
static Standard_Integer DrawDim_CENTER (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
TopoDS_Shape aLocalShape = DBRep::Get(arg[2],TopAbs_EDGE);
TopoDS_Edge edge = TopoDS::Edge(aLocalShape);
// TopoDS_Edge edge = TopoDS::Edge(DBRep::Get(arg[2],TopAbs_EDGE));
Standard_Real f,l;
Handle(Geom_Curve) curve = BRep_Tool::Curve (edge,f,l);
if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
gp_Circ circle = Handle(Geom_Circle)::DownCast(curve)->Circ();
gp_Pnt center = circle.Location ();
//:abv: avoid dependence on TKTopAlgo
TopoDS_Vertex vc;
// = BRepBuilderAPI_MakeVertex (center);
BRep_Builder B;
B.MakeVertex(vc,center,Precision::Confusion());
DBRep::Set(arg[1],vc);
return 0;
}
}
di << "DrawDim_CENTER : error" << "\n";
return 1;
}
//=======================================================================
//function : DrawDim_VARIABLES
//purpose :
//=======================================================================
static Standard_Integer DrawDim_VARIABLES (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n != 2) return 1;
TopoDS_Shape aLocalShape = DBRep::Get(a[1],TopAbs_FACE);
TopoDS_Face F = TopoDS::Face(aLocalShape);
// TopoDS_Face F = TopoDS::Face(DBRep::Get(a[1],TopAbs_FACE));
if (F.IsNull()) return 0;
Standard_Integer i = 0;
TopoDS_Vertex vf,vl;
TopTools_MapOfShape M;
M.Add(F);
TopExp_Explorer ex (F,TopAbs_EDGE);
while (ex.More()) {
if (M.Add(ex.Current())) {
TopExp::Vertices(TopoDS::Edge(ex.Current()),vf,vl);
if (M.Add(vf)) {
i++;
char* p = (char *)malloc(100);
sprintf(p,"%s_%dv",a[1],i);
DBRep::Set(p,vf);
di.AppendElement(p);
DrawDim::DrawShapeName (vf,p);
}
if (M.Add(vl)) {
i++;
char *p = (char *)malloc(100);
sprintf(p,"%s_%dv",a[1],i);
DBRep::Set(p,vl);
di.AppendElement(p);
DrawDim::DrawShapeName (vl,p);
}
i++;
char *p = (char *)malloc(100);
sprintf(p,"%s_%de",a[1],i);
DBRep::Set(p,ex.Current());
di.AppendElement(p);
DrawDim::DrawShapeName (ex.Current(),p);
}
ex.Next();
}
return 0;
}
//=======================================================================
//function : DrawDim_SPLACEMENT
//purpose :
//=======================================================================
static Standard_Integer DrawDim_SPLACEMENT (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n == 4) {
TopoDS_Shape shape = DBRep::Get(a[1]);
TopoDS_Shape aLocalShape = DBRep::Get(a[2],TopAbs_FACE);
TopoDS_Face from = TopoDS::Face(aLocalShape);
aLocalShape = DBRep::Get(a[3],TopAbs_FACE);
TopoDS_Face to = TopoDS::Face(aLocalShape);
// TopoDS_Face from = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
// TopoDS_Face to = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
if (!shape.IsNull() && !from.IsNull() && !to.IsNull()) {
gp_Pln pfrom,pto;
DrawDim::Pln(from,pfrom);
DrawDim::Pln(to,pto);
gp_Ax3 axfrom (pfrom.Position());
gp_Ax3 axto (pto.Position());
gp_Trsf trsf;
trsf.SetDisplacement(axfrom,axto);
TopLoc_Location move (trsf);
shape.Move(move);
DBRep::Set(a[1],shape);
return 0;
}
}
di << "DrawDim_SPlacement : error" << "\n";
return 1;
}
//=======================================================================
//function : DrawDim_GPLACEMENT
//purpose :
//=======================================================================
static Standard_Integer DrawDim_GPLACEMENT (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n == 4) {
Handle(Geom_Geometry) geom = DrawTrSurf::Get(a[1]);
TopoDS_Shape aLocalShape = DBRep::Get(a[2],TopAbs_FACE);
TopoDS_Face from = TopoDS::Face(aLocalShape);
aLocalShape = DBRep::Get(a[3],TopAbs_FACE);
TopoDS_Face to = TopoDS::Face(aLocalShape);
// TopoDS_Face from = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
// TopoDS_Face to = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
if (!geom.IsNull() && !from.IsNull() && !to.IsNull()) {
gp_Pln pfrom,pto;
DrawDim::Pln(from,pfrom);
DrawDim::Pln(to,pto);
gp_Ax3 axfrom (pfrom.Position());
gp_Ax3 axto (pto.Position());
gp_Trsf trsf;
trsf.SetDisplacement(axfrom,axto);
Handle(Geom_Geometry) newgeom = geom->Transformed(trsf);
DrawTrSurf::Set(a[1],newgeom);
return 0;
}
}
di << "DrawDim_Placement : error" << "\n";
return 1;
}
//=======================================================================
//function : PlanarDimensionCommands
//purpose :
//=======================================================================
void DrawDim::PlanarDimensionCommands (Draw_Interpretor& theCommands)
{
// syntaxes
theCommands.Add ("distance",
"distance,no args to get help",
__FILE__, DrawDim_DISTANCE);
theCommands.Add ("radius",
"radius, no args to get help",
__FILE__, DrawDim_RADIUS);
theCommands.Add ("angle",
"angle, no args to get help",
__FILE__, DrawDim_ANGLE);
theCommands.Add ("center",
"to extract center of a circle : center ,name, circle",
__FILE__, DrawDim_CENTER);
theCommands.Add ("variables",
"to extract variables of a face",
__FILE__, DrawDim_VARIABLES);
theCommands.Add ("splacement",
"to move shape from face to face",
__FILE__, DrawDim_SPLACEMENT);
theCommands.Add ("gplacement",
"to move geometry from face to face",
__FILE__, DrawDim_GPLACEMENT);
}

View File

@@ -0,0 +1,45 @@
-- File: DrawDim_PlanarDistance.cdl
-- Created: Wed Jan 10 10:16:25 1996
-- Author: Denis PASCAL
-- <dp@zerox>
---Copyright: Matra Datavision 1996
class PlanarDistance from DrawDim inherits PlanarDimension from DrawDim
---Purpose: PlanarDistance point/point
-- PlanarDistance point/line
-- PlanarDistance line/line
uses Face from TopoDS,
Pnt from gp,
Shape from TopoDS,
Edge from TopoDS,
Color from Draw,
Display from Draw
is
Create (plane : Face from TopoDS;
point1 : Shape from TopoDS;
point2 : Shape from TopoDS)
returns mutable PlanarDistance from DrawDim;
Create (geom1 : Shape from TopoDS;
geom2 : Shape from TopoDS)
returns mutable PlanarDistance from DrawDim;
DrawOn(me; dis : in out Display);
---Purpose: private
Draw (me; p : Pnt from gp;
e : Edge from TopoDS;
d : in out Display) is private;
fields
myGeom1 : Shape from TopoDS;
myGeom2 : Shape from TopoDS;
end PlanarDistance;

View File

@@ -0,0 +1,106 @@
// File: DrawDim_PlanarDistance.cxx
// Created: Wed Jan 10 14:25:34 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <DrawDim_PlanarDistance.ixx>
#include <DrawDim.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <gp_Lin.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <TopExp.hxx>
//=======================================================================
//function : Draw
//purpose :
//=======================================================================
void DrawDim_PlanarDistance::Draw
(const gp_Pnt& point, const TopoDS_Edge& edge, Draw_Display& dis) const
{
Standard_Real f,l;
Handle(Geom_Curve) line = BRep_Tool::Curve(edge,f,l);
GeomAPI_ProjectPointOnCurve pj (point,Handle(Geom_Curve)::DownCast(line));
if (pj.NbPoints() == 1) {
gp_Pnt first = point;
gp_Pnt last = pj.Point(1);
dis.Draw (first,last);
gp_Pnt p ((first.X()+ last.X())/2,(first.Y()+ last.Y())/2,(first.Z()+ last.Z())/2);
DrawText(p,dis);
}
}
//=======================================================================
//function : DrawDim_PlanarDistance
//purpose :
//=======================================================================
DrawDim_PlanarDistance::DrawDim_PlanarDistance (const TopoDS_Face& face,
const TopoDS_Shape& geom1,
const TopoDS_Shape& geom2)
{
myPlane = face; myGeom1 = geom1; myGeom2 = geom2;
}
//=======================================================================
//function : DrawDim_PlanarDistance
//purpose :
//=======================================================================
DrawDim_PlanarDistance::DrawDim_PlanarDistance (const TopoDS_Shape& geom1,
const TopoDS_Shape& geom2)
{
myGeom1 = geom1; myGeom2 = geom2;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DrawDim_PlanarDistance::DrawOn(Draw_Display& dis) const
{
if (myGeom1.ShapeType() == TopAbs_VERTEX && myGeom2.ShapeType() == TopAbs_VERTEX) {
gp_Pnt first = BRep_Tool::Pnt(TopoDS::Vertex(myGeom1));
gp_Pnt last = BRep_Tool::Pnt(TopoDS::Vertex(myGeom2));
dis.Draw (first,last);
gp_Pnt p ((first.X()+ last.X())/2,(first.Y()+ last.Y())/2,(first.Z()+ last.Z())/2);
DrawText(p,dis);
return;
}
else if (myGeom1.ShapeType() == TopAbs_VERTEX && myGeom2.ShapeType() == TopAbs_EDGE) {
gp_Pnt point = BRep_Tool::Pnt(TopoDS::Vertex(myGeom1));
Draw (point,TopoDS::Edge(myGeom2),dis);
return;
}
else if (myGeom1.ShapeType() == TopAbs_EDGE && myGeom2.ShapeType() == TopAbs_VERTEX) {
gp_Pnt point = BRep_Tool::Pnt(TopoDS::Vertex(myGeom2));
Draw (point,TopoDS::Edge(myGeom1),dis);
return;
}
else if (myGeom1.ShapeType() == TopAbs_EDGE && myGeom2.ShapeType() == TopAbs_EDGE) {
Standard_Real f,l;
Handle(Geom_Curve) C = BRep_Tool::Curve (TopoDS::Edge(myGeom1),f,l);
if (!C.IsNull()) {
Handle(Geom_Line) L = Handle(Geom_Line)::DownCast(C);
if (!L.IsNull()) {
gp_Pnt point = L->Lin().Location();
TopoDS_Edge edge = TopoDS::Edge(myGeom2);
Draw (point,edge,dis);
return;
}
}
}
cout << " DrawDim_PlanarDistance::DrawOn : dimension error" << endl;
}

View File

@@ -0,0 +1,33 @@
-- File: DrawDim_PlanarRadius.cdl
-- Created: Fri Jan 12 17:52:28 1996
-- Author: Denis PASCAL
-- <dp@zerox>
---Copyright: Matra Datavision 1996
class PlanarRadius from DrawDim inherits PlanarDimension from DrawDim
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Color from Draw,
Display from Draw
is
Create (plane : Face from TopoDS;
circle : Shape from TopoDS)
returns mutable PlanarRadius from DrawDim;
Create (circle : Shape from TopoDS)
returns mutable PlanarRadius from DrawDim;
DrawOn(me; dis : in out Display);
fields
myCircle : Shape from TopoDS;
end PlanarRadius;

View File

@@ -0,0 +1,68 @@
// File: DrawDim_PlanarRadius.cxx
// Created: Fri Jan 12 17:59:57 1996
// Author: Denis PASCAL
// <dp@zerox>
#include <DrawDim_PlanarRadius.ixx>
#include <DrawDim.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <BRep_Tool.hxx>
#include <TCollection_AsciiString.hxx>
#include <Draw_Color.hxx>
#include <ElCLib.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
//=======================================================================
//function : DrawDim_PlanarRadius
//purpose :
//=======================================================================
DrawDim_PlanarRadius::DrawDim_PlanarRadius(const TopoDS_Face& face, const TopoDS_Shape& c)
{
myPlane = face;
myCircle = c;
}
//=======================================================================
//function : DrawDim_PlanarRadius
//purpose :
//=======================================================================
DrawDim_PlanarRadius::DrawDim_PlanarRadius(const TopoDS_Shape& c)
{
myCircle = c;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DrawDim_PlanarRadius::DrawOn(Draw_Display& dis) const
{
if (myCircle.ShapeType() == TopAbs_EDGE) {
Standard_Real f,l;
Handle(Geom_Curve) curve = BRep_Tool::Curve (TopoDS::Edge(myCircle),f,l);
if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
gp_Circ circle = Handle(Geom_Circle)::DownCast(curve)->Circ();
const gp_Pnt& first = circle.Location();
TopoDS_Vertex vf, vl;
TopExp::Vertices(TopoDS::Edge(myCircle),vf,vl);
const gp_Pnt last = BRep_Tool::Pnt(vf);
//
dis.Draw (first,last);
gp_Pnt p ((first.X()+ last.X())/2,(first.Y()+ last.Y())/2,(first.Z()+ last.Z())/2);
DrawText(p,dis);
return;
}
}
cout << " DrawDim_PlanarRadius::DrawOn : dimension error" << endl;
}

33
src/DrawDim/DrawDim_Radius.cdl Executable file
View File

@@ -0,0 +1,33 @@
-- File: DrawDim_Radius.cdl
-- Created: Mon Apr 21 13:36:26 1997
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Radius from DrawDim inherits Dimension from DrawDim
---Purpose:
uses Face from TopoDS,
Display from Draw
is
Create (cylinder : Face from TopoDS)
returns mutable Radius from DrawDim;
Cylinder (me) returns Face from TopoDS;
---C++: return const&
Cylinder (me : mutable; face : Face from TopoDS);
DrawOn (me; dis : in out Display);
fields
myCylinder : Face from TopoDS;
end Radius;

114
src/DrawDim/DrawDim_Radius.cxx Executable file
View File

@@ -0,0 +1,114 @@
// File: DrawDim_Radius.cxx
// Created: Mon Apr 21 14:40:47 1997
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <DrawDim_Radius.ixx>
#include <BRepAdaptor_Surface.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GC_MakeCircle.hxx>
#include <TopoDS.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>
//=======================================================================
//function : DrawDim_Radius
//purpose :
//=======================================================================
DrawDim_Radius::DrawDim_Radius(const TopoDS_Face& cylinder)
{
myCylinder = cylinder;
}
//=======================================================================
//function : Cylinder
//purpose :
//=======================================================================
const TopoDS_Face& DrawDim_Radius::Cylinder() const
{
return myCylinder;
}
//=======================================================================
//function : Cylinder
//purpose :
//=======================================================================
void DrawDim_Radius::Cylinder(const TopoDS_Face& face)
{
myCylinder = face;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DrawDim_Radius::DrawOn(Draw_Display& dis) const
{
// input
TopoDS_Shape myFShape = myCylinder;
// output
gp_Pnt myPosition;
gp_Circ myCircle;
//=======================================================================
//function : ComputeOneFaceRadius
//purpose :
//=======================================================================
//void AIS_RadiusDimension::ComputeOneFaceRadius(const Handle(Prs3d_Presentation)& aPresentation)
//{
cout << "entree dans computeonefaceradius"<< endl;
BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
Standard_Real uFirst, uLast, vFirst, vLast;
uFirst = surfAlgo.FirstUParameter();
uLast = surfAlgo.LastUParameter();
vFirst = surfAlgo.FirstVParameter();
vLast = surfAlgo.LastVParameter();
Standard_Real uMoy = (uFirst + uLast)/2;
Standard_Real vMoy = (vFirst + vLast)/2;
gp_Pnt curpos ;
surfAlgo.D0(uMoy, vMoy, curpos);
const Handle(Geom_Surface)& surf = surfAlgo.Surface().Surface();
Handle(Geom_Curve) aCurve;
if (surf->DynamicType() == STANDARD_TYPE(Geom_ToroidalSurface)) {
aCurve = surf->UIso(uMoy);
uFirst = vFirst;
uLast = vLast;
}
else {
aCurve = surf->VIso(vMoy);
}
if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) {
myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
} // if (aCurve->DynamicType() ...
else {
// compute a circle from 3 points on "aCurve"
gp_Pnt P1, P2;
surfAlgo.D0(uFirst, vMoy, P1);
surfAlgo.D0(uLast, vMoy, P2);
GC_MakeCircle mkCirc(P1, curpos, P2);
myCircle = mkCirc.Value()->Circ();
} // else ...
myPosition = curpos;
// DISPLAY
// Add(myText, curpos, mCircle, uFirst, uLast)
dis.Draw(myCircle,uFirst,uLast);
dis.DrawMarker(myPosition, Draw_Losange);
}

2
src/DrawDim/FILES Executable file
View File

@@ -0,0 +1,2 @@
DrawDim_PlanarDimensionCommands.cxx