mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
180
src/DsgPrs/DsgPrs.cdl
Executable file
180
src/DsgPrs/DsgPrs.cdl
Executable file
@@ -0,0 +1,180 @@
|
||||
-- File: DsgPrs.cdl
|
||||
-- Created: Mon Oct 3 15:35:36 1994
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@houblon>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
package DsgPrs
|
||||
|
||||
---Purpose: Describes Standard Presentations for DsgIHM objects
|
||||
|
||||
uses Prs3d,
|
||||
gp,
|
||||
TCollection,
|
||||
TopoDS,
|
||||
Quantity,
|
||||
Geom
|
||||
|
||||
is
|
||||
enumeration ArrowSide is AS_NONE,AS_FIRSTAR,AS_LASTAR,AS_BOTHAR,AS_FIRSTPT,AS_LASTPT,AS_BOTHPT,
|
||||
AS_FIRSTAR_LASTPT,AS_FIRSTPT_LASTAR;
|
||||
---Purpose: Designates how many arrows will be displayed and
|
||||
-- where they will be displayed in presenting a length.
|
||||
|
||||
class EllipseRadiusPresentation;
|
||||
|
||||
class LengthPresentation;
|
||||
|
||||
class RadiusPresentation;
|
||||
|
||||
class DiameterPresentation;
|
||||
|
||||
class FilletRadiusPresentation;
|
||||
|
||||
class AnglePresentation;
|
||||
|
||||
class Chamf2dPresentation;
|
||||
|
||||
class ParalPresentation;
|
||||
|
||||
class PerpenPresentation;
|
||||
|
||||
class SymmetricPresentation; -- presentation for axial symmetry
|
||||
|
||||
class MidPointPresentation; -- presentation for equal distance from point
|
||||
|
||||
class TangentPresentation;
|
||||
|
||||
class ConcentricPresentation;
|
||||
|
||||
class FixPresentation;
|
||||
|
||||
class IdenticPresentation;
|
||||
|
||||
class EqualRadiusPresentation;
|
||||
|
||||
class EqualDistancePresentation;
|
||||
|
||||
class SymbPresentation;
|
||||
|
||||
class ShapeDirPresentation;
|
||||
|
||||
class OffsetPresentation;
|
||||
|
||||
class DatumTool;
|
||||
|
||||
class DatumPrs instantiates Datum from Prs3d(Ax2 from gp,
|
||||
DatumTool from DsgPrs);
|
||||
class XYZAxisPresentation;
|
||||
|
||||
class XYZPlanePresentation;
|
||||
|
||||
class ShadedPlanePresentation;
|
||||
|
||||
ComputeSymbol(aPresentation: Presentation from Prs3d;
|
||||
anAspect: AngleAspect from Prs3d;
|
||||
pt1,pt2:Pnt from gp;
|
||||
dir1,dir2: Dir from gp;
|
||||
ArrowSide: ArrowSide from DsgPrs);
|
||||
---Purpose: draws symbols ((one or two) arrows,(one or two)points
|
||||
-- at thebeginning and at the end of the dimension
|
||||
|
||||
ComputeSymbol(aPresentation: Presentation from Prs3d;
|
||||
anAspect: LengthAspect from Prs3d;
|
||||
pt1,pt2:Pnt from gp;
|
||||
dir1,dir2: Dir from gp;
|
||||
ArrowSide: ArrowSide from DsgPrs;
|
||||
drawFromCenter: Boolean = Standard_True);
|
||||
---Purpose: draws symbols ((one or two) arrows,(one or two)points
|
||||
-- at thebeginning and at the end of the dimension
|
||||
|
||||
ComputePlanarFacesLengthPresentation( FirstArrowLength : Real from Standard;
|
||||
SecondArrowLength : Real from Standard;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
DirAttach : Dir from gp;
|
||||
OffsetPoint : Pnt from gp;
|
||||
PlaneOfFaces : Pln from gp;
|
||||
EndOfArrow1 : out Pnt from gp;
|
||||
EndOfArrow2 : out Pnt from gp;
|
||||
DirOfArrow1 : out Dir from gp );
|
||||
|
||||
ComputeCurvilinearFacesLengthPresentation( FirstArrowLength : Real from Standard;
|
||||
SecondArrowLength : Real from Standard;
|
||||
SecondSurf : Surface from Geom;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
DirAttach : Dir from gp;
|
||||
EndOfArrow2 : out Pnt from gp;
|
||||
DirOfArrow1 : out Dir from gp;
|
||||
VCurve : out Curve from Geom;
|
||||
UCurve : out Curve from Geom;
|
||||
FirstU : out Real from Standard;
|
||||
deltaU : out Real from Standard;
|
||||
FirstV : out Real from Standard;
|
||||
deltaV : out Real from Standard );
|
||||
|
||||
|
||||
|
||||
ComputeFacesAnglePresentation( ArrowLength : Real from Standard;
|
||||
Value : Real from Standard;
|
||||
CenterPoint : Pnt from gp;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
dir1 : Dir from gp;
|
||||
dir2 : Dir from gp;
|
||||
axisdir : Dir from gp;
|
||||
isPlane : Boolean from Standard;
|
||||
AxisOfSurf : Ax1 from gp;
|
||||
OffsetPoint : Pnt from gp;
|
||||
AngleCirc : out Circ from gp;
|
||||
FirstParAngleCirc : out Real from Standard;
|
||||
LastParAngleCirc : out Real from Standard;
|
||||
EndOfArrow1 : out Pnt from gp;
|
||||
EndOfArrow2 : out Pnt from gp;
|
||||
DirOfArrow1 : out Dir from gp;
|
||||
DirOfArrow2 : out Dir from gp;
|
||||
ProjAttachPoint2 : out Pnt from gp;
|
||||
AttachCirc : out Circ from gp;
|
||||
FirstParAttachCirc : out Real from Standard;
|
||||
LastParAttachCirc : out Real from Standard );
|
||||
|
||||
|
||||
ComputeRadiusLine( aCenter : Pnt from gp;
|
||||
anEndOfArrow : Pnt from gp;
|
||||
aPosition : Pnt from gp;
|
||||
drawFromCenter: Boolean from Standard;
|
||||
aRadLineOrign : out Pnt from gp;
|
||||
aRadLineEnd : out Pnt from gp);
|
||||
|
||||
ComputeFilletRadiusPresentation( ArrowLength : Real from Standard;
|
||||
Value : Real from Standard;
|
||||
Position : Pnt from gp;
|
||||
NormalDir : Dir from gp;
|
||||
FirstPoint : Pnt from gp;
|
||||
SecondPoint : Pnt from gp;
|
||||
Center : Pnt from gp;
|
||||
BasePnt : Pnt from gp;
|
||||
drawRevers : Boolean from Standard;
|
||||
SpecCase : out Boolean from Standard;
|
||||
FilletCirc : out Circ from gp;
|
||||
FirstParCirc : out Real from Standard;
|
||||
LastParCirc : out Real from Standard;
|
||||
EndOfArrow : out Pnt from gp;
|
||||
DirOfArrow : out Dir from gp;
|
||||
DrawPosition : out Pnt from gp );
|
||||
---Purpose: computes Geometry for fillet radius presentation;
|
||||
-- special case flag SpecCase equal Standard_True if
|
||||
-- radius of fillet circle = 0 or if anngle between
|
||||
-- Vec1(Center, FirstPoint) and Vec2(Center,SecondPoint) equal 0 or PI
|
||||
|
||||
|
||||
DistanceFromApex( elips : Elips from gp;
|
||||
Apex : Pnt from gp;
|
||||
par : Real from Standard)
|
||||
returns Real from Standard;
|
||||
---Purpose: computes length of ellipse arc in parametric units
|
||||
|
||||
end DsgPrs;
|
||||
|
750
src/DsgPrs/DsgPrs.cxx
Executable file
750
src/DsgPrs/DsgPrs.cxx
Executable file
@@ -0,0 +1,750 @@
|
||||
#include <DsgPrs.ixx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
|
||||
#include <gce_MakeLin.hxx>
|
||||
|
||||
|
||||
void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_AngleAspect)& LA,
|
||||
const gp_Pnt& pt1,
|
||||
const gp_Pnt& pt2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const DsgPrs_ArrowSide ArrowSide)
|
||||
{
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
|
||||
MarkerAsp->SetType(Aspect_TOM_BALL);
|
||||
MarkerAsp->SetScale(0.8);
|
||||
Quantity_Color acolor;
|
||||
Aspect_TypeOfLine atype;
|
||||
Standard_Real awidth;
|
||||
LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
|
||||
MarkerAsp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
|
||||
|
||||
// symbols aux extremites de la cote
|
||||
// Graphic3d_Vertex V3d,V3d1,V3d2;
|
||||
Graphic3d_Vertex V3d,V3d1;
|
||||
|
||||
switch(ArrowSide) {
|
||||
case DsgPrs_AS_NONE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_FIRSTAR:
|
||||
{
|
||||
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt1,
|
||||
dir1,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
LA->ArrowAspect()->Length());
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_LASTAR:
|
||||
{
|
||||
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt2,
|
||||
dir2,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
LA->ArrowAspect()->Length());
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_BOTHAR:
|
||||
{
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt1,
|
||||
dir1,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
LA->ArrowAspect()->Length());
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt2,
|
||||
dir2,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
LA->ArrowAspect()->Length());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_FIRSTPT:
|
||||
{
|
||||
V3d = Graphic3d_Vertex (pt1.X(), pt1.Y(), pt1.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_LASTPT:
|
||||
{
|
||||
// On dessine un rond
|
||||
V3d = Graphic3d_Vertex (pt2.X(), pt2.Y(), pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_BOTHPT:
|
||||
{
|
||||
V3d1 = Graphic3d_Vertex (pt1.X(), pt1.Y(), pt1.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d1);
|
||||
Graphic3d_Vertex V3d2(pt2.X(), pt2.Y(), pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_FIRSTAR_LASTPT:
|
||||
{
|
||||
// an Arrow
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt1,
|
||||
dir1,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
LA->ArrowAspect()->Length());
|
||||
// a Round
|
||||
V3d = Graphic3d_Vertex (pt2.X(), pt2.Y(), pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_FIRSTPT_LASTAR:
|
||||
{
|
||||
// a Round
|
||||
V3d = Graphic3d_Vertex (pt1.X(), pt1.Y(), pt1.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
// an Arrow
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt2,
|
||||
dir2,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
LA->ArrowAspect()->Length());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_LengthAspect)& LA,
|
||||
const gp_Pnt& pt1,
|
||||
const gp_Pnt& pt2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const DsgPrs_ArrowSide ArrowSide,
|
||||
const Standard_Boolean drawFromCenter)
|
||||
{
|
||||
Quantity_Color acolor;
|
||||
Aspect_TypeOfLine atype;
|
||||
Standard_Real awidth;
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
|
||||
Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
|
||||
MarkerAsp->SetType(Aspect_TOM_BALL);
|
||||
MarkerAsp->SetScale(0.8);
|
||||
MarkerAsp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
|
||||
// symbols aux extremites de la cote
|
||||
// Graphic3d_Vertex V3d,V3d1,V3d2;
|
||||
Graphic3d_Vertex V3d,V3d1;
|
||||
|
||||
switch(ArrowSide) {
|
||||
case DsgPrs_AS_NONE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_FIRSTAR:
|
||||
{
|
||||
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt1,
|
||||
dir1,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_LASTAR:
|
||||
{
|
||||
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt2,
|
||||
dir2,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_BOTHAR:
|
||||
{
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt1,
|
||||
dir1,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
pt2,
|
||||
dir2,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_FIRSTPT:
|
||||
{
|
||||
V3d = Graphic3d_Vertex (pt1.X(), pt1.Y(), pt1.Z());
|
||||
if(drawFromCenter)
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_LASTPT:
|
||||
{
|
||||
// On dessine un rond
|
||||
V3d = Graphic3d_Vertex (pt2.X(), pt2.Y(), pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_BOTHPT:
|
||||
{
|
||||
V3d1 = Graphic3d_Vertex (pt1.X(), pt1.Y(), pt1.Z());
|
||||
if(drawFromCenter)
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d1);
|
||||
Graphic3d_Vertex V3d2(pt2.X(), pt2.Y(), pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_FIRSTAR_LASTPT:
|
||||
{
|
||||
// an Arrow
|
||||
Prs3d_Arrow::Draw (aPresentation,
|
||||
pt1,
|
||||
dir1,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
// a Round
|
||||
V3d = Graphic3d_Vertex (pt2.X(), pt2.Y(), pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DsgPrs_AS_FIRSTPT_LASTAR:
|
||||
{
|
||||
// a Round
|
||||
V3d = Graphic3d_Vertex (pt1.X(), pt1.Y(), pt1.Z());
|
||||
if(drawFromCenter)
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
// an Arrow
|
||||
Prs3d_Arrow::Draw (aPresentation,
|
||||
pt2,
|
||||
dir2,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputePlanarFacesLengthPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs::ComputePlanarFacesLengthPresentation( const Standard_Real FirstArrowLength,
|
||||
const Standard_Real SecondArrowLength,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& DirAttach,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const gp_Pln& PlaneOfFaces,
|
||||
gp_Pnt & EndOfArrow1,
|
||||
gp_Pnt & EndOfArrow2,
|
||||
gp_Dir & DirOfArrow1 )
|
||||
{
|
||||
gp_Lin FirstLin( AttachmentPoint1, DirAttach );
|
||||
gp_Lin SecondLin( AttachmentPoint2, DirAttach );
|
||||
|
||||
EndOfArrow1 = ElCLib::Value( ElCLib::Parameter( FirstLin, OffsetPoint ), FirstLin );
|
||||
EndOfArrow2 = ElCLib::Value( ElCLib::Parameter( SecondLin, OffsetPoint ), SecondLin );
|
||||
|
||||
if (EndOfArrow1.SquareDistance( EndOfArrow2 ) > Precision::Confusion()*Precision::Confusion()) // not null length
|
||||
{
|
||||
gp_Dir LengthDir( gp_Vec( EndOfArrow1, EndOfArrow2 ) );
|
||||
if ((FirstArrowLength + SecondArrowLength)*(FirstArrowLength + SecondArrowLength) <
|
||||
EndOfArrow1.SquareDistance( EndOfArrow2 ))
|
||||
DirOfArrow1 = -LengthDir;
|
||||
else
|
||||
DirOfArrow1 = LengthDir;
|
||||
}
|
||||
else // null length
|
||||
DirOfArrow1 = PlaneOfFaces.Axis().Direction();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeCurvilinearFacesLengthPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs::ComputeCurvilinearFacesLengthPresentation( const Standard_Real FirstArrowLength,
|
||||
const Standard_Real SecondArrowLength,
|
||||
const Handle( Geom_Surface )& SecondSurf,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& DirAttach,
|
||||
gp_Pnt & EndOfArrow2,
|
||||
gp_Dir & DirOfArrow1,
|
||||
Handle( Geom_Curve )& VCurve,
|
||||
Handle( Geom_Curve )& UCurve,
|
||||
Standard_Real & FirstU,
|
||||
Standard_Real & deltaU,
|
||||
Standard_Real & FirstV,
|
||||
Standard_Real & deltaV )
|
||||
{
|
||||
GeomAPI_ProjectPointOnSurf ProjectorOnSurface;
|
||||
GeomAPI_ProjectPointOnCurve ProjectorOnCurve;
|
||||
Quantity_Parameter U1, V1, U2, V2;
|
||||
Standard_Real LastU, LastV;
|
||||
Standard_Real SquareTolerance = Precision::Confusion()*Precision::Confusion();
|
||||
|
||||
ProjectorOnSurface.Init( AttachmentPoint1, SecondSurf );
|
||||
Standard_Integer Index(1);
|
||||
Quantity_Length MinDist = RealLast();
|
||||
Quantity_Parameter LocalU, LocalV;
|
||||
gp_Vec D1U, D1V;
|
||||
gp_Dir LocalDir;
|
||||
for (Standard_Integer i = 1; i <= ProjectorOnSurface.NbPoints(); i++)
|
||||
{
|
||||
ProjectorOnSurface.Parameters( i, LocalU, LocalV );
|
||||
|
||||
SecondSurf->D1( LocalU, LocalV, EndOfArrow2, D1U, D1V );
|
||||
if (D1U.SquareMagnitude() <= SquareTolerance || D1V.SquareMagnitude() <= SquareTolerance)
|
||||
LocalDir = gp_Dir( gp_Vec( AttachmentPoint1, ProjectorOnSurface.Point( i ) ) );
|
||||
else
|
||||
LocalDir = gp_Dir( D1U ^ D1V );
|
||||
if (DirAttach.IsParallel( LocalDir, Precision::Angular() ) && ProjectorOnSurface.Distance( i ) < MinDist)
|
||||
{
|
||||
Index = i;
|
||||
MinDist = ProjectorOnSurface.Distance( i );
|
||||
}
|
||||
}
|
||||
EndOfArrow2 = ProjectorOnSurface.Point( Index );
|
||||
ProjectorOnSurface.Parameters( Index, U1, V1 );
|
||||
|
||||
if ((FirstArrowLength + SecondArrowLength)*(FirstArrowLength + SecondArrowLength) <
|
||||
AttachmentPoint1.SquareDistance( EndOfArrow2 ))
|
||||
DirOfArrow1 = -DirAttach;
|
||||
else
|
||||
DirOfArrow1 = DirAttach;
|
||||
|
||||
if (EndOfArrow2.SquareDistance( AttachmentPoint2 ) > Precision::Confusion()*Precision::Confusion())
|
||||
{
|
||||
VCurve = SecondSurf->VIso( V1 );
|
||||
ProjectorOnCurve.Init( EndOfArrow2, VCurve );
|
||||
FirstU = ProjectorOnCurve.LowerDistanceParameter();
|
||||
|
||||
ProjectorOnSurface.Init( AttachmentPoint2, SecondSurf );
|
||||
ProjectorOnSurface.LowerDistanceParameters( U2, V2 );
|
||||
UCurve = SecondSurf->UIso( U2 );
|
||||
|
||||
ProjectorOnCurve.Init( AttachmentPoint2, UCurve );
|
||||
LastV = ProjectorOnCurve.LowerDistanceParameter();
|
||||
|
||||
gp_Pnt Intersection = SecondSurf->Value( U2, V1 );
|
||||
ProjectorOnCurve.Init( Intersection, VCurve );
|
||||
LastU = ProjectorOnCurve.LowerDistanceParameter();
|
||||
ProjectorOnCurve.Init( Intersection, UCurve );
|
||||
FirstV = ProjectorOnCurve.LowerDistanceParameter();
|
||||
|
||||
deltaU = LastU - FirstU;
|
||||
deltaV = LastV - FirstV;
|
||||
|
||||
if (VCurve->IsPeriodic() && Abs( deltaU ) > VCurve->Period()/2)
|
||||
{
|
||||
Standard_Real Sign = (deltaU > 0.0)? -1.0 : 1.0;
|
||||
deltaU = VCurve->Period() - Abs( deltaU );
|
||||
deltaU *= Sign;
|
||||
}
|
||||
if (UCurve->IsPeriodic() && Abs( deltaV ) > UCurve->Period()/2)
|
||||
{
|
||||
Standard_Real Sign = (deltaV > 0.0)? -1.0 : 1.0;
|
||||
deltaV = UCurve->Period() - Abs( deltaV );
|
||||
deltaV *= Sign;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeFacesAnglePresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs::ComputeFacesAnglePresentation( const Standard_Real ArrowLength,
|
||||
const Standard_Real Value,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const gp_Dir& axisdir,
|
||||
const Standard_Boolean isPlane,
|
||||
const gp_Ax1& AxisOfSurf,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
gp_Circ & AngleCirc,
|
||||
Standard_Real & FirstParAngleCirc,
|
||||
Standard_Real & LastParAngleCirc,
|
||||
gp_Pnt & EndOfArrow1,
|
||||
gp_Pnt & EndOfArrow2,
|
||||
gp_Dir & DirOfArrow1,
|
||||
gp_Dir & DirOfArrow2,
|
||||
gp_Pnt & ProjAttachPoint2,
|
||||
gp_Circ & AttachCirc,
|
||||
Standard_Real & FirstParAttachCirc,
|
||||
Standard_Real & LastParAttachCirc )
|
||||
{
|
||||
if (Value > Precision::Angular() && Abs( PI-Value ) > Precision::Angular())
|
||||
{
|
||||
// Computing presentation of angle's arc
|
||||
gp_Ax2 ax( CenterPoint, axisdir, dir1 );
|
||||
AngleCirc.SetPosition( ax );
|
||||
AngleCirc.SetRadius( CenterPoint.Distance( OffsetPoint ) );
|
||||
gp_Vec vec1( dir1 );
|
||||
vec1 *= AngleCirc.Radius();
|
||||
gp_Pnt p1 = CenterPoint.Translated( vec1 );
|
||||
gp_Vec vec2( dir2 );
|
||||
vec2 *= AngleCirc.Radius();
|
||||
gp_Pnt p2 = CenterPoint.Translated( vec2 );
|
||||
|
||||
Standard_Real Par1 = 0.;
|
||||
Standard_Real Par2 = ElCLib::Parameter( AngleCirc, p2 );
|
||||
Standard_Real Par0 = ElCLib::Parameter( AngleCirc, OffsetPoint );
|
||||
|
||||
gp_Vec PosVec( CenterPoint, OffsetPoint );
|
||||
gp_Vec NormalOfPlane = vec1 ^ vec2;
|
||||
|
||||
gp_Vec Normal1 = NormalOfPlane ^ vec1;
|
||||
gp_Vec Normal2 = NormalOfPlane ^ vec2;
|
||||
Standard_Integer Sign1 = (PosVec * Normal1 >= 0)? 1 : -1;
|
||||
Standard_Integer Sign2 = (PosVec * Normal2 >= 0)? 1 : -1;
|
||||
if (Sign1 == 1 && Sign2 == -1)
|
||||
{
|
||||
FirstParAngleCirc = Par1;
|
||||
LastParAngleCirc = Par2;
|
||||
}
|
||||
else if (Sign1 == 1 && Sign2 == 1)
|
||||
{
|
||||
FirstParAngleCirc = Par1;
|
||||
LastParAngleCirc = Par0;
|
||||
}
|
||||
else if (Sign1 == -1 && Sign2 == 1)
|
||||
{
|
||||
Par1 += PI;
|
||||
Par2 += PI;
|
||||
FirstParAngleCirc = Par1;
|
||||
LastParAngleCirc = Par2;
|
||||
}
|
||||
else //Sign1 == -1 && Sign2 == -1
|
||||
{
|
||||
AngleCirc.SetPosition( gp_Ax2( CenterPoint, axisdir, gp_Dir( PosVec ) ) );
|
||||
Par0 = 0.;
|
||||
Par1 = ElCLib::Parameter( AngleCirc, p1 );
|
||||
Par2 = ElCLib::Parameter( AngleCirc, p2 );
|
||||
FirstParAngleCirc = Par0;
|
||||
LastParAngleCirc = Par2;
|
||||
}
|
||||
|
||||
// Computing presentation of arrows
|
||||
EndOfArrow1 = ElCLib::Value( Par1, AngleCirc );
|
||||
EndOfArrow2 = ElCLib::Value( Par2, AngleCirc );
|
||||
Standard_Real beta = 0.;
|
||||
if (AngleCirc.Radius() > Precision::Confusion())
|
||||
beta = ArrowLength / AngleCirc.Radius();
|
||||
gp_Pnt OriginOfArrow1 = ElCLib::Value( Par1 + beta, AngleCirc );
|
||||
gp_Pnt OriginOfArrow2 = ElCLib::Value( Par2 - beta, AngleCirc );
|
||||
DirOfArrow1 = gp_Dir( gp_Vec( OriginOfArrow1, EndOfArrow1 ) );
|
||||
DirOfArrow2 = gp_Dir( gp_Vec( OriginOfArrow2, EndOfArrow2 ) );
|
||||
if (EndOfArrow1.SquareDistance( EndOfArrow2 ) <= (ArrowLength + ArrowLength)*(ArrowLength + ArrowLength))
|
||||
{
|
||||
DirOfArrow1.Reverse();
|
||||
DirOfArrow2.Reverse();
|
||||
}
|
||||
}
|
||||
else // dir1 and dir2 are parallel
|
||||
{
|
||||
gp_Dir ArrowDir = axisdir ^ dir1;
|
||||
DirOfArrow1 = ArrowDir;
|
||||
DirOfArrow2 = -ArrowDir;
|
||||
gp_Lin DirLine( AttachmentPoint1, dir1 );
|
||||
EndOfArrow1 = ElCLib::Value( ElCLib::Parameter( DirLine, OffsetPoint ), DirLine );
|
||||
EndOfArrow2 = EndOfArrow1;
|
||||
}
|
||||
|
||||
// Line or arc from AttachmentPoint2 to its "projection"
|
||||
gp_Lin SecondLin( CenterPoint, dir2 );
|
||||
if (SecondLin.Contains( AttachmentPoint2, Precision::Confusion() ))
|
||||
ProjAttachPoint2 = AttachmentPoint2;
|
||||
else
|
||||
{
|
||||
if (isPlane)
|
||||
ProjAttachPoint2 = ElCLib::Value( ElCLib::Parameter( SecondLin, AttachmentPoint2 ), SecondLin );
|
||||
else
|
||||
{
|
||||
gp_Lin LineOfAxis( AxisOfSurf );
|
||||
gp_Pnt CenterOfArc = ElCLib::Value( ElCLib::Parameter( LineOfAxis, AttachmentPoint2 ),
|
||||
LineOfAxis );
|
||||
|
||||
gp_Ax2 Ax2( CenterOfArc,
|
||||
AxisOfSurf.Direction(),
|
||||
gp_Dir( gp_Vec( CenterOfArc, AttachmentPoint2 ) ) );
|
||||
AttachCirc.SetPosition( Ax2 );
|
||||
AttachCirc.SetRadius( CenterOfArc.Distance( AttachmentPoint2 ) );
|
||||
|
||||
GeomAPI_ExtremaCurveCurve Intersection( new Geom_Circle( AttachCirc ),
|
||||
new Geom_Line( SecondLin ) );
|
||||
Intersection.NearestPoints( ProjAttachPoint2, ProjAttachPoint2 );
|
||||
|
||||
Standard_Real U2 = ElCLib::Parameter( AttachCirc, ProjAttachPoint2 );
|
||||
if (U2 <= PI)
|
||||
{
|
||||
FirstParAttachCirc = 0;
|
||||
LastParAttachCirc = U2;
|
||||
}
|
||||
else
|
||||
{
|
||||
FirstParAttachCirc = U2;
|
||||
LastParAttachCirc = 2*PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DsgPrs::ComputeFilletRadiusPresentation( const Standard_Real ArrowLength,
|
||||
const Standard_Real Value,
|
||||
const gp_Pnt & Position,
|
||||
const gp_Dir & NormalDir,
|
||||
const gp_Pnt & FirstPoint,
|
||||
const gp_Pnt & SecondPoint,
|
||||
const gp_Pnt & Center,
|
||||
const gp_Pnt & BasePnt,
|
||||
const Standard_Boolean drawRevers,
|
||||
Standard_Boolean & SpecCase,
|
||||
gp_Circ & FilletCirc,
|
||||
Standard_Real & FirstParCirc,
|
||||
Standard_Real & LastParCirc,
|
||||
gp_Pnt & EndOfArrow,
|
||||
gp_Dir & DirOfArrow,
|
||||
gp_Pnt & DrawPosition)
|
||||
{
|
||||
gp_Dir dir1(gp_Vec(Center, FirstPoint));
|
||||
gp_Dir dir2(gp_Vec(Center, SecondPoint));
|
||||
Standard_Real Angle = dir1.Angle(dir2);
|
||||
if(Angle <= Precision::Angular() || ( PI - Angle ) <= Precision::Angular() ||
|
||||
Value <= Precision::Confusion()) SpecCase = Standard_True;
|
||||
else SpecCase = Standard_False;
|
||||
if ( !SpecCase )
|
||||
{
|
||||
// Computing presentation of fillet's arc
|
||||
gp_Ax2 ax( Center, NormalDir, dir1 );
|
||||
FilletCirc.SetPosition( ax );
|
||||
FilletCirc.SetRadius( Center.Distance( FirstPoint ) ); //***
|
||||
gp_Vec vec1( dir1 );
|
||||
vec1 *= FilletCirc.Radius();
|
||||
#ifdef DEB
|
||||
gp_Pnt p1 =
|
||||
#endif
|
||||
Center.Translated( vec1 );
|
||||
gp_Vec vec2( dir2 );
|
||||
vec2 *= FilletCirc.Radius();
|
||||
#ifdef DEB
|
||||
gp_Pnt p2 =
|
||||
#endif
|
||||
Center.Translated( vec2 );
|
||||
gp_Vec PosVec;
|
||||
if(! Center.IsEqual( Position, Precision::Confusion() ))
|
||||
PosVec.SetXYZ( gp_Vec(Center, Position).XYZ() );
|
||||
else
|
||||
PosVec.SetXYZ( (vec1.Added(vec2)).XYZ() );
|
||||
gp_Vec NormalOfPlane = vec1 ^ vec2;
|
||||
gp_Vec Normal1 = NormalOfPlane ^ vec1;
|
||||
gp_Vec Normal2 = NormalOfPlane ^ vec2;
|
||||
Standard_Integer Sign1 = (PosVec * Normal1 >= 0)? 1 : -1;
|
||||
Standard_Integer Sign2 = (PosVec * Normal2 >= 0)? 1 : -1;
|
||||
gp_Lin L1( Center, dir1 );
|
||||
gp_Lin L2( Center, dir2 );
|
||||
if ( Sign1 != Sign2 )
|
||||
{
|
||||
DrawPosition = Position; //***
|
||||
gp_Dir direction(PosVec) ;
|
||||
Standard_Real angle = dir1.Angle(direction) ;
|
||||
if (( dir1 ^ direction) * NormalDir < 0.0e0) angle = -angle ;
|
||||
if(Sign1 == -1) angle += PI;
|
||||
EndOfArrow = ElCLib::Value(angle, FilletCirc); //***
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(L1.Distance(Position) < L2.Distance(Position))
|
||||
{
|
||||
EndOfArrow = FirstPoint; //***
|
||||
DrawPosition = ElCLib::Value(ElCLib::Parameter(L1, Position), L1);
|
||||
}
|
||||
else
|
||||
{
|
||||
EndOfArrow = SecondPoint; //***
|
||||
DrawPosition = ElCLib::Value(ElCLib::Parameter(L2, Position), L2);
|
||||
}
|
||||
}
|
||||
if((dir1^dir2).IsOpposite(NormalDir, Precision::Angular()))
|
||||
{
|
||||
gp_Dir newdir = NormalDir.Reversed() ;
|
||||
gp_Ax2 axnew( Center, newdir, dir1 );
|
||||
FilletCirc.SetPosition( axnew );
|
||||
}
|
||||
FirstParCirc = ElCLib::Parameter( FilletCirc, FirstPoint );
|
||||
LastParCirc = ElCLib::Parameter( FilletCirc, SecondPoint );
|
||||
|
||||
#ifdef DEB
|
||||
#endif
|
||||
}
|
||||
else //Angle equal 0 or PI or R = 0
|
||||
{
|
||||
DrawPosition = Position;
|
||||
EndOfArrow = BasePnt;
|
||||
}
|
||||
|
||||
|
||||
if(drawRevers)
|
||||
{
|
||||
gp_Vec Vd(DrawPosition, EndOfArrow);
|
||||
DrawPosition.Translate(Vd *2);
|
||||
}
|
||||
DirOfArrow.SetXYZ(gp_Dir(gp_Vec(DrawPosition, EndOfArrow)).XYZ());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeRadiusLine
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs::ComputeRadiusLine(const gp_Pnt & aCenter,
|
||||
const gp_Pnt & anEndOfArrow,
|
||||
const gp_Pnt & aPosition,
|
||||
const Standard_Boolean drawFromCenter,
|
||||
gp_Pnt & aRadLineOrign,
|
||||
gp_Pnt & aRadLineEnd)
|
||||
{
|
||||
if(drawFromCenter)
|
||||
{
|
||||
gp_Lin RadiusLine = gce_MakeLin( aCenter, anEndOfArrow );
|
||||
Standard_Real PosParOnLine = ElCLib::Parameter( RadiusLine, aPosition );
|
||||
Standard_Real EndOfArrowPar = ElCLib::Parameter( RadiusLine, anEndOfArrow );
|
||||
if (PosParOnLine < 0.0)
|
||||
{
|
||||
aRadLineOrign = aPosition;
|
||||
aRadLineEnd = anEndOfArrow;
|
||||
}
|
||||
else if (PosParOnLine > EndOfArrowPar)
|
||||
{
|
||||
aRadLineOrign = aPosition;
|
||||
aRadLineEnd = aCenter;
|
||||
}
|
||||
else
|
||||
{
|
||||
aRadLineOrign = aCenter;
|
||||
aRadLineEnd = anEndOfArrow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aRadLineOrign = aPosition;
|
||||
aRadLineEnd = anEndOfArrow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DistanceFromApex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real DsgPrs::DistanceFromApex(const gp_Elips & elips,
|
||||
const gp_Pnt & Apex,
|
||||
const Standard_Real par)
|
||||
{
|
||||
Standard_Real dist;
|
||||
Standard_Real parApex = ElCLib::Parameter ( elips, Apex );
|
||||
if(parApex == 0.0 || parApex == PI)
|
||||
{//Major case
|
||||
if(parApex == 0.0) //pos Apex
|
||||
dist = (par < PI) ? par : (2*PI - par);
|
||||
else //neg Apex
|
||||
dist = (par < PI) ? ( PI - par) : ( par - PI );
|
||||
}
|
||||
else
|
||||
{// Minor case
|
||||
if(parApex == PI / 2) //pos Apex
|
||||
{
|
||||
if(par <= parApex + PI && par > parApex )
|
||||
dist = par - parApex;
|
||||
else
|
||||
{
|
||||
if(par > parApex + PI)
|
||||
dist = 2*PI - par + parApex;
|
||||
else
|
||||
dist = parApex - par; // 0 < par < PI/2
|
||||
}
|
||||
}
|
||||
else //neg Apex == 3/2 PI
|
||||
{
|
||||
if(par <= parApex && par >= PI/2)
|
||||
dist = parApex - par;
|
||||
else
|
||||
{
|
||||
if(par > parApex)
|
||||
dist = par - parApex;
|
||||
else
|
||||
dist = par + PI/2; // 0 < par < PI/2
|
||||
}
|
||||
}
|
||||
}
|
||||
return dist;
|
||||
}
|
129
src/DsgPrs/DsgPrs_AnglePresentation.cdl
Executable file
129
src/DsgPrs/DsgPrs_AnglePresentation.cdl
Executable file
@@ -0,0 +1,129 @@
|
||||
-- File: DsgPrs_AnglePresentation.cdl
|
||||
-- Created: Tue Feb 7 12:13:12 1995
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@houblon>
|
||||
-- Modifs by ROB : Added one Method to take into Account Units in
|
||||
-- Presentation
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class AnglePresentation from DsgPrs
|
||||
---Purpose: A framework for displaying angles.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Circ from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection,
|
||||
ArrowSide from DsgPrs,
|
||||
Ax1 from gp
|
||||
|
||||
is
|
||||
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aVal: Real from Standard;
|
||||
aText: ExtendedString from TCollection;
|
||||
aCircle: Circ from gp;
|
||||
aPosition: Pnt from gp;
|
||||
Apex: Pnt from gp;
|
||||
VminCircle: Circ from gp;
|
||||
VmaxCircle: Circ from gp;
|
||||
aArrowSize: Real from Standard );
|
||||
---Purpose: Draws the presenation of the full angle of a cone.
|
||||
-- VminCircle - a circle at V parameter = Vmin
|
||||
-- VmaxCircle - a circle at V parameter = Vmax
|
||||
-- aCircle - a circle at V parameter from projection of aPosition to axis of the cone
|
||||
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
theval: Real from Standard;
|
||||
CenterPoint : Pnt from gp;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
dir1: Dir from gp;
|
||||
dir2: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Draws the representation of the angle
|
||||
-- defined by dir1 and dir2, centered on
|
||||
-- CenterPoint, using the offset point OffsetPoint.
|
||||
-- Lines are drawn to points AttachmentPoint1 and AttachmentPoint2
|
||||
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
theval: Real from Standard;
|
||||
thevalstring : ExtendedString from TCollection;
|
||||
CenterPoint : Pnt from gp;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
dir1: Dir from gp;
|
||||
dir2: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Same as above, but <thevalstring> contains conversion
|
||||
-- in Session units....
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
theval: Real from Standard;
|
||||
thevalstring : ExtendedString from TCollection;
|
||||
CenterPoint : Pnt from gp;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
dir1: Dir from gp;
|
||||
dir2: Dir from gp;
|
||||
OffsetPoint: Pnt from gp;
|
||||
ArrowSide : ArrowSide from DsgPrs);
|
||||
---Purpose: Same as above, may add one or
|
||||
-- two Arrows according to <ArrowSide> value
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
theval: Real from Standard;
|
||||
thevalstring : ExtendedString from TCollection;
|
||||
CenterPoint : Pnt from gp;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
dir1: Dir from gp;
|
||||
dir2: Dir from gp;
|
||||
axisdir: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Same as above, but axisdir contains the axis direction
|
||||
-- useful for Revol that can be opened with 180 degrees
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
theval : Real from Standard;
|
||||
thevalstring : ExtendedString from TCollection;
|
||||
CenterPoint : Pnt from gp;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
dir1 : Dir from gp;
|
||||
dir2 : Dir from gp;
|
||||
axisdir : Dir from gp;
|
||||
isPlane : Boolean from Standard;
|
||||
AxisOfSurf : Ax1 from gp;
|
||||
OffsetPoint : Pnt from gp;
|
||||
ArrowSide : ArrowSide from DsgPrs);
|
||||
---Purpose: Same as above,may add one or
|
||||
-- two Arrows according to <ArrowSide> value
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer:Drawer from Prs3d;
|
||||
theval: Real from Standard;
|
||||
theCenter,AttachmentPoint1:Pnt from gp;
|
||||
theAxe: Ax1 from gp;
|
||||
ArrowSide: ArrowSide from DsgPrs);
|
||||
---Purpose: simple representation of a poor lonesome angle dimension
|
||||
-- Draw a line from <theCenter> to <AttachmentPoint1>, then operates
|
||||
-- a rotation around the perpmay add one or
|
||||
-- two Arrows according to <ArrowSide> value. The
|
||||
-- attributes (color,arrowsize,...) are driven by the Drawer.
|
||||
|
||||
|
||||
end AnglePresentation;
|
||||
|
||||
|
||||
|
||||
|
973
src/DsgPrs/DsgPrs_AnglePresentation.cxx
Executable file
973
src/DsgPrs/DsgPrs_AnglePresentation.cxx
Executable file
@@ -0,0 +1,973 @@
|
||||
// File: DsgPrs_AnglePresentation.cxx
|
||||
// Created: Tue Feb 7 12:18:14 1995
|
||||
|
||||
|
||||
#include <DsgPrs_AnglePresentation.ixx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_AngleAspect.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
#include <GC_MakeCircle.hxx>
|
||||
#include <gce_MakePln.hxx>
|
||||
|
||||
#include <UnitsAPI.hxx>
|
||||
|
||||
//pop pour NT
|
||||
//#if WNT
|
||||
#include <stdio.h>
|
||||
//#endif
|
||||
|
||||
|
||||
static Standard_Integer AboveInBelowCone(gp_Circ CMax, gp_Circ CMin, gp_Circ C);
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_AnglePresentation::Add
|
||||
// purpose : draws the presentation of the cone's angle;
|
||||
//==========================================================================
|
||||
void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real aVal,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Circ& aCircle,
|
||||
const gp_Pnt& aPosition,
|
||||
const gp_Pnt& Apex,
|
||||
const gp_Circ& VminCircle,
|
||||
const gp_Circ& VmaxCircle,
|
||||
const Standard_Real aArrowSize)
|
||||
{
|
||||
|
||||
|
||||
|
||||
Handle(Prs3d_AngleAspect) anAngleAspect = aDrawer->AngleAspect();
|
||||
Handle(Prs3d_LengthAspect) aLengthAspect = aDrawer->LengthAspect();
|
||||
Standard_Real myArrowSize;
|
||||
|
||||
TCollection_ExtendedString txt = aText;
|
||||
if( aArrowSize == 0.0 ) myArrowSize = aCircle.Radius()/ 10.;
|
||||
else myArrowSize = aArrowSize;
|
||||
|
||||
anAngleAspect->ArrowAspect()->SetLength(myArrowSize);
|
||||
aDrawer->ArrowAspect()->SetLength(myArrowSize);
|
||||
|
||||
Standard_Boolean IsArrowOut = Standard_True; //Is arrows inside or outside of the cone
|
||||
Standard_Boolean IsConeTrimmed = Standard_False;
|
||||
gp_Circ myCircle = aCircle;
|
||||
|
||||
|
||||
if( VminCircle.Radius() > 0.01 ) {
|
||||
IsConeTrimmed = Standard_True;
|
||||
if( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 1 ) myCircle = VminCircle;
|
||||
}
|
||||
|
||||
gp_Pnt AttachmentPnt;
|
||||
gp_Pnt OppositePnt;
|
||||
gp_Pnt aPnt, tmpPnt;
|
||||
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
Standard_Real param = 0.; //ElCLib::Parameter(myCircle, aPosition);
|
||||
|
||||
aPnt = Apex;
|
||||
gp_Pnt P1 = ElCLib::Value(0., myCircle);
|
||||
gp_Pnt P2 = ElCLib::Value(Standard_PI, myCircle);
|
||||
|
||||
gce_MakePln mkPln(P1, P2, aPnt); // create a plane whitch defines plane for projection aPosition on it
|
||||
|
||||
gp_Vec aVector( mkPln.Value().Location(), aPosition ); //project aPosition on a plane
|
||||
gp_Vec Normal = mkPln.Value().Axis().Direction();
|
||||
Normal = (aVector * Normal) * Normal;
|
||||
aPnt = aPosition;
|
||||
|
||||
aPnt = aPnt.Translated( -Normal );
|
||||
|
||||
tmpPnt = aPnt;
|
||||
|
||||
if( aPnt.Distance(P1) < aPnt.Distance(P2) ){
|
||||
AttachmentPnt = P1;
|
||||
OppositePnt = P2;
|
||||
}
|
||||
else {
|
||||
AttachmentPnt = P2;
|
||||
OppositePnt = P1;
|
||||
}
|
||||
|
||||
aPnt = AttachmentPnt ; // Creating of circle whitch defines a plane for a dimension arc
|
||||
gp_Vec Vec(AttachmentPnt, Apex); // Dimension arc is a part of the circle
|
||||
Vec.Scale(2);
|
||||
aPnt.Translate(Vec);
|
||||
GC_MakeCircle mkCirc(AttachmentPnt, OppositePnt, aPnt);
|
||||
gp_Circ aCircle2 = mkCirc.Value()->Circ();
|
||||
|
||||
Standard_Integer i;
|
||||
Standard_Real AttParam = ElCLib::Parameter(aCircle2, AttachmentPnt); //must be equal to zero (look circle construction)
|
||||
Standard_Real OppParam = ElCLib::Parameter(aCircle2, OppositePnt);
|
||||
gp_Dir aDir, aDir2;
|
||||
|
||||
while ( AttParam >= 2*Standard_PI ) AttParam -= 2*Standard_PI;
|
||||
while ( OppParam >= 2*Standard_PI ) OppParam -= 2*Standard_PI;
|
||||
|
||||
//-------------------------- Compute angle ------------------------
|
||||
if( txt.Length() == 0 ) {
|
||||
Standard_Real angle = UnitsAPI::CurrentFromLS( Abs( OppParam ),"PLANE ANGLE");
|
||||
char res[80];
|
||||
sprintf(res, "%g", angle );
|
||||
txt = TCollection_ExtendedString(res);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
if( ElCLib::Parameter(aCircle2, tmpPnt) < OppParam )
|
||||
// if( aPosition.Distance( myCircle.Location() ) <= myCircle.Radius() )
|
||||
if( 2 * myCircle.Radius() > 4 * myArrowSize ) IsArrowOut = Standard_False; //four times more than an arrow size
|
||||
|
||||
|
||||
Graphic3d_Array1OfVertex V(1, 12);
|
||||
|
||||
Standard_Real angle;
|
||||
// param = ElCLib::Parameter(aCircle2, tmpPnt);
|
||||
angle = OppParam - AttParam;
|
||||
param = AttParam;
|
||||
|
||||
if(IsArrowOut) {
|
||||
aDir = gp_Dir( ( gp_Vec( ElCLib::Value( AttParam - Standard_PI/12, aCircle2 ), AttachmentPnt) ) );
|
||||
aDir2 = gp_Dir( ( gp_Vec( ElCLib::Value( OppParam + Standard_PI/12, aCircle2 ), OppositePnt) ) );
|
||||
}
|
||||
else {
|
||||
aDir = gp_Dir( ( gp_Vec( ElCLib::Value( AttParam + Standard_PI/12, aCircle2 ), AttachmentPnt ) ) );
|
||||
aDir2 = gp_Dir( ( gp_Vec( ElCLib::Value( OppParam - Standard_PI/12, aCircle2 ), OppositePnt ) ) );
|
||||
}
|
||||
|
||||
while ( angle > 2*Standard_PI ) angle -= 2*Standard_PI;
|
||||
for( i = 0; i <= 11; i++ ) { //calculating of arc
|
||||
( ElCLib::Value(param + angle/11 * i, aCircle2) ).Coord(X, Y, Z);
|
||||
V(i+1).SetCoord(X, Y, Z);
|
||||
}
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); //add the arc
|
||||
|
||||
DsgPrs::ComputeSymbol(aPresentation, anAngleAspect, AttachmentPnt,
|
||||
AttachmentPnt, aDir, aDir, DsgPrs_AS_LASTAR);
|
||||
DsgPrs::ComputeSymbol(aPresentation, anAngleAspect, OppositePnt,
|
||||
OppositePnt, aDir2, aDir2, DsgPrs_AS_LASTAR);
|
||||
|
||||
param = ElCLib::Parameter(aCircle2, tmpPnt);
|
||||
tmpPnt = ElCLib::Value(param, aCircle2);
|
||||
tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -1)*2);
|
||||
Prs3d_Text::Draw(aPresentation,aLengthAspect->TextAspect(), txt, tmpPnt); //add the TCollection_ExtendedString
|
||||
|
||||
angle = 2*Standard_PI - param ;
|
||||
if( param > OppParam ) {
|
||||
while ( angle > 2*Standard_PI ) angle -= 2*Standard_PI;
|
||||
for( i = 11; i >= 0; i-- ) { //calculating of arc
|
||||
( ElCLib::Value(-angle/11 * i, aCircle2) ).Coord(X, Y, Z);
|
||||
V(i+1).SetCoord(X, Y, Z);
|
||||
}
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); //add additional line
|
||||
}
|
||||
|
||||
if( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 1 && !IsConeTrimmed ) { //above
|
||||
Graphic3d_Array1OfVertex V2(1,3);
|
||||
AttachmentPnt.Coord(X, Y, Z);
|
||||
V2(1).SetCoord(X, Y, Z);
|
||||
Apex.Coord(X, Y, Z);
|
||||
V2(2).SetCoord(X, Y, Z);
|
||||
OppositePnt.Coord(X, Y, Z);
|
||||
V2(3).SetCoord(X, Y, Z);
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); //add the additional lines
|
||||
}
|
||||
else {
|
||||
aPnt = OppositePnt ;
|
||||
if ( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 0 ) return;
|
||||
Graphic3d_Array1OfVertex V3(1,2);
|
||||
gp_Pnt P11 = ElCLib::Value( 0., VmaxCircle );
|
||||
gp_Pnt P12 = ElCLib::Value( Standard_PI, VmaxCircle );
|
||||
|
||||
AttachmentPnt.Coord(X, Y, Z);
|
||||
V3(1).SetCoord(X, Y, Z);
|
||||
if( aPnt.Distance(P1) < aPnt.Distance(P2) ) P12.Coord(X, Y, Z);
|
||||
else P11.Coord(X, Y, Z);
|
||||
V3(2).SetCoord(X, Y, Z);
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
|
||||
|
||||
OppositePnt.Coord(X, Y, Z);
|
||||
V3(1).SetCoord(X, Y, Z);
|
||||
if( aPnt.Distance(P1) < aPnt.Distance(P2) ) P11.Coord(X, Y, Z);
|
||||
else P12.Coord(X, Y, Z);
|
||||
V3(2).SetCoord(X, Y, Z);
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Returns 1 if C is above of CMin; 0 if C is bitween CMin and CMax; -1 if C is Below CMax
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
static Standard_Integer AboveInBelowCone(gp_Circ CMax, gp_Circ CMin, gp_Circ C)
|
||||
{
|
||||
Standard_Real D, D1, D2;
|
||||
|
||||
D = CMax.Location().Distance( CMin.Location() );
|
||||
D1 = CMax.Location().Distance( C.Location() );
|
||||
D2 = CMin.Location().Distance( C.Location() );
|
||||
|
||||
|
||||
if ( D >= D1 && D >= D2 ) return 0;
|
||||
if ( D < D2 && D1 < D2 ) return -1;
|
||||
if ( D < D1 && D2 < D1 ) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_AnglePresentation::Add
|
||||
// purpose :
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const gp_Dir& axisdir,
|
||||
const gp_Pnt& OffsetPoint) {
|
||||
char valcar[80];
|
||||
sprintf(valcar,"%5.2f",theval);
|
||||
|
||||
Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Ax2 ax(CenterPoint,axisdir,dir1);
|
||||
gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint));
|
||||
gp_Vec vec1(dir1);
|
||||
vec1 *= cer.Radius();
|
||||
#ifdef DEB
|
||||
gp_Pnt p1 =
|
||||
#endif
|
||||
CenterPoint.Translated(vec1);
|
||||
gp_Vec vec2(dir2);
|
||||
vec2 *= cer.Radius();
|
||||
gp_Pnt p2 = CenterPoint.Translated(vec2);
|
||||
|
||||
Standard_Real uc1 = 0.;
|
||||
Standard_Real uc2 = ElCLib::Parameter(cer,p2);
|
||||
Standard_Real uco = ElCLib::Parameter(cer,OffsetPoint);
|
||||
|
||||
Standard_Real udeb = uc1;
|
||||
Standard_Real ufin = uc2;
|
||||
|
||||
if (uco > ufin) {
|
||||
if (Abs(theval)<PI) {
|
||||
// test si uco est dans le secteur oppose
|
||||
if (uco > udeb+PI && uco < ufin+PI){
|
||||
udeb = udeb + PI;
|
||||
ufin = ufin + PI;
|
||||
uc1 = udeb;
|
||||
uc2 = ufin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uco > ufin) {
|
||||
if ((uco-uc2) < (uc1-uco+(2*PI))) {
|
||||
ufin = uco;
|
||||
}
|
||||
else {
|
||||
udeb = uco - 2*PI;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real alpha = Abs(ufin-udeb);
|
||||
Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / PI));
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint);
|
||||
|
||||
gp_Vec vecarr;
|
||||
gp_Pnt ptarr;
|
||||
ElCLib::D1(uc1,cer,ptarr,vecarr);
|
||||
gp_Ax1 ax1(ptarr, axisdir);
|
||||
gp_Dir dirarr(-vecarr);
|
||||
//calcul de l'angle de rotation
|
||||
Standard_Real beta(0.);
|
||||
Standard_Real length = LA->ArrowAspect()->Length();
|
||||
if (length < Precision::Confusion()) length = 1.e-04;
|
||||
gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ());
|
||||
Standard_Real parcir = ElCLib::Parameter(cer, ptarr2);
|
||||
gp_Pnt ptarr3 = ElCLib::Value(parcir, cer);
|
||||
gp_Vec v1(ptarr,ptarr2 );
|
||||
gp_Vec v2(ptarr, ptarr3);
|
||||
beta = v1.Angle(v2);
|
||||
dirarr.Rotate(ax1, beta);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
dirarr,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
Vrap(1).SetCoord(AttachmentPoint1.X(),
|
||||
AttachmentPoint1.Y(),
|
||||
AttachmentPoint1.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
|
||||
ElCLib::D1(uc2,cer,ptarr,vecarr);
|
||||
ax1.SetLocation(ptarr);
|
||||
gp_Dir dirarr2(vecarr);
|
||||
dirarr2.Rotate(ax1,-beta);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
dirarr2,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
|
||||
Vrap(1).SetCoord(AttachmentPoint2.X(),
|
||||
AttachmentPoint2.Y(),
|
||||
AttachmentPoint2.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_AnglePresentation::Add
|
||||
// purpose : Adds prezentation of angle between two faces
|
||||
//==========================================================================
|
||||
|
||||
void DsgPrs_AnglePresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const gp_Dir& axisdir,
|
||||
const Standard_Boolean isPlane,
|
||||
const gp_Ax1& AxisOfSurf,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const DsgPrs_ArrowSide ArrowPrs )
|
||||
{
|
||||
char valcar[80];
|
||||
sprintf( valcar, "%5.2f", theval );
|
||||
|
||||
Handle( Prs3d_AngleAspect ) LA = aDrawer->AngleAspect();
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
|
||||
|
||||
gp_Circ AngleCirc, AttachCirc;
|
||||
Standard_Real FirstParAngleCirc, LastParAngleCirc, FirstParAttachCirc, LastParAttachCirc;
|
||||
gp_Pnt EndOfArrow1, EndOfArrow2, ProjAttachPoint2;
|
||||
gp_Dir DirOfArrow1, DirOfArrow2;
|
||||
DsgPrs::ComputeFacesAnglePresentation( LA->ArrowAspect()->Length(),
|
||||
theval,
|
||||
CenterPoint,
|
||||
AttachmentPoint1,
|
||||
AttachmentPoint2,
|
||||
dir1,
|
||||
dir2,
|
||||
axisdir,
|
||||
isPlane,
|
||||
AxisOfSurf,
|
||||
OffsetPoint,
|
||||
AngleCirc,
|
||||
FirstParAngleCirc,
|
||||
LastParAngleCirc,
|
||||
EndOfArrow1,
|
||||
EndOfArrow2,
|
||||
DirOfArrow1,
|
||||
DirOfArrow2,
|
||||
ProjAttachPoint2,
|
||||
AttachCirc,
|
||||
FirstParAttachCirc,
|
||||
LastParAttachCirc );
|
||||
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
|
||||
// Creating the angle's arc or line if null angle
|
||||
if (theval > Precision::Angular() && Abs( PI-theval ) > Precision::Angular())
|
||||
{
|
||||
Standard_Real Alpha = Abs( LastParAngleCirc - FirstParAngleCirc );
|
||||
Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / PI));
|
||||
Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 );
|
||||
Standard_Real delta = Alpha / (Standard_Real)( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 0 ; i < NodeNumber; i++)
|
||||
{
|
||||
CurPnt = ElCLib::Value( FirstParAngleCirc, AngleCirc );
|
||||
ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
FirstParAngleCirc += delta ;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc );
|
||||
}
|
||||
else // null angle
|
||||
{
|
||||
Vrap(1).SetCoord( OffsetPoint.X(),
|
||||
OffsetPoint.Y(),
|
||||
OffsetPoint.Z());
|
||||
Vrap(2).SetCoord( EndOfArrow1.X(), EndOfArrow1.Y(), EndOfArrow1.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap );
|
||||
}
|
||||
|
||||
// Add presentation of arrows
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow1, EndOfArrow2, DirOfArrow1, DirOfArrow2, ArrowPrs );
|
||||
|
||||
// Drawing the text
|
||||
Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, OffsetPoint );
|
||||
|
||||
// Line from AttachmentPoint1 to end of Arrow1
|
||||
Vrap(1).SetCoord(AttachmentPoint1.X(),
|
||||
AttachmentPoint1.Y(),
|
||||
AttachmentPoint1.Z());
|
||||
Vrap(2).SetCoord( EndOfArrow1.X(), EndOfArrow1.Y(), EndOfArrow1.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap );
|
||||
|
||||
// Line or arc from AttachmentPoint2 to its "projection"
|
||||
if (AttachmentPoint2.Distance( ProjAttachPoint2 ) > Precision::Confusion())
|
||||
{
|
||||
if (isPlane)
|
||||
{
|
||||
// Creating the line from AttachmentPoint2 to its projection
|
||||
Vrap(1).SetCoord( AttachmentPoint2.X(),
|
||||
AttachmentPoint2.Y(),
|
||||
AttachmentPoint2.Z() );
|
||||
Vrap(2).SetCoord( ProjAttachPoint2.X(),
|
||||
ProjAttachPoint2.Y(),
|
||||
ProjAttachPoint2.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Creating the arc from AttachmentPoint2 to its "projection"
|
||||
Standard_Real Alpha = Abs( LastParAttachCirc - FirstParAttachCirc );
|
||||
Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / PI));
|
||||
Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 );
|
||||
Standard_Real delta = Alpha / (Standard_Real)( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 0 ; i < NodeNumber; i++)
|
||||
{
|
||||
CurPnt = ElCLib::Value( FirstParAttachCirc, AttachCirc );
|
||||
ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
FirstParAttachCirc += delta ;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc );
|
||||
}
|
||||
}
|
||||
// Line from "projection" of AttachmentPoint2 to end of Arrow2
|
||||
Vrap(1).SetCoord( ProjAttachPoint2.X(),
|
||||
ProjAttachPoint2.Y(),
|
||||
ProjAttachPoint2.Z() );
|
||||
Vrap(2).SetCoord( EndOfArrow2.X(), EndOfArrow2.Y(), EndOfArrow2.Z());
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap );
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_AnglePresentation::Add
|
||||
// purpose :
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const gp_Pnt& OffsetPoint) {
|
||||
char valcar[80];
|
||||
sprintf(valcar,"%5.2f",theval);
|
||||
|
||||
Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Dir Norm;
|
||||
if (!dir1.IsParallel(dir2, Precision::Angular())) {
|
||||
Norm = dir1.Crossed(dir2);
|
||||
}
|
||||
else {
|
||||
gp_Dir dir2B = gp_Dir(gp_Vec(CenterPoint, OffsetPoint));
|
||||
Norm = dir1.Crossed(dir2B);
|
||||
}
|
||||
|
||||
if (Abs(theval) > PI) Norm.Reverse();
|
||||
|
||||
gp_Ax2 ax(CenterPoint,Norm,dir1);
|
||||
gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint));
|
||||
gp_Vec vec1(dir1);
|
||||
vec1 *= cer.Radius();
|
||||
#ifdef DEB
|
||||
gp_Pnt p1 =
|
||||
#endif
|
||||
CenterPoint.Translated(vec1);
|
||||
gp_Vec vec2(dir2);
|
||||
vec2 *= cer.Radius();
|
||||
gp_Pnt p2 = CenterPoint.Translated(vec2);
|
||||
|
||||
Standard_Real uc1 = 0.;
|
||||
Standard_Real uc2 = ElCLib::Parameter(cer,p2);
|
||||
Standard_Real uco = ElCLib::Parameter(cer,OffsetPoint);
|
||||
|
||||
Standard_Real udeb = uc1;
|
||||
Standard_Real ufin = uc2;
|
||||
|
||||
if (uco > ufin) {
|
||||
if (Abs(theval)<PI) {
|
||||
// test si uco est dans le secteur oppose
|
||||
if (uco > udeb+PI && uco < ufin+PI){
|
||||
udeb = udeb + PI;
|
||||
ufin = ufin + PI;
|
||||
uc1 = udeb;
|
||||
uc2 = ufin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uco > ufin) {
|
||||
if ((uco-uc2) < (uc1-uco+(2*PI))) {
|
||||
ufin = uco;
|
||||
}
|
||||
else {
|
||||
udeb = uco - 2*PI;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real alpha = Abs(ufin-udeb);
|
||||
Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / PI));
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint);
|
||||
|
||||
gp_Vec vecarr;
|
||||
gp_Pnt ptarr;
|
||||
ElCLib::D1(uc1,cer,ptarr,vecarr);
|
||||
gp_Ax1 ax1(ptarr, Norm);
|
||||
gp_Dir dirarr(-vecarr);
|
||||
//calcul de l'angle de rotation
|
||||
Standard_Real beta;
|
||||
Standard_Real length = LA->ArrowAspect()->Length();
|
||||
if (length < Precision::Confusion()) length = 1.e-04;
|
||||
gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ());
|
||||
Standard_Real parcir = ElCLib::Parameter(cer, ptarr2);
|
||||
gp_Pnt ptarr3 = ElCLib::Value(parcir, cer);
|
||||
gp_Vec v1(ptarr,ptarr2 );
|
||||
gp_Vec v2(ptarr, ptarr3);
|
||||
beta = v1.Angle(v2);
|
||||
dirarr.Rotate(ax1, beta);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
dirarr,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
Vrap(1).SetCoord(AttachmentPoint1.X(),
|
||||
AttachmentPoint1.Y(),
|
||||
AttachmentPoint1.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
|
||||
ElCLib::D1(uc2,cer,ptarr,vecarr);
|
||||
ax1.SetLocation(ptarr);
|
||||
gp_Dir dirarr2(vecarr);
|
||||
dirarr2.Rotate(ax1, - beta);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
dirarr2,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
|
||||
Vrap(1).SetCoord(AttachmentPoint2.X(),
|
||||
AttachmentPoint2.Y(),
|
||||
AttachmentPoint2.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_AnglePresentation::Add
|
||||
// purpose : ODL 4-fevrier-97
|
||||
// on peut choisir le symbol des extremites de la cote (fleche, point ...)
|
||||
//==========================================================================
|
||||
|
||||
void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
char valcar[80];
|
||||
sprintf(valcar,"%5.2f",theval);
|
||||
|
||||
Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Dir Norm = dir1.Crossed(dir2);
|
||||
|
||||
if (Abs(theval) > PI) Norm.Reverse();
|
||||
|
||||
gp_Ax2 ax(CenterPoint,Norm,dir1);
|
||||
gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint));
|
||||
gp_Vec vec1(dir1);
|
||||
vec1 *= cer.Radius();
|
||||
#ifdef DEB
|
||||
gp_Pnt p1 =
|
||||
#endif
|
||||
CenterPoint.Translated(vec1);
|
||||
gp_Vec vec2(dir2);
|
||||
vec2 *= cer.Radius();
|
||||
gp_Pnt p2 = CenterPoint.Translated(vec2);
|
||||
|
||||
Standard_Real uc1 = 0.;
|
||||
Standard_Real uc2 = ElCLib::Parameter(cer,p2);
|
||||
Standard_Real uco = ElCLib::Parameter(cer,OffsetPoint);
|
||||
|
||||
Standard_Real udeb = uc1;
|
||||
Standard_Real ufin = uc2;
|
||||
|
||||
if (uco > ufin) {
|
||||
if (Abs(theval)<PI) {
|
||||
// test si uco est dans le secteur oppose
|
||||
if (uco > udeb+PI && uco < ufin+PI){
|
||||
udeb = udeb + PI;
|
||||
ufin = ufin + PI;
|
||||
uc1 = udeb;
|
||||
uc2 = ufin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uco > ufin) {
|
||||
if ((uco-uc2) < (uc1-uco+(2*PI))) {
|
||||
ufin = uco;
|
||||
}
|
||||
else {
|
||||
udeb = uco - 2*PI;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real alpha = Abs(ufin-udeb);
|
||||
Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / PI));
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint);
|
||||
|
||||
// Lignes de rappel
|
||||
gp_Vec vecarr;
|
||||
gp_Pnt ptarr;
|
||||
ElCLib::D1(uc1,cer,ptarr,vecarr);
|
||||
gp_Ax1 ax1(ptarr, Norm);
|
||||
gp_Dir dirarr(-vecarr);
|
||||
//calcul de l'angle de rotation
|
||||
Standard_Real beta(0.);
|
||||
Standard_Real length = LA->ArrowAspect()->Length();
|
||||
if (length < Precision::Confusion()) length = 1.e-04;
|
||||
gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ());
|
||||
Standard_Real parcir = ElCLib::Parameter(cer, ptarr2);
|
||||
gp_Pnt ptarr3 = ElCLib::Value(parcir, cer);
|
||||
gp_Vec v1(ptarr,ptarr2 );
|
||||
gp_Vec v2(ptarr, ptarr3);
|
||||
beta = v1.Angle(v2);
|
||||
dirarr.Rotate(ax1, beta);
|
||||
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
Vrap(1).SetCoord(AttachmentPoint1.X(),
|
||||
AttachmentPoint1.Y(),
|
||||
AttachmentPoint1.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
|
||||
gp_Vec vecarr1;
|
||||
gp_Pnt ptarr1;
|
||||
ElCLib::D1(uc2,cer,ptarr1,vecarr1);
|
||||
ax1.SetLocation(ptarr1);
|
||||
gp_Dir dirarr2(vecarr1);
|
||||
dirarr2.Rotate(ax1, - beta);
|
||||
|
||||
|
||||
Vrap(1).SetCoord(AttachmentPoint2.X(),
|
||||
AttachmentPoint2.Y(),
|
||||
AttachmentPoint2.Z());
|
||||
Vrap(2).SetCoord(ptarr1.X(),ptarr1.Y(),ptarr1.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
|
||||
|
||||
// On trace les fleches
|
||||
DsgPrs::ComputeSymbol(aPresentation,LA,ptarr,ptarr1,dirarr,dirarr2,ArrowPrs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_AnglePresentation::Add
|
||||
// purpose :
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& dir1,
|
||||
const gp_Dir& dir2,
|
||||
const gp_Pnt& OffsetPoint) {
|
||||
|
||||
|
||||
char valcar[80];
|
||||
sprintf(valcar,"%5.2f",theval);
|
||||
TCollection_AsciiString valas(valcar);
|
||||
TCollection_ExtendedString aText(valas);
|
||||
|
||||
Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Dir Norm = dir1.Crossed(dir2);
|
||||
|
||||
if (Abs(theval) > PI) Norm.Reverse();
|
||||
|
||||
gp_Ax2 ax(CenterPoint,Norm,dir1);
|
||||
gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint));
|
||||
gp_Vec vec1(dir1);
|
||||
vec1 *= cer.Radius();
|
||||
#ifdef DEB
|
||||
gp_Pnt p1 =
|
||||
#endif
|
||||
CenterPoint.Translated(vec1);
|
||||
gp_Vec vec2(dir2);
|
||||
vec2 *= cer.Radius();
|
||||
gp_Pnt p2 = CenterPoint.Translated(vec2);
|
||||
|
||||
Standard_Real uc1 = 0.;
|
||||
Standard_Real uc2 = ElCLib::Parameter(cer,p2);
|
||||
Standard_Real uco = ElCLib::Parameter(cer,OffsetPoint);
|
||||
|
||||
Standard_Real udeb = uc1;
|
||||
Standard_Real ufin = uc2;
|
||||
|
||||
if (uco > ufin) {
|
||||
if (Abs(theval)<PI) {
|
||||
// test si uco est dans le secteur oppose
|
||||
if (uco > udeb+PI && uco < ufin+PI){
|
||||
udeb = udeb + PI;
|
||||
ufin = ufin + PI;
|
||||
uc1 = udeb;
|
||||
uc2 = ufin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uco > ufin) {
|
||||
if ((uco-uc2) < (uc1-uco+(2*PI))) {
|
||||
ufin = uco;
|
||||
}
|
||||
else {
|
||||
udeb = uco - 2*PI;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real alpha = Abs(ufin-udeb);
|
||||
Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / PI));
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint);
|
||||
|
||||
gp_Vec vecarr;
|
||||
gp_Pnt ptarr;
|
||||
ElCLib::D1(uc1,cer,ptarr,vecarr);
|
||||
gp_Ax1 ax1(ptarr, Norm);
|
||||
gp_Dir dirarr(-vecarr);
|
||||
//calcul de l'angle de rotation
|
||||
Standard_Real beta;
|
||||
Standard_Real length = LA->ArrowAspect()->Length();
|
||||
if (length < Precision::Confusion()) length = 1.e-04;
|
||||
gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ());
|
||||
Standard_Real parcir = ElCLib::Parameter(cer, ptarr2);
|
||||
gp_Pnt ptarr3 = ElCLib::Value(parcir, cer);
|
||||
gp_Vec v1(ptarr,ptarr2 );
|
||||
gp_Vec v2(ptarr, ptarr3);
|
||||
beta = v1.Angle(v2);
|
||||
dirarr.Rotate(ax1, beta);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
dirarr,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
Vrap(1).SetCoord(AttachmentPoint1.X(),
|
||||
AttachmentPoint1.Y(),
|
||||
AttachmentPoint1.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
|
||||
ElCLib::D1(uc2,cer,ptarr,vecarr);
|
||||
ax1.SetLocation(ptarr);
|
||||
gp_Dir dirarr2(vecarr);
|
||||
dirarr2.Rotate(ax1, - beta);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
dirarr2,
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
|
||||
Vrap(1).SetCoord(AttachmentPoint2.X(),
|
||||
AttachmentPoint2.Y(),
|
||||
AttachmentPoint2.Z());
|
||||
Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
}
|
||||
|
||||
void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const gp_Pnt& CenterPoint,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Ax1& theAxe,
|
||||
const DsgPrs_ArrowSide ArrowSide)
|
||||
{
|
||||
Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Dir dir1(gp_Vec(CenterPoint, AttachmentPoint1));
|
||||
gp_Ax2 ax(CenterPoint,theAxe.Direction(),dir1);
|
||||
gp_Circ cer(ax,CenterPoint.Distance(AttachmentPoint1));
|
||||
|
||||
Standard_Integer nbp = Max (4 , Standard_Integer (50. * theval / PI));
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = theval/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(dteta*(i-1),cer);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Standard_Real uc1 = 0.;
|
||||
Standard_Real uc2 = ElCLib::Parameter(cer,AttachmentPoint1.Rotated(theAxe,theval));
|
||||
|
||||
gp_Vec vecarr;
|
||||
gp_Pnt ptarr;
|
||||
Standard_Real length = LA->ArrowAspect()->Length();
|
||||
if (length < Precision::Confusion()) length = 1.e-04;
|
||||
|
||||
switch(ArrowSide) {
|
||||
case DsgPrs_AS_NONE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_FIRSTAR:
|
||||
{
|
||||
ElCLib::D1(uc1,cer,ptarr,vecarr);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
gp_Dir(-vecarr),
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_LASTAR:
|
||||
{
|
||||
ElCLib::D1(uc2,cer,ptarr,vecarr);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
gp_Dir(vecarr),
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
break;
|
||||
}
|
||||
case DsgPrs_AS_BOTHAR:
|
||||
{
|
||||
ElCLib::D1(uc1,cer,ptarr,vecarr);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
gp_Dir(-vecarr),
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
ElCLib::D1(uc2,cer,ptarr,vecarr);
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
ptarr,
|
||||
gp_Dir(vecarr),
|
||||
LA->ArrowAspect()->Angle(),
|
||||
length);
|
||||
break;
|
||||
}
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
56
src/DsgPrs/DsgPrs_Chamf2dPresentation.cdl
Executable file
56
src/DsgPrs/DsgPrs_Chamf2dPresentation.cdl
Executable file
@@ -0,0 +1,56 @@
|
||||
-- File: DsgPrs_Chamf2dPresentation.cdl
|
||||
-- Created: Tue Mar 19 18:37:53 1996
|
||||
-- Author: Flore Lantheaume
|
||||
-- <fla@filax>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
class Chamf2dPresentation from DsgPrs
|
||||
|
||||
---Purpose: Framework for display of 2D chamfers.
|
||||
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp,
|
||||
ArrowSide from DsgPrs,
|
||||
ExtendedString from TCollection
|
||||
|
||||
|
||||
is
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aPntAttach : Pnt from gp;
|
||||
aPntEnd : Pnt from gp;
|
||||
aText : ExtendedString from TCollection);
|
||||
|
||||
---Purpose: Defines the display of elements showing 2D chamfers on shapes.
|
||||
-- These include the text aText, the point of attachment,
|
||||
-- aPntAttach and the end point aPntEnd.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aPntAttach : Pnt from gp;
|
||||
aPntEnd : Pnt from gp;
|
||||
aText : ExtendedString from TCollection;
|
||||
ArrowSide : ArrowSide from DsgPrs);
|
||||
|
||||
---Purpose: Defines the display of texts, symbols and icons used
|
||||
-- to present 2D chamfers.
|
||||
-- These include the text aText, the point of attachment,
|
||||
-- aPntAttach and the end point aPntEnd.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer. The arrow
|
||||
-- at the point of attachment has a display defined by a
|
||||
-- value of the enumeration DsgPrs_Arrowside.
|
||||
|
||||
end Chamf2dPresentation;
|
89
src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx
Executable file
89
src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx
Executable file
@@ -0,0 +1,89 @@
|
||||
// File: DsgPrs_Chamf2dPresentation.cxx
|
||||
// Created: Tue Mar 19 18:45:13 1996
|
||||
// Author: Flore Lantheaume
|
||||
// <fla@filax>
|
||||
|
||||
|
||||
#include <DsgPrs_Chamf2dPresentation.ixx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <DsgPrs.hxx>
|
||||
|
||||
void DsgPrs_Chamf2dPresentation::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aPntAttach,
|
||||
const gp_Pnt& aPntEnd,
|
||||
const TCollection_ExtendedString& aText)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)
|
||||
->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
V(1).SetCoord(aPntAttach.X(),aPntAttach.Y(),aPntAttach.Z());
|
||||
|
||||
V(2).SetCoord(aPntEnd.X(),aPntEnd.Y(),aPntEnd.Z());
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ());
|
||||
Prs3d_Arrow::Draw(aPresentation,
|
||||
aPntAttach,
|
||||
ArrowDir,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntEnd);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_Chamf2dPresentation::Add
|
||||
// purpose : ODL 4-fevrier-97
|
||||
// on peut choisir le symbol des extremites de la cote (fleche, point ...)
|
||||
//==========================================================================
|
||||
|
||||
void DsgPrs_Chamf2dPresentation::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aPntAttach,
|
||||
const gp_Pnt& aPntEnd,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)
|
||||
->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
V(1).SetCoord(aPntAttach.X(),aPntAttach.Y(),aPntAttach.Z());
|
||||
|
||||
V(2).SetCoord(aPntEnd.X(),aPntEnd.Y(),aPntEnd.Z());
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntEnd);
|
||||
|
||||
gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ());
|
||||
|
||||
gp_Dir ArrowDir1 = ArrowDir;
|
||||
ArrowDir1.Reverse();
|
||||
|
||||
DsgPrs::ComputeSymbol(aPresentation,LA,aPntEnd,aPntAttach,ArrowDir1,ArrowDir,ArrowPrs);
|
||||
|
||||
|
||||
}
|
38
src/DsgPrs/DsgPrs_ConcentricPresentation.cdl
Executable file
38
src/DsgPrs/DsgPrs_ConcentricPresentation.cdl
Executable file
@@ -0,0 +1,38 @@
|
||||
-- File: DsgPrs_ConcentricPresentation.cdl
|
||||
-- Created: Mon Mar 18 16:33:30 1996
|
||||
-- Author: Flore Lantheaume
|
||||
-- <fla@filax>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
class ConcentricPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to define display of relations of concentricity.
|
||||
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d
|
||||
|
||||
is
|
||||
|
||||
Add (myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aCenter: Pnt from gp;
|
||||
aRadius : Real from Standard;
|
||||
aNorm : Dir from gp;
|
||||
aPoint : Pnt from gp);
|
||||
|
||||
---Purpose: Defines the display of elements showing relations of
|
||||
-- concentricity between shapes.
|
||||
-- These include the center aCenter, the radius
|
||||
-- aRadius, the direction aNorm and the point aPoint.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
|
||||
end ConcentricPresentation;
|
95
src/DsgPrs/DsgPrs_ConcentricPresentation.cxx
Executable file
95
src/DsgPrs/DsgPrs_ConcentricPresentation.cxx
Executable file
@@ -0,0 +1,95 @@
|
||||
// File: DsgPrs_ConcentricPresentation.cxx
|
||||
// Created: Mon Mar 18 16:40:07 1996
|
||||
// Author: Flore Lantheaume
|
||||
// <fla@filax>
|
||||
|
||||
|
||||
#include <DsgPrs_ConcentricPresentation.ixx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
void DsgPrs_ConcentricPresentation::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aCenter,
|
||||
const Standard_Real aRadius,
|
||||
const gp_Dir& aNorm,
|
||||
const gp_Pnt& aPoint)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
|
||||
//Creation et discretisation du plus gros cercle
|
||||
gp_Circ Circ(gp_Ax2(aCenter,aNorm), aRadius);
|
||||
Standard_Integer nbp = 50;
|
||||
Standard_Real dteta = (2 * PI)/nbp;
|
||||
Graphic3d_Array1OfVertex V(1,nbp+1);
|
||||
gp_Pnt ptcur;
|
||||
Standard_Real ucur = 0;
|
||||
Standard_Integer i ;
|
||||
for ( i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(ucur, Circ);
|
||||
V(i).SetCoord(ptcur.X(), ptcur.Y(),ptcur.Z());
|
||||
ucur = ucur + dteta;
|
||||
}
|
||||
V(nbp+1).SetCoord( V(1).X(), V(1).Y(), V(1).Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)
|
||||
->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
//Creation et discretisation du plus petit cercle
|
||||
Circ.SetRadius(aRadius/2);
|
||||
ucur = 0;
|
||||
for ( i = 1; i<=nbp; i++) {
|
||||
ptcur = ElCLib::Value(ucur, Circ);
|
||||
V(i).SetCoord(ptcur.X(), ptcur.Y(),ptcur.Z());
|
||||
ucur = ucur + dteta;
|
||||
}
|
||||
V(nbp+1).SetCoord( V(1).X(), V(1).Y(), V(1).Z());
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)
|
||||
->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
//Creation de la croix
|
||||
//1er segment
|
||||
gp_Dir vecnorm(aPoint.XYZ() - aCenter.XYZ() );
|
||||
gp_Vec vec(vecnorm);
|
||||
vec.Multiply(aRadius);
|
||||
gp_Pnt p1 = aCenter.Translated(vec);
|
||||
gp_Pnt p2 = aCenter.Translated(-vec);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->
|
||||
SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Graphic3d_Array1OfVertex VExt(1,2);
|
||||
VExt(1).SetCoord(p1.X(), p1.Y(), p1.Z());
|
||||
VExt(2).SetCoord(p2.X(), p2.Y(), p2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VExt);
|
||||
|
||||
//2ieme segment
|
||||
vec.Cross(aNorm);
|
||||
vecnorm.SetCoord(vec.X(), vec.Y(), vec.Z() );
|
||||
vec.SetXYZ(vecnorm.XYZ());
|
||||
vec.Multiply(aRadius);
|
||||
p1 = aCenter.Translated(vec);
|
||||
p2 = aCenter.Translated(-vec);
|
||||
VExt(1).SetCoord(p1.X(), p1.Y(), p1.Z());
|
||||
VExt(2).SetCoord(p2.X(), p2.Y(), p2.Z());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->
|
||||
SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VExt);
|
||||
|
||||
}
|
17
src/DsgPrs/DsgPrs_DatumTool.cdl
Executable file
17
src/DsgPrs/DsgPrs_DatumTool.cdl
Executable file
@@ -0,0 +1,17 @@
|
||||
-- File: DsgPrs_DatumTool.cdl
|
||||
-- Created: Mon Oct 10 16:14:47 1994
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@houblon>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
class DatumTool from DsgPrs
|
||||
---Purpose: A generic framework for defining display of datums. Instantiates Prs3d_Datum.
|
||||
uses Ax2 from gp
|
||||
|
||||
is
|
||||
|
||||
Ax2 ( myclass; aDatum: Ax2 from gp ) returns Ax2 from gp;
|
||||
|
||||
end DatumTool from DsgPrs;
|
||||
|
||||
|
12
src/DsgPrs/DsgPrs_DatumTool.cxx
Executable file
12
src/DsgPrs/DsgPrs_DatumTool.cxx
Executable file
@@ -0,0 +1,12 @@
|
||||
// File: DsgPrs_DatumTool.cxx
|
||||
// Created: Mon Oct 10 16:16:29 1994
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
|
||||
#include <DsgPrs_DatumTool.ixx>
|
||||
|
||||
gp_Ax2 DsgPrs_DatumTool::Ax2(const gp_Ax2& ax)
|
||||
{
|
||||
return ax;
|
||||
}
|
59
src/DsgPrs/DsgPrs_DiameterPresentation.cdl
Executable file
59
src/DsgPrs/DsgPrs_DiameterPresentation.cdl
Executable file
@@ -0,0 +1,59 @@
|
||||
-- File: DsgPrs_DiameterPresentation.cdl
|
||||
-- Created: Wed Aug 21 15:29:40 1996
|
||||
-- Author: Jacques MINOT
|
||||
-- <jmi@anotax.paris1.matra-dtv.fr>
|
||||
-- modified 12-january-98 by Sergey ZARITCHNY
|
||||
-- <szy@orthodox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
class DiameterPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework for displaying diameters in shapes.
|
||||
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Circ from gp,
|
||||
Drawer from Prs3d,
|
||||
ArrowSide from DsgPrs,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aText : ExtendedString from TCollection;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
aCircle : Circ from gp;
|
||||
ArrowSide: ArrowSide from DsgPrs;
|
||||
IsDiamSymbol : Boolean from Standard );
|
||||
---Purpose: Draws the diameter of the circle aCircle displayed in
|
||||
-- the presentation aPresentation and with attributes
|
||||
-- defined by the attribute manager aDrawer. The point
|
||||
-- AttachmentPoint defines the point of contact
|
||||
-- between the circle and the diameter presentation.
|
||||
-- The value of the enumeration ArrowSide controls
|
||||
-- whether arrows will be displayed at either or both
|
||||
-- ends of the length. The text aText labels the diameter.
|
||||
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aText : ExtendedString from TCollection;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
aCircle : Circ from gp;
|
||||
uFirst : Real from Standard;
|
||||
uLast : Real from Standard;
|
||||
ArrowSide : ArrowSide from DsgPrs;
|
||||
IsDiamSymbol : Boolean from Standard);
|
||||
---Purpose: Draws the diameter of the arc anArc displayed in the
|
||||
-- presentation aPresentation and with attributes
|
||||
-- defined by the attribute manager aDrawer. The point
|
||||
-- AttachmentPoint defines the point of contact
|
||||
-- between the arc and the diameter presentation. The
|
||||
-- value of the enumeration ArrowSide controls whether
|
||||
-- arrows will be displayed at either or both ends of the
|
||||
-- length. The parameters uFirst and uLast define the
|
||||
-- first and last points of the arc. The text aText labels the diameter.
|
||||
|
||||
end DiameterPresentation;
|
223
src/DsgPrs/DsgPrs_DiameterPresentation.cxx
Executable file
223
src/DsgPrs/DsgPrs_DiameterPresentation.cxx
Executable file
@@ -0,0 +1,223 @@
|
||||
// Copyright: Matra-Datavision 1996
|
||||
// File: DsgPrs_DiameterPresentation.cxx
|
||||
// Created: Wed Aug 21 15:36:02 1996
|
||||
// Author: Jacques MINOT
|
||||
// <jmi>
|
||||
// modified 12-january-98
|
||||
// Sergey ZARITCHNY
|
||||
// <szy@androxx.nnov.matra-dtv.fr>
|
||||
// szy
|
||||
#include <DsgPrs_DiameterPresentation.ixx>
|
||||
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_DiameterPresentation::Add
|
||||
// purpose : ODL 4-fevrier-97
|
||||
// on peut choisir le symbol des extremites de la cote (fleche, point ...)
|
||||
//==========================================================================
|
||||
void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint,
|
||||
const gp_Circ& aCircle,
|
||||
const DsgPrs_ArrowSide ArrowPrs,
|
||||
const Standard_Boolean IsDiamSymbol )
|
||||
{
|
||||
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Standard_Real parat = ElCLib::Parameter(aCircle, AttachmentPoint);
|
||||
gp_Pnt ptoncirc = ElCLib::Value (parat, aCircle);
|
||||
|
||||
// ligne de cote
|
||||
|
||||
gp_Pnt center = aCircle.Location();
|
||||
gp_Vec vecrap (ptoncirc,center);
|
||||
|
||||
Standard_Real dist = center.Distance(AttachmentPoint);
|
||||
Standard_Real aRadius = aCircle.Radius();
|
||||
Standard_Boolean inside = Standard_False;
|
||||
|
||||
gp_Pnt pt1 = AttachmentPoint;
|
||||
if (dist < aRadius) {
|
||||
pt1 = ptoncirc;
|
||||
dist = aRadius;
|
||||
inside = Standard_True;
|
||||
}
|
||||
vecrap.Normalize();
|
||||
vecrap *= (dist+aRadius);
|
||||
gp_Pnt OppositePoint = pt1.Translated(vecrap);
|
||||
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
Quantity_Length X,Y,Z;
|
||||
pt1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
OppositePoint.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// value
|
||||
TCollection_ExtendedString Text = aText;
|
||||
if(IsDiamSymbol)
|
||||
Text = TCollection_ExtendedString("\330 ") + aText; // VRO (2007-05-17) inserted a blank.
|
||||
Prs3d_Text::Draw(aPresentation, LA->TextAspect(), Text, AttachmentPoint);
|
||||
|
||||
// arrows
|
||||
|
||||
gp_Dir arrdir (vecrap);
|
||||
if (inside) arrdir.Reverse();
|
||||
|
||||
|
||||
gp_Vec vecrap2 = vecrap;
|
||||
gp_Pnt ptoncirc2 = ptoncirc;
|
||||
gp_Dir arrdir2 = arrdir;
|
||||
vecrap2.Normalize();
|
||||
vecrap2 *= (aCircle.Radius() * 2.);
|
||||
ptoncirc2.Translate (vecrap2);
|
||||
arrdir2.Reverse();
|
||||
|
||||
DsgPrs::ComputeSymbol(aPresentation,LA,ptoncirc,ptoncirc2,arrdir,arrdir2,ArrowPrs);
|
||||
}
|
||||
|
||||
|
||||
static Standard_Boolean DsgPrs_InDomain(const Standard_Real fpar,
|
||||
const Standard_Real lpar,
|
||||
const Standard_Real para)
|
||||
{
|
||||
if (fpar >= 0.) {
|
||||
if(lpar > fpar)
|
||||
return ((para >= fpar) && (para <= lpar));
|
||||
else { // fpar > lpar
|
||||
Standard_Real delta = 2*PI-fpar;
|
||||
Standard_Real lp, par, fp;
|
||||
lp = lpar + delta;
|
||||
par = para + delta;
|
||||
while(lp > 2*PI) lp-=2*PI;
|
||||
while(par > 2*PI) par-=2*PI;
|
||||
fp = 0.;
|
||||
return ((par >= fp) && (par <= lp));
|
||||
}
|
||||
|
||||
}
|
||||
if (para >= (fpar+2*PI)) return Standard_True;
|
||||
if (para <= lpar) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DsgPrs_DiameterPresentation::Add
|
||||
//purpose : SZY 12-february-98
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint,
|
||||
const gp_Circ& aCircle,
|
||||
const Standard_Real uFirst,
|
||||
const Standard_Real uLast,
|
||||
const DsgPrs_ArrowSide ArrowPrs,//ArrowSide
|
||||
const Standard_Boolean IsDiamSymbol )
|
||||
{
|
||||
Standard_Real fpara = uFirst;
|
||||
Standard_Real lpara = uLast;
|
||||
while (lpara > 2*PI) {
|
||||
fpara -= 2*PI;
|
||||
lpara -= 2*PI;
|
||||
}
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
// Handle(Prs3d_TextAspect) TA = aDrawer->TextAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// AspectText3d from Graphic3d
|
||||
Standard_Real parEndOfArrow = ElCLib::Parameter(aCircle,AttachmentPoint); //
|
||||
gp_Pnt EndOfArrow;
|
||||
gp_Pnt DrawPosition = AttachmentPoint;// attachment point
|
||||
Standard_Boolean otherside = Standard_False;
|
||||
|
||||
gp_Pnt Center = aCircle.Location();
|
||||
gp_Pnt FirstPoint = ElCLib::Value(uFirst, aCircle);
|
||||
gp_Pnt SecondPoint = ElCLib::Value(uLast, aCircle);
|
||||
|
||||
if ( !DsgPrs_InDomain(fpara,lpara,parEndOfArrow)) {
|
||||
Standard_Real otherpar = parEndOfArrow + PI;// not in domain
|
||||
if (otherpar > 2*PI) otherpar -= 2*PI;
|
||||
if (DsgPrs_InDomain(fpara,lpara,otherpar)) {
|
||||
parEndOfArrow = otherpar; // parameter on circle
|
||||
EndOfArrow = ElCLib::Value(parEndOfArrow, aCircle);
|
||||
otherside = Standard_True;
|
||||
}
|
||||
else {
|
||||
gp_Dir dir1(gp_Vec(Center, FirstPoint));
|
||||
gp_Dir dir2(gp_Vec(Center, SecondPoint));
|
||||
gp_Lin L1( Center, dir1 );
|
||||
gp_Lin L2( Center, dir2 );
|
||||
if(L1.Distance(AttachmentPoint) < L2.Distance(AttachmentPoint))
|
||||
{
|
||||
EndOfArrow = FirstPoint; //***
|
||||
DrawPosition = ElCLib::Value(ElCLib::Parameter( L1, AttachmentPoint ), L1);
|
||||
}
|
||||
else
|
||||
{
|
||||
EndOfArrow = SecondPoint; //***
|
||||
DrawPosition = ElCLib::Value(ElCLib::Parameter( L2, AttachmentPoint ), L2);
|
||||
}
|
||||
}
|
||||
// EndOfArrow = ElCLib::Value(parEndOfArrow, aCircle);
|
||||
// DrawPosition = AttachmentPoint;
|
||||
}
|
||||
else {
|
||||
EndOfArrow = ElCLib::Value(parEndOfArrow, aCircle);
|
||||
DrawPosition = AttachmentPoint;
|
||||
}
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
DrawPosition.Coord(X,Y,Z);
|
||||
Vrap(1).SetCoord(X,Y,Z);
|
||||
|
||||
EndOfArrow.Coord(X,Y,Z);
|
||||
Vrap(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap);
|
||||
|
||||
// text
|
||||
TCollection_ExtendedString Text = aText;
|
||||
if(IsDiamSymbol)
|
||||
Text = TCollection_ExtendedString("\330 ") + Text;// => \330 | \370?
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),Text,DrawPosition);
|
||||
|
||||
// Add presentation of arrow
|
||||
gp_Dir DirOfArrow(gp_Vec(DrawPosition, EndOfArrow).XYZ());
|
||||
DsgPrs::ComputeSymbol(aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs);
|
||||
|
||||
}
|
65
src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cdl
Executable file
65
src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cdl
Executable file
@@ -0,0 +1,65 @@
|
||||
-- File: DsgPrs_EllipseRadiusPresentation.cdl
|
||||
-- Created: Mon Jan 26 09:41:13 1998
|
||||
-- Author: Sergey ZARITCHNY
|
||||
-- <szy@androx.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class EllipseRadiusPresentation from DsgPrs
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Elips from gp,
|
||||
OffsetCurve from Geom,
|
||||
Drawer from Prs3d,
|
||||
ArrowSide from DsgPrs,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
theval : Real from Standard;
|
||||
aText : ExtendedString from TCollection;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
anEndOfArrow : Pnt from gp;
|
||||
aCenter : Pnt from gp;
|
||||
IsMaxRadius : Boolean from Standard;
|
||||
ArrowSide: ArrowSide from DsgPrs);
|
||||
---Purpose: draws a Radius (Major or Minor)
|
||||
-- representation for whole ellipse case
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
theval : Real from Standard;
|
||||
aText : ExtendedString from TCollection;
|
||||
anEllipse : Elips from gp;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
anEndOfArrow : Pnt from gp;
|
||||
aCenter : Pnt from gp;
|
||||
uFirst : Real from Standard;
|
||||
IsInDomain : Boolean from Standard;
|
||||
IsMaxRadius : Boolean from Standard;
|
||||
ArrowSide : ArrowSide from DsgPrs);
|
||||
---Purpose: draws a Radius (Major or Minor) representation
|
||||
-- for arc of an ellipse case
|
||||
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
theval : Real from Standard;
|
||||
aText : ExtendedString from TCollection;
|
||||
aCurve : OffsetCurve from Geom;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
anEndOfArrow : Pnt from gp;
|
||||
aCenter : Pnt from gp;
|
||||
uFirst : Real from Standard;
|
||||
IsInDomain : Boolean from Standard;
|
||||
IsMaxRadius : Boolean from Standard;
|
||||
ArrowSide : ArrowSide from DsgPrs);
|
||||
---Purpose: draws a Radius (Major or Minor) representation
|
||||
-- for arc of an offset curve from ellipse
|
||||
|
||||
end EllipseRadiusPresentation;
|
199
src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx
Executable file
199
src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx
Executable file
@@ -0,0 +1,199 @@
|
||||
// File: DsgPrs_EllipseRadiusPresentation.cxx
|
||||
// Created: Mon Jan 26 09:59:22 1998
|
||||
// Author: Sergey ZARITCHNY
|
||||
// <szy@androx.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DsgPrs_EllipseRadiusPresentation.ixx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Elips.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <Geom_Ellipse.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
#include <Geom_OffsetCurve.hxx>
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString & aText,
|
||||
// const gp_Elips & anEllipse,
|
||||
const gp_Pnt & aPosition,
|
||||
const gp_Pnt & anEndOfArrow,
|
||||
const gp_Pnt & aCenter,
|
||||
const Standard_Boolean IsMaxRadius,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Standard_Boolean inside = Standard_False;
|
||||
// gp_Pnt EndPoint, EndOfArrow;
|
||||
gp_Pnt EndPoint;
|
||||
Standard_Real dist = aCenter.Distance( aPosition );
|
||||
if( dist > theval ) EndPoint = aPosition;
|
||||
else {
|
||||
EndPoint = anEndOfArrow;
|
||||
inside = Standard_True;
|
||||
}
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
Quantity_Length X,Y,Z;
|
||||
aCenter.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
EndPoint.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// value
|
||||
TCollection_ExtendedString Text;
|
||||
if(IsMaxRadius)
|
||||
Text = TCollection_ExtendedString("a = ");
|
||||
else
|
||||
Text = TCollection_ExtendedString("b = ");
|
||||
Text += aText;
|
||||
Prs3d_Text::Draw(aPresentation, LA->TextAspect(), Text, aPosition );
|
||||
|
||||
// arrows
|
||||
gp_Dir arrdir( gp_Vec( aCenter, anEndOfArrow));
|
||||
if (!inside) arrdir.Reverse();
|
||||
|
||||
DsgPrs::ComputeSymbol(aPresentation, LA, anEndOfArrow, anEndOfArrow, arrdir, arrdir, ArrowPrs );
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString & aText,
|
||||
const gp_Elips & anEllipse,
|
||||
const gp_Pnt & aPosition,
|
||||
const gp_Pnt & anEndOfArrow,
|
||||
const gp_Pnt & aCenter,
|
||||
const Standard_Real uFirst,
|
||||
const Standard_Boolean IsInDomain,
|
||||
const Standard_Boolean IsMaxRadius,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
if(!IsInDomain)
|
||||
{
|
||||
Standard_Real parFirst;
|
||||
Standard_Real uLast = ElCLib::Parameter ( anEllipse, anEndOfArrow );
|
||||
Standard_Real Alpha = DsgPrs::DistanceFromApex(anEllipse, anEndOfArrow, uFirst);//length of ellipse arc
|
||||
gp_Vec Vapex(aCenter, ElCLib::Value( uLast, anEllipse )) ;
|
||||
gp_Vec Vpnt(aCenter, ElCLib::Value( uFirst, anEllipse )) ;
|
||||
gp_Dir dir(Vpnt ^ Vapex);
|
||||
if(anEllipse.Position().Direction().IsOpposite( dir, Precision::Angular()))
|
||||
parFirst = uLast;
|
||||
else
|
||||
parFirst = uFirst;
|
||||
Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / PI));
|
||||
Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 );
|
||||
Standard_Real delta = Alpha / ( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 0 ; i < NodeNumber; i++)
|
||||
{
|
||||
CurPnt = ElCLib::Value( parFirst, anEllipse );
|
||||
ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
parFirst += delta ;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc );
|
||||
}
|
||||
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, aDrawer, theval, aText,
|
||||
aPosition, anEndOfArrow, aCenter, IsMaxRadius, ArrowPrs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : // for offset curve
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString & aText,
|
||||
const Handle(Geom_OffsetCurve) & aCurve,
|
||||
const gp_Pnt & aPosition,
|
||||
const gp_Pnt & anEndOfArrow,
|
||||
const gp_Pnt & aCenter,
|
||||
const Standard_Real uFirst,
|
||||
const Standard_Boolean IsInDomain,
|
||||
const Standard_Boolean IsMaxRadius,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
if(!IsInDomain)
|
||||
{
|
||||
Standard_Real parFirst;
|
||||
if(!aCurve->IsCN(1)) return ;
|
||||
gp_Elips aBEllipse = Handle(Geom_Ellipse)::DownCast(aCurve->BasisCurve ())->Elips();
|
||||
Standard_Real Offset = aCurve->Offset();
|
||||
aBEllipse.SetMajorRadius(aBEllipse.MajorRadius() + Offset);
|
||||
aBEllipse.SetMinorRadius(aBEllipse.MinorRadius() + Offset);
|
||||
Standard_Real uLast = ElCLib::Parameter ( aBEllipse, anEndOfArrow );
|
||||
Standard_Real Alpha = DsgPrs::DistanceFromApex(aBEllipse, anEndOfArrow, uFirst);//length of ellipse arc
|
||||
gp_Pnt p1;
|
||||
aCurve->D0(uFirst, p1);
|
||||
gp_Vec Vapex(aCenter, anEndOfArrow) ;
|
||||
gp_Vec Vpnt (aCenter, p1) ;
|
||||
gp_Dir dir(Vpnt ^ Vapex);
|
||||
if(aCurve->Direction().IsOpposite( dir, Precision::Angular()))
|
||||
parFirst = uLast;
|
||||
else
|
||||
parFirst = uFirst;
|
||||
Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / PI));
|
||||
Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 );
|
||||
Standard_Real delta = Alpha / ( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 0 ; i < NodeNumber; i++)
|
||||
{
|
||||
aCurve->D0( parFirst, CurPnt );
|
||||
ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
parFirst += delta ;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc );
|
||||
}
|
||||
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, aDrawer, theval, aText,
|
||||
aPosition, anEndOfArrow, aCenter, IsMaxRadius, ArrowPrs);
|
||||
|
||||
}
|
61
src/DsgPrs/DsgPrs_EqualDistancePresentation.cdl
Executable file
61
src/DsgPrs/DsgPrs_EqualDistancePresentation.cdl
Executable file
@@ -0,0 +1,61 @@
|
||||
-- File: DsgPrs_EqualDistancePresentation.cdl
|
||||
-- Created: Tue Jan 27 16:59:36 1998
|
||||
-- Author: Julia GERASIMOVA
|
||||
-- <jgv@velox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class EqualDistancePresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to display equal distances between shapes and a given plane.
|
||||
-- The distance is the length of a projection from the shape to the plane.
|
||||
-- These distances are used to compare two shapes by this vector alone.
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Plane from Geom,
|
||||
ArrowSide from DsgPrs,
|
||||
Circ from gp
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
Point1 : Pnt from gp;
|
||||
Point2 : Pnt from gp;
|
||||
Point3 : Pnt from gp;
|
||||
Point4 : Pnt from gp;
|
||||
Plane : Plane from Geom );
|
||||
---Purpose: Adds the points Point1, Point2, Point3 Point4, and the
|
||||
-- plane Plane to the presentation object aPresentation.
|
||||
-- The display attributes of these elements is defined by the attribute manager aDrawer.
|
||||
-- The distance is the length of a projection from the shape to the plane.
|
||||
-- These distances are used to compare two shapes by this vector alone.
|
||||
|
||||
AddInterval( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aPoint1 : Pnt from gp;
|
||||
aPoint2 : Pnt from gp;
|
||||
aDir : Dir from gp;
|
||||
aPosition : Pnt from gp;
|
||||
anArrowSide : ArrowSide from DsgPrs;
|
||||
anExtremePnt1 : out Pnt from gp;
|
||||
anExtremePnt2 : out Pnt from gp);
|
||||
---Purpose: is used for presentation of interval between
|
||||
-- two lines or two points or between a line and a point.
|
||||
|
||||
AddIntervalBetweenTwoArcs( myclass;aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aCircle1 : Circ from gp;
|
||||
aCircle2 : Circ from gp;
|
||||
aPoint1 : Pnt from gp;
|
||||
aPoint2 : Pnt from gp;
|
||||
aPoint3 : Pnt from gp;
|
||||
aPoint4 : Pnt from gp;
|
||||
anArrowSide : ArrowSide from DsgPrs);
|
||||
---Purpose:is used for presentation of interval between two arcs.
|
||||
-- One of arcs can have a zero radius.
|
||||
|
||||
end EqualDistancePresentation;
|
259
src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx
Executable file
259
src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx
Executable file
@@ -0,0 +1,259 @@
|
||||
// File: DsgPrs_EqualDistancePresentation.cxx
|
||||
// Created: Tue Jan 27 17:05:12 1998
|
||||
// Author: Julia GERASIMOVA
|
||||
// <jgv@velox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DsgPrs_EqualDistancePresentation.ixx>
|
||||
|
||||
#include <DsgPrs.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
|
||||
//=================================================================================
|
||||
//function : Add
|
||||
//=================================================================================
|
||||
void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& aPresentation,
|
||||
const Handle( Prs3d_Drawer )& aDrawer,
|
||||
const gp_Pnt& Point1,
|
||||
const gp_Pnt& Point2,
|
||||
const gp_Pnt& Point3,
|
||||
const gp_Pnt& Point4,
|
||||
const Handle( Geom_Plane )& Plane )
|
||||
{
|
||||
Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
|
||||
|
||||
Graphic3d_Array1OfVertex VertexArray( 1, 2 );
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
// Line between two middles
|
||||
gp_Pnt Middle12( (Point1.XYZ() + Point2.XYZ()) * 0.5 ), Middle34( (Point3.XYZ() + Point4.XYZ()) * 0.5 );
|
||||
|
||||
Middle12.Coord( X, Y, Z );
|
||||
VertexArray( 1 ).SetCoord( X, Y, Z );
|
||||
Middle34.Coord( X, Y, Z );
|
||||
VertexArray( 2 ).SetCoord( X, Y, Z );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
// Add presentation of arrows (points)
|
||||
gp_Dir aDir( 0, 0, 1 );
|
||||
DsgPrs::ComputeSymbol(aPresentation, LA,
|
||||
Middle12, Middle34,
|
||||
aDir, aDir,
|
||||
DsgPrs_AS_BOTHPT );
|
||||
// ota -- begin --
|
||||
// Two small lines in the middle of this line
|
||||
gp_Pnt Middle( (Middle12.XYZ() + Middle34.XYZ()) * 0.5 ), aTextPos;
|
||||
Standard_Real Dist = Middle12.Distance( Middle34 );
|
||||
Standard_Real SmallDist;
|
||||
gp_Dir LineDir, OrtDir;
|
||||
gp_Vec LineVec, OrtVec;
|
||||
|
||||
if (Dist > Precision::Confusion())
|
||||
{
|
||||
SmallDist = Dist * 0.05; // 1/20.0 part
|
||||
if (SmallDist <= Precision::Confusion())
|
||||
SmallDist = Dist;
|
||||
LineDir = gce_MakeDir( Middle12, Middle34 );
|
||||
OrtDir = Plane->Pln().Axis().Direction() ^ LineDir;
|
||||
LineVec = gp_Vec( LineDir ) * SmallDist;
|
||||
OrtVec = gp_Vec( OrtDir ) * SmallDist;
|
||||
|
||||
aTextPos = Middle.Translated( OrtVec );
|
||||
}
|
||||
else
|
||||
{
|
||||
gp_Vec Vec1( Middle, Point1 );
|
||||
|
||||
if (Vec1.SquareMagnitude() > Precision::Confusion()*Precision::Confusion())
|
||||
{
|
||||
Standard_Real Angle = gp_Vec( Middle, Point1 ).Angle( gp_Vec( Middle, Point3 ) );
|
||||
gp_Pnt MidPnt = Point1.Rotated( Plane->Pln().Axis(), Angle*0.5 );
|
||||
OrtDir = gce_MakeDir( Middle, MidPnt );
|
||||
LineDir = OrtDir ^ Plane->Pln().Axis().Direction();
|
||||
|
||||
Standard_Real Distance = Point1.Distance( Point2 );
|
||||
SmallDist = Distance * 0.05; // 1/20.0
|
||||
if (SmallDist <= Precision::Confusion())
|
||||
SmallDist = Distance;
|
||||
|
||||
OrtVec = gp_Vec( OrtDir ) * SmallDist;
|
||||
LineVec = gp_Vec( LineDir ) * SmallDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
SmallDist = 5.0;
|
||||
OrtVec = gp_Vec( Plane->Pln().XAxis().Direction() ) * SmallDist;
|
||||
LineVec = gp_Vec( Plane->Pln().YAxis().Direction() ) * SmallDist;
|
||||
}
|
||||
aTextPos = Middle.Translated (OrtVec);
|
||||
}
|
||||
|
||||
TCollection_ExtendedString aText("==");
|
||||
|
||||
//Draw the text
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(), aText, aTextPos);
|
||||
}
|
||||
|
||||
//==================================================================================
|
||||
//function : AddInterval
|
||||
//purpose : is used for presentation of interval between two lines or two points,
|
||||
// or between one line and one point.
|
||||
//==================================================================================
|
||||
void DsgPrs_EqualDistancePresentation::AddInterval(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aPoint1,
|
||||
const gp_Pnt& aPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& aPosition,
|
||||
const DsgPrs_ArrowSide anArrowSide,
|
||||
gp_Pnt& aProj1,
|
||||
gp_Pnt& aProj2)
|
||||
{
|
||||
const Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
//set color
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Lin L1 (aPoint1,aDirection);
|
||||
gp_Lin L2 (aPoint2,aDirection);
|
||||
aProj1 = ElCLib::Value(ElCLib::Parameter(L1, aPosition),L1);
|
||||
aProj2 = ElCLib::Value(ElCLib::Parameter(L2, aPosition),L2);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
aProj1.Coord (X, Y, Z);
|
||||
V(1).SetCoord(X, Y, Z);
|
||||
|
||||
aPoint1.Coord(X, Y, Z);
|
||||
V(2).SetCoord(X, Y, Z);
|
||||
|
||||
//add first attached line
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
//add distance interval
|
||||
aProj2.Coord(X, Y, Z);
|
||||
V(2).SetCoord(X, Y, Z);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
|
||||
//add second attached line
|
||||
aPoint2.Coord(X, Y, Z);
|
||||
V(1).SetCoord(X, Y, Z);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
//add arrows presentation
|
||||
gp_Dir aDir(aProj2.XYZ() - aProj1.XYZ());
|
||||
|
||||
DsgPrs::ComputeSymbol(aPresentation, LA,
|
||||
aProj1, aProj2,
|
||||
aDir.Reversed(), aDir,
|
||||
anArrowSide);
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// function : AddIntervalBetweenTwoArcs
|
||||
// purpose : is used for presentation of interval between two arcs. One
|
||||
// of the arcs can have a zero radius (being a point really)
|
||||
//========================================================================
|
||||
void
|
||||
DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Circ& aCirc1,
|
||||
const gp_Circ& aCirc2,
|
||||
const gp_Pnt& aPoint1,
|
||||
const gp_Pnt& aPoint2,
|
||||
const gp_Pnt& aPoint3,
|
||||
const gp_Pnt& aPoint4,
|
||||
const DsgPrs_ArrowSide anArrowSide)
|
||||
{
|
||||
//it seems to set color
|
||||
const Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Standard_Real aPar11, aPar12, aPar21, aPar22;
|
||||
if(aCirc1.Radius() > Precision::Confusion()){
|
||||
aPar11 = ElCLib::Parameter (aCirc1, aPoint1);
|
||||
aPar12 = ElCLib::Parameter(aCirc1, aPoint2);
|
||||
}
|
||||
else {
|
||||
aPar11 = PI;
|
||||
aPar12 = PI;
|
||||
}
|
||||
if (aCirc2.Radius() > Precision::Confusion()){
|
||||
aPar21 = ElCLib::Parameter(aCirc2, aPoint3 );
|
||||
aPar22 = ElCLib::Parameter(aCirc2, aPoint4);
|
||||
}
|
||||
else {
|
||||
aPar21 = PI;
|
||||
aPar22 = PI;
|
||||
}
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
V(1).SetCoord(aPoint2.X(), aPoint2.Y(), aPoint2.Z());
|
||||
V(2).SetCoord(aPoint4.X(), aPoint4.Y(), aPoint4.Z());
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( V );
|
||||
|
||||
Standard_Integer aNodeNb;
|
||||
Standard_Real aDelta, aCurPar;
|
||||
if(aPar12 < aPar11 ) aPar12 +=2*PI;
|
||||
if (Abs(aPar12 - aPar11) > Precision::Confusion()) {
|
||||
aNodeNb = Standard_Integer(Max(Abs(aPar12 - aPar11)*50./PI + 0.5, 4.));
|
||||
Graphic3d_Array1OfVertex ApproxArc1( 1, aNodeNb+1);
|
||||
aDelta = (aPar12 - aPar11)/aNodeNb;
|
||||
aCurPar= aPar11;
|
||||
for ( int i = 1; i<= aNodeNb ; aCurPar+= aDelta, i++)
|
||||
{
|
||||
gp_Pnt CurPnt = ElCLib::Value( aCurPar, aCirc1);
|
||||
ApproxArc1(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
}
|
||||
ApproxArc1(aNodeNb+1).SetCoord( aPoint2.X(), aPoint2.Y(), aPoint2.Z() );
|
||||
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc1 );
|
||||
}
|
||||
if (aPar22 < aPar21) aPar22 += 2*PI;
|
||||
if ( Abs(aPar22 - aPar21) > Precision::Confusion()){
|
||||
aNodeNb = Standard_Integer(Max(Abs(aPar22 - aPar21)*50./PI + 0.5, 4.));
|
||||
Graphic3d_Array1OfVertex ApproxArc2( 1, aNodeNb+1);
|
||||
aDelta = (aPar22 - aPar21)/aNodeNb;
|
||||
aCurPar= aPar21;
|
||||
for ( int i=1; i<= aNodeNb; aCurPar+= aDelta, i++)
|
||||
{
|
||||
gp_Pnt CurPnt = ElCLib::Value( aCurPar, aCirc2);
|
||||
ApproxArc2(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
}
|
||||
ApproxArc2(aNodeNb+1).SetCoord( aPoint4.X(), aPoint4.Y(), aPoint4.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc2 );
|
||||
}
|
||||
|
||||
//get the direction of interval
|
||||
gp_Dir DirOfArrow;
|
||||
if(aPoint4.Distance(aPoint2) > Precision::Confusion()){
|
||||
DirOfArrow.SetXYZ(aPoint4.XYZ() - aPoint2.XYZ());
|
||||
}
|
||||
else {
|
||||
//Let's take the radius direction
|
||||
gp_Pnt aCenter = aCirc1.Location();
|
||||
if(aPoint4.Distance(aCenter) < Precision::Confusion())
|
||||
return;
|
||||
DirOfArrow.SetXYZ(aPoint4.XYZ() - aCenter.XYZ());
|
||||
}
|
||||
|
||||
// Add presentation of arrows
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA, aPoint2, aPoint4, DirOfArrow.Reversed(), DirOfArrow, anArrowSide );
|
||||
|
||||
}
|
||||
//-- ota -- end
|
35
src/DsgPrs/DsgPrs_EqualRadiusPresentation.cdl
Executable file
35
src/DsgPrs/DsgPrs_EqualRadiusPresentation.cdl
Executable file
@@ -0,0 +1,35 @@
|
||||
-- File: DsgPrs_EqualRadiusPresentation.cdl
|
||||
-- Created: Sat Jan 17 14:13:23 1998
|
||||
-- Author: Julia GERASIMOVA
|
||||
-- <jgv@orthodox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class EqualRadiusPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to define display of equality in radii.
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp,
|
||||
Plane from Geom
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
FirstCenter : Pnt from gp;
|
||||
SecondCenter : Pnt from gp;
|
||||
FirstPoint : Pnt from gp;
|
||||
SecondPoint : Pnt from gp;
|
||||
Plane : Plane from Geom );
|
||||
---Purpose: Adds the points FirstCenter, SecondCenter,
|
||||
-- FirstPoint, SecondPoint, and the plane Plane to the
|
||||
-- presentation object aPresentation.
|
||||
-- The display attributes of these elements is defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- FirstCenter and SecondCenter are the centers of the
|
||||
-- first and second shapes respectively, and FirstPoint
|
||||
-- and SecondPoint are the attachment points of the radii to arcs.
|
||||
|
||||
end EqualRadiusPresentation;
|
105
src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx
Executable file
105
src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx
Executable file
@@ -0,0 +1,105 @@
|
||||
// File: DsgPrs_EqualRadiusPresentation.cxx
|
||||
// Created: Tue Jan 20 20:51:19 1998
|
||||
// Author: Julia GERASIMOVA
|
||||
// <jgv@orthodox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DsgPrs_EqualRadiusPresentation.ixx>
|
||||
|
||||
#include <DsgPrs.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
|
||||
void DsgPrs_EqualRadiusPresentation::Add( const Handle( Prs3d_Presentation )& aPresentation,
|
||||
const Handle( Prs3d_Drawer )& aDrawer,
|
||||
const gp_Pnt& FirstCenter,
|
||||
const gp_Pnt& SecondCenter,
|
||||
const gp_Pnt& FirstPoint,
|
||||
const gp_Pnt& SecondPoint,
|
||||
const Handle( Geom_Plane )& Plane )
|
||||
{
|
||||
Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
|
||||
|
||||
Graphic3d_Array1OfVertex VertexArray( 1, 2 );
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
// Radius lines
|
||||
FirstCenter.Coord( X, Y, Z );
|
||||
VertexArray( 1 ).SetCoord( X, Y, Z );
|
||||
FirstPoint.Coord( X, Y, Z );
|
||||
VertexArray( 2 ).SetCoord( X, Y, Z );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
SecondCenter.Coord( X, Y, Z );
|
||||
VertexArray( 1 ).SetCoord( X, Y, Z );
|
||||
SecondPoint.Coord( X, Y, Z );
|
||||
VertexArray( 2 ).SetCoord( X, Y, Z );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
// Add presentation of arrows
|
||||
gp_Dir FirstDir = gce_MakeDir( FirstCenter, FirstPoint ), SecondDir = gce_MakeDir( SecondCenter, SecondPoint );
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA,
|
||||
FirstCenter, FirstPoint,
|
||||
FirstDir.Reversed(), FirstDir,
|
||||
DsgPrs_AS_FIRSTPT_LASTAR );
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA,
|
||||
SecondCenter, SecondPoint,
|
||||
SecondDir.Reversed(), SecondDir,
|
||||
DsgPrs_AS_FIRSTPT_LASTAR );
|
||||
|
||||
// Line between two centers
|
||||
FirstCenter.Coord( X, Y, Z );
|
||||
VertexArray( 2 ).SetCoord( X, Y, Z );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
//ota === beging ===
|
||||
|
||||
gp_Pnt Middle( (FirstCenter.XYZ() + SecondCenter.XYZ()) *0.5 ), aTextPos;
|
||||
Standard_Real SmallDist;
|
||||
//Mark of constraint
|
||||
TCollection_ExtendedString aText("==");
|
||||
|
||||
Standard_Real Dist = FirstCenter.Distance( SecondCenter );
|
||||
if (Dist > Precision::Confusion())
|
||||
{
|
||||
SmallDist = Dist * 0.05; // take 1/20 part of length;
|
||||
if (SmallDist <= Precision::Confusion())
|
||||
SmallDist = Dist;
|
||||
gp_Dir LineDir = gce_MakeDir( FirstCenter, SecondCenter );
|
||||
gp_Dir OrtDir = Plane->Pln().Axis().Direction() ^ LineDir;
|
||||
|
||||
gp_Vec OrtVec = gp_Vec( OrtDir ) * SmallDist;
|
||||
|
||||
//Compute the text position
|
||||
aTextPos = Middle.Translated(OrtVec);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Real Rad = Max(FirstCenter.Distance( FirstPoint ),
|
||||
SecondCenter.Distance(SecondPoint));
|
||||
|
||||
SmallDist = Rad *0.05; // take 1/20 part of length;
|
||||
if (SmallDist <= Precision::Confusion())
|
||||
SmallDist = Rad;
|
||||
|
||||
gp_Vec aVec(SmallDist, SmallDist, SmallDist);
|
||||
|
||||
//Compute the text position
|
||||
aTextPos = FirstCenter.Translated(aVec);
|
||||
}
|
||||
|
||||
//Draw the text
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText, aTextPos);
|
||||
//ota === end ===
|
||||
}
|
42
src/DsgPrs/DsgPrs_FilletRadiusPresentation.cdl
Executable file
42
src/DsgPrs/DsgPrs_FilletRadiusPresentation.cdl
Executable file
@@ -0,0 +1,42 @@
|
||||
-- File: DsgPrs_FilletRadiusPresentation.cdl
|
||||
-- Created: Mon Dec 8 11:40:57 1997
|
||||
-- Author: Serguei ZARITCHNY
|
||||
-- <xab@zozox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
class FilletRadiusPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework for displaying radii of fillets.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection,
|
||||
ArrowSide from DsgPrs,
|
||||
TrimmedCurve from Geom,
|
||||
Circle from Geom,
|
||||
Ax1 from gp
|
||||
is
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
thevalue : Real from Standard;
|
||||
aText : ExtendedString from TCollection;
|
||||
aPosition : Pnt from gp;
|
||||
aNormalDir : Dir from gp;
|
||||
aBasePnt : Pnt from gp;
|
||||
aFirstPoint : Pnt from gp;
|
||||
aSecondPoint : Pnt from gp;
|
||||
aCenter : Pnt from gp;
|
||||
ArrowPrs : ArrowSide from DsgPrs;
|
||||
drawRevers : Boolean from Standard;
|
||||
DrawPosition : out Pnt from gp;
|
||||
EndOfArrow : out Pnt from gp;
|
||||
TrimCurve : out TrimmedCurve from Geom;
|
||||
HasCircle : out Boolean from Standard);
|
||||
---Purpose: Adds a display of the radius of a fillet to the
|
||||
-- presentation aPresentation. The display ttributes
|
||||
-- defined by the attribute manager aDrawer. the value
|
||||
-- specifies the length of the radius.
|
||||
|
||||
end FilletRadiusPresentation;
|
129
src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx
Executable file
129
src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx
Executable file
@@ -0,0 +1,129 @@
|
||||
// File: DsgPrs_FilletRadiusPresentation.cxx
|
||||
// Created: Mon Dec 8 12:00:59 1997
|
||||
// Author: Serguei ZARITCHNY
|
||||
// <xab@zozox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DsgPrs_FilletRadiusPresentation.ixx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
|
||||
//pop pour NT
|
||||
//#if WNT
|
||||
#include <stdio.h>
|
||||
//#endif
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const Standard_Real theval,
|
||||
const TCollection_ExtendedString & aText,
|
||||
const gp_Pnt & aPosition,
|
||||
const gp_Dir & aNormalDir,
|
||||
const gp_Pnt & aBasePnt,
|
||||
const gp_Pnt & aFirstPoint,
|
||||
const gp_Pnt & aSecondPoint,
|
||||
const gp_Pnt & aCenter,
|
||||
const DsgPrs_ArrowSide ArrowPrs,
|
||||
const Standard_Boolean drawRevers,
|
||||
gp_Pnt & DrawPosition,
|
||||
gp_Pnt & EndOfArrow,
|
||||
Handle(Geom_TrimmedCurve)& TrimCurve,
|
||||
Standard_Boolean & HasCircle )
|
||||
{
|
||||
char valcar[80];
|
||||
sprintf(valcar,"%5.2f",theval);
|
||||
Standard_Real FirstParCirc, LastParCirc;
|
||||
Standard_Boolean SpecCase;
|
||||
gp_Dir DirOfArrow;
|
||||
gp_Circ FilletCirc;
|
||||
// gp_Pnt NewPosition, EndOfArrow;
|
||||
Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
|
||||
Standard_Real ArrowLength = LA->Arrow1Aspect()->Length();
|
||||
DsgPrs::ComputeFilletRadiusPresentation( ArrowLength,
|
||||
theval,
|
||||
aPosition,
|
||||
aNormalDir,
|
||||
aFirstPoint,
|
||||
aSecondPoint,
|
||||
aCenter,
|
||||
aBasePnt,
|
||||
drawRevers,
|
||||
SpecCase,
|
||||
FilletCirc,
|
||||
FirstParCirc,
|
||||
LastParCirc,
|
||||
EndOfArrow,
|
||||
DirOfArrow,
|
||||
DrawPosition //NewPosition
|
||||
);
|
||||
// Creating the fillet's arc
|
||||
if( !SpecCase )
|
||||
{
|
||||
Standard_Real Alpha = Abs(LastParCirc - FirstParCirc);
|
||||
Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / PI));
|
||||
Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 );
|
||||
Standard_Real delta = Alpha / ( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 0 ; i < NodeNumber; i++)
|
||||
{
|
||||
CurPnt = ElCLib::Value( FirstParCirc, FilletCirc );
|
||||
ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
FirstParCirc += delta ;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc );
|
||||
HasCircle = Standard_True;
|
||||
Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc );
|
||||
TrimCurve = new Geom_TrimmedCurve( Circle, FirstParCirc, LastParCirc );
|
||||
}
|
||||
else // null or PI anle or Radius = 0
|
||||
{
|
||||
HasCircle = Standard_False;
|
||||
}
|
||||
|
||||
// Line from position to intersection point on fillet's circle (EndOfArrow)
|
||||
Graphic3d_Array1OfVertex Vrap(1,2);
|
||||
Vrap(1).SetCoord(DrawPosition.X(),
|
||||
DrawPosition.Y(),
|
||||
DrawPosition.Z());
|
||||
Vrap(2).SetCoord( EndOfArrow.X(), EndOfArrow.Y(), EndOfArrow.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap );
|
||||
// Drawing the text
|
||||
Prs3d_Text::Draw(aPresentation, LA->TextAspect(), aText, DrawPosition);
|
||||
|
||||
// Add presentation of arrows
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs );
|
||||
|
||||
}
|
||||
|
36
src/DsgPrs/DsgPrs_FixPresentation.cdl
Executable file
36
src/DsgPrs/DsgPrs_FixPresentation.cdl
Executable file
@@ -0,0 +1,36 @@
|
||||
-- File: DsgPrs_FixPresentation.cdl
|
||||
-- Created: Mon Apr 1 12:59:22 1996
|
||||
-- Author: Flore Lantheaume
|
||||
-- <fla@filax>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
class FixPresentation from DsgPrs
|
||||
|
||||
---Purpose: class which draws the presentation of Fixed objects
|
||||
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp
|
||||
|
||||
is
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aPntAttach : Pnt from gp;
|
||||
aPntEnd : Pnt from gp;
|
||||
aNormPln : Dir from gp;
|
||||
aSymbSize : Real from Standard);
|
||||
|
||||
---Purpose: draws the presentation of fixed objects by
|
||||
-- drawing the 'fix' symbol at position <aPntEnd>.
|
||||
-- A binding segment is drawn between <aPntAttach>
|
||||
-- ( which belongs the the fix object) and <aPntEnd>.
|
||||
-- aSymbSize is the size of the 'fix'symbol
|
||||
|
||||
|
||||
end FixPresentation;
|
116
src/DsgPrs/DsgPrs_FixPresentation.cxx
Executable file
116
src/DsgPrs/DsgPrs_FixPresentation.cxx
Executable file
@@ -0,0 +1,116 @@
|
||||
// File: DsgPrs_FixPresentation.cxx
|
||||
// Created: Mon Apr 1 13:04:35 1996
|
||||
// Author: Flore Lantheaume
|
||||
// <fla@filax>
|
||||
|
||||
|
||||
#include <DsgPrs_FixPresentation.ixx>
|
||||
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_FixPresentation::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aPntAttach,
|
||||
const gp_Pnt& aPntEnd,
|
||||
const gp_Dir& aNormPln,
|
||||
const Standard_Real symbsize)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
//Trace du segment de raccordement
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
V(1).SetCoord(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
|
||||
V(2).SetCoord(aPntEnd.X(), aPntEnd.Y(), aPntEnd.Z() );
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// trace du symbole 'Fix'
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
|
||||
gp_Vec dirac(aPntAttach, aPntEnd);
|
||||
// vecteur directeur du seg. de raccord
|
||||
dirac.Normalize();
|
||||
gp_Vec norac = dirac.Crossed(gp_Vec(aNormPln));
|
||||
gp_Ax1 ax(aPntEnd, aNormPln);
|
||||
norac.Rotate(ax, PI/8);
|
||||
// vecteur normal au seg. de raccord
|
||||
norac*=(symbsize/2);
|
||||
gp_Pnt P1 = aPntEnd.Translated(norac);
|
||||
gp_Pnt P2 = aPntEnd.Translated(-norac);
|
||||
|
||||
V(1).SetCoord(P1.X(),P1.Y(),P1.Z());
|
||||
V(2).SetCoord(P2.X(),P2.Y(),P2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// trace des 'dents'
|
||||
norac*=0.8;
|
||||
P1 = aPntEnd.Translated(norac);
|
||||
P2 = aPntEnd.Translated(-norac);
|
||||
dirac*=(symbsize/2);
|
||||
gp_Pnt PF(P1.XYZ());
|
||||
gp_Pnt PL = PF.Translated(dirac);
|
||||
PL.Translate(norac);
|
||||
V(1).SetCoord( PF.X(), PF.Y(), PF.Z() );
|
||||
V(2).SetCoord( PL.X(), PL.Y(), PL.Z() );
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
PF.SetXYZ(P2.XYZ());
|
||||
PL = PF.Translated(dirac);
|
||||
PL.Translate(norac);
|
||||
V(1).SetCoord( PF.X(), PF.Y(), PF.Z() );
|
||||
V(2).SetCoord( PL.X(), PL.Y(), PL.Z() );
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
PF.SetXYZ((P1.XYZ() + P2.XYZ())/2);
|
||||
PL = PF.Translated(dirac);
|
||||
PL.Translate(norac);
|
||||
V(1).SetCoord( PF.X(), PF.Y(), PF.Z() );
|
||||
V(2).SetCoord( PL.X(), PL.Y(), PL.Z() );
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// On ajoute un rond au point d'attache
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
|
||||
MarkerAsp->SetType(Aspect_TOM_BALL);
|
||||
MarkerAsp->SetScale(0.8);
|
||||
Quantity_Color acolor;
|
||||
Aspect_TypeOfLine atype;
|
||||
Standard_Real awidth;
|
||||
LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
|
||||
MarkerAsp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
|
||||
Graphic3d_Vertex V3d(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
}
|
94
src/DsgPrs/DsgPrs_IdenticPresentation.cdl
Executable file
94
src/DsgPrs/DsgPrs_IdenticPresentation.cdl
Executable file
@@ -0,0 +1,94 @@
|
||||
-- File: DsgPrs_IdenticPresentation.cdl
|
||||
-- Created: Fri Jan 3 17:58:43 1997
|
||||
-- Author: Stagiaire Flore Lautheanne
|
||||
-- <fla@chariox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
class IdenticPresentation from DsgPrs
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Ax2 from gp,
|
||||
Elips from gp -- jfa 10/10/2000
|
||||
|
||||
is
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
aPntAttach : Pnt from gp;
|
||||
aPntOffset : Pnt from gp);
|
||||
---Purpose: draws a line between <aPntAttach> and
|
||||
-- <aPntOffset>.
|
||||
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
aFAttach : Pnt from gp;
|
||||
aSAttach : Pnt from gp;
|
||||
aPntOffset : Pnt from gp);
|
||||
---Purpose: draws the 'identic' presentation by
|
||||
-- drawing a line between <aFAttach> and
|
||||
-- <aSAttach> , and a linkimg segment
|
||||
-- between <aPntOffset> and its projection
|
||||
-- on the precedent line.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
aAx2 : Ax2 from gp;
|
||||
aCenter : Pnt from gp;
|
||||
aFAttach : Pnt from gp;
|
||||
aSAttach : Pnt from gp;
|
||||
aPntOffset : Pnt from gp);
|
||||
---Purpose: draws the 'identic' presentation in the case of
|
||||
-- circles : draws an arc of circle between
|
||||
-- <aFAttach> and <aSAttach> of center <aCenter>
|
||||
-- and of radius dist(aCenter, aFAttach), and
|
||||
-- draws a segment between <aPntOffset> and
|
||||
-- its projection on the arc.
|
||||
|
||||
-- jfa 16/10/2000
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
aAx2 : Ax2 from gp;
|
||||
aCenter : Pnt from gp;
|
||||
aFAttach : Pnt from gp;
|
||||
aSAttach : Pnt from gp;
|
||||
aPntOffset : Pnt from gp;
|
||||
aPntOnCirc : Pnt from gp);
|
||||
---Purpose: draws the 'identic' presentation in the case of
|
||||
-- circles : draws an arc of circle between
|
||||
-- <aFAttach> and <aSAttach> of center <aCenter>
|
||||
-- and of radius dist(aCenter, aFAttach), and
|
||||
-- draws a segment between <aPntOffset> and <aPntOnCirc>
|
||||
|
||||
-- jfa 16/10/2000
|
||||
|
||||
-- jfa 10/10/2000 for ellipses identity presentation
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
anEllipse: Elips from gp;
|
||||
aFAttach : Pnt from gp;
|
||||
aSAttach : Pnt from gp;
|
||||
aPntOffset : Pnt from gp;
|
||||
aPntOnElli : Pnt from gp);
|
||||
---Purpose: draws the 'identic' presentation in the case of
|
||||
-- ellipses: draws an arc of the anEllipse
|
||||
-- between <aFAttach> and <aSAttach> and
|
||||
-- draws a segment between <aPntOffset> and <aPntOnElli>
|
||||
|
||||
-- jfa 10/10/2000 end
|
||||
|
||||
end IdenticPresentation;
|
||||
|
250
src/DsgPrs/DsgPrs_IdenticPresentation.cxx
Executable file
250
src/DsgPrs/DsgPrs_IdenticPresentation.cxx
Executable file
@@ -0,0 +1,250 @@
|
||||
// File: DsgPrs_IdenticPresentation.cxx
|
||||
// Created: Fri Jan 3 18:05:10 1997
|
||||
// Author: Flore Lantheaume
|
||||
// <fla@chariox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DsgPrs_IdenticPresentation.ixx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <gp_Elips.hxx>
|
||||
|
||||
void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& aPntAttach,
|
||||
const gp_Pnt& aPntOffset)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
V(1).SetCoord(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
|
||||
V(2).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// On ajoute un rond au point d'attache
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
|
||||
MarkerAsp->SetType(Aspect_TOM_BALL);
|
||||
MarkerAsp->SetScale(0.8);
|
||||
Quantity_Color acolor;
|
||||
Aspect_TypeOfLine atype;
|
||||
Standard_Real awidth;
|
||||
LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
|
||||
MarkerAsp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
|
||||
Graphic3d_Vertex V3d(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& aFAttach,
|
||||
const gp_Pnt& aSAttach,
|
||||
const gp_Pnt& aPntOffset)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
V(1).SetCoord(aFAttach.X(), aFAttach.Y(), aFAttach.Z());
|
||||
V(2).SetCoord(aSAttach.X(), aSAttach.Y(), aSAttach.Z());
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// trait joignant aPntOffset
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Vec v1(aFAttach, aSAttach);
|
||||
gp_Vec v2(aSAttach, aPntOffset);
|
||||
V(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
|
||||
if ( !v1.IsParallel(v2, Precision::Angular())) {
|
||||
// on joint aPntOffset a son projete
|
||||
gp_Lin ll(aFAttach, gp_Dir(v1));
|
||||
gp_Pnt ProjPntOffset = ElCLib::Value(ElCLib::Parameter(ll,aPntOffset ), ll);
|
||||
V(2).SetCoord(ProjPntOffset.X(), ProjPntOffset.Y(), ProjPntOffset.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Ax2& theAxe,
|
||||
const gp_Pnt& aCenter,
|
||||
const gp_Pnt& aFAttach,
|
||||
const gp_Pnt& aSAttach,
|
||||
const gp_Pnt& aPntOffset)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Ax2 ax = theAxe;
|
||||
ax.SetLocation(aCenter);
|
||||
Standard_Real rad = aCenter.Distance(aFAttach);
|
||||
gp_Circ CC(ax,rad );
|
||||
Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach);
|
||||
Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach);
|
||||
Standard_Real alpha = pSAttach - pFAttach;
|
||||
if ( alpha < 0 ) alpha += 2*Standard_PI;
|
||||
Standard_Integer nb = (Standard_Integer )( 50. * alpha / PI);
|
||||
Standard_Integer nbp = Max (4 , nb);
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(pFAttach + dteta*(i-1),CC);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// trait joignant aPntOffset
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Graphic3d_Array1OfVertex V2(1,2);
|
||||
if ( Abs((aPntOffset.Distance(aCenter) - rad )) >= Precision::Confusion() ) {
|
||||
gp_Pnt ProjPntOffset = ElCLib::Value(ElCLib::Parameter(CC,aPntOffset ), CC);
|
||||
|
||||
V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
|
||||
V2(2).SetCoord(ProjPntOffset.X(), ProjPntOffset.Y(), ProjPntOffset.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
|
||||
}
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
|
||||
}
|
||||
|
||||
// jfa 16/10/2000
|
||||
void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Ax2& theAxe,
|
||||
const gp_Pnt& aCenter,
|
||||
const gp_Pnt& aFAttach,
|
||||
const gp_Pnt& aSAttach,
|
||||
const gp_Pnt& aPntOffset,
|
||||
const gp_Pnt& aPntOnCirc)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Ax2 ax = theAxe;
|
||||
ax.SetLocation(aCenter);
|
||||
Standard_Real rad = aCenter.Distance(aFAttach);
|
||||
gp_Circ CC(ax,rad );
|
||||
Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach);
|
||||
Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach);
|
||||
Standard_Real alpha = pSAttach - pFAttach;
|
||||
if ( alpha < 0 ) alpha += 2*Standard_PI;
|
||||
Standard_Integer nb = (Standard_Integer )( 50. * alpha / PI);
|
||||
Standard_Integer nbp = Max (4 , nb);
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(pFAttach + dteta*(i-1),CC);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// trait joignant aPntOffset
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Graphic3d_Array1OfVertex V2(1,2);
|
||||
if ( aPntOffset.Distance(aPntOnCirc) >= Precision::Confusion() )
|
||||
{
|
||||
V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
|
||||
V2(2).SetCoord(aPntOnCirc.X(), aPntOnCirc.Y(), aPntOnCirc.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
|
||||
}
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
|
||||
}
|
||||
// jfa 16/10/2000 end
|
||||
|
||||
// jfa 10/10/2000
|
||||
void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Elips& anEllipse,
|
||||
const gp_Pnt& aFAttach,
|
||||
const gp_Pnt& aSAttach,
|
||||
const gp_Pnt& aPntOffset,
|
||||
const gp_Pnt& aPntOnElli)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Standard_Real pFAttach = ElCLib::Parameter(anEllipse, aFAttach);
|
||||
Standard_Real pSAttach = ElCLib::Parameter(anEllipse, aSAttach);
|
||||
Standard_Real alpha = pSAttach - pFAttach;
|
||||
if ( alpha < 0 ) alpha += 2*Standard_PI;
|
||||
Standard_Integer nb = (Standard_Integer)(50.0*alpha/PI);
|
||||
Standard_Integer nbp = Max (4 , nb);
|
||||
Graphic3d_Array1OfVertex V(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i<=nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(pFAttach + dteta*(i-1),anEllipse);
|
||||
V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// trait joignant aPntOffset
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Graphic3d_Array1OfVertex V2(1,2);
|
||||
|
||||
if ( ! aPntOnElli.IsEqual(aPntOffset, Precision::Confusion()) )
|
||||
{
|
||||
V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
|
||||
V2(2).SetCoord(aPntOnElli.X(), aPntOnElli.Y(), aPntOnElli.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
|
||||
}
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
|
||||
}
|
||||
// jfa 10/10/2000 end
|
117
src/DsgPrs/DsgPrs_LengthPresentation.cdl
Executable file
117
src/DsgPrs/DsgPrs_LengthPresentation.cdl
Executable file
@@ -0,0 +1,117 @@
|
||||
-- File: DsgPrs_LengthPresentation.cdl
|
||||
-- Created: Thu Jun 3 09:41:39 1993
|
||||
-- Author: Jean-Louis FRENKEL
|
||||
-- <jlf@stylox>
|
||||
-- modified : Rob le 26-mars-96 rajout de methodes pour representation simple...
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class LengthPresentation from DsgPrs
|
||||
---Purpose: Framework for displaying lengths.
|
||||
-- The length displayed is indicated by line segments
|
||||
-- and text alone or by a combination of line segment,
|
||||
-- text and arrows at either or both of its ends.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection,
|
||||
ArrowSide from DsgPrs,
|
||||
|
||||
Pln from gp,
|
||||
Surface from Geom
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aDirection: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Draws a line segment representing a length in the
|
||||
-- display aPresentation.
|
||||
-- This segment joins the points AttachmentPoint1 and
|
||||
-- AttachmentPoint2, along the direction aDirection.
|
||||
-- The text aText will be displayed at the offset point OffsetPoint.
|
||||
-- The line and text attributes are specified by the
|
||||
-- attribute manager aDrawer.
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aText : ExtendedString from TCollection;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
aDirection : Dir from gp;
|
||||
OffsetPoint : Pnt from gp;
|
||||
ArrowSide : ArrowSide from DsgPrs );
|
||||
---Purpose: Draws a line segment representing a length in the
|
||||
-- display aPresentation.
|
||||
-- This segment joins the points AttachmentPoint1 and
|
||||
-- AttachmentPoint2, along the direction aDirection.
|
||||
-- The text aText will be displayed at the offset point
|
||||
-- OffsetPoint. The value of the enumeration ArrowSide
|
||||
-- controls whether arrows will be displayed at either or
|
||||
-- both ends of the length.
|
||||
-- The line, text and arrow attributes are specified by the
|
||||
-- attribute manager aDrawer.
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aText : ExtendedString from TCollection;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
PlaneOfFaces : Pln from gp;
|
||||
aDirection : Dir from gp;
|
||||
OffsetPoint : Pnt from gp;
|
||||
ArrowSide : ArrowSide from DsgPrs );
|
||||
---Purpose: Draws a line segment representing a length in the
|
||||
-- display aPresentation.
|
||||
-- This segment joins the points AttachmentPoint1 and
|
||||
-- AttachmentPoint2, along the direction aDirection.
|
||||
-- The text aText will be displayed at the offset point
|
||||
-- OffsetPoint. The value of the enumeration ArrowSide
|
||||
-- controls whether arrows will be displayed at either or
|
||||
-- both ends of the length.
|
||||
-- The plane PlaneOfFaces is used if length is null.
|
||||
-- The line, text and arrow attributes are specified by the
|
||||
-- attribute manager aDrawer.
|
||||
|
||||
Add( myclass; aPresentation : Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aText : ExtendedString from TCollection;
|
||||
SecondSurf : Surface from Geom;
|
||||
AttachmentPoint1 : Pnt from gp;
|
||||
AttachmentPoint2 : Pnt from gp;
|
||||
aDirection : Dir from gp;
|
||||
OffsetPoint : Pnt from gp;
|
||||
ArrowSide : ArrowSide from DsgPrs );
|
||||
---Purpose: Draws a line segment representing a length in the
|
||||
-- display aPresentation.
|
||||
-- This segment joins the points AttachmentPoint1 and
|
||||
-- AttachmentPoint2, along the direction
|
||||
-- aDirection. AttachmentPoint2 lies on the curvilinear
|
||||
-- faces SecondSurf. The text aText will be displayed at
|
||||
-- the offset point OffsetPoint. The value of the
|
||||
-- enumeration ArrowSide controls whether arrows will
|
||||
-- be displayed at either or both ends of the length.
|
||||
-- The line, text and arrow attributes are specified by the
|
||||
-- attribute manager aDrawer.
|
||||
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
Pt1 : Pnt from gp;
|
||||
Pt2 : Pnt from gp;
|
||||
ArrowSide : ArrowSide from DsgPrs);
|
||||
---Purpose: Draws a line segment representing a length in the
|
||||
-- display aPresentation.
|
||||
-- This segment joins the points AttachmentPoint1 and
|
||||
-- AttachmentPoint2, along the direction aDirection.
|
||||
-- The value of the enumeration ArrowSide controls
|
||||
-- whether arrows will be displayed at either or both ends of the length.
|
||||
-- The line and arrow attributes are specified by the attribute manager aDrawer.
|
||||
|
||||
end LengthPresentation;
|
468
src/DsgPrs/DsgPrs_LengthPresentation.cxx
Executable file
468
src/DsgPrs/DsgPrs_LengthPresentation.cxx
Executable file
@@ -0,0 +1,468 @@
|
||||
#include <DsgPrs_LengthPresentation.ixx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
|
||||
|
||||
void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& OffsetPoint)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Lin L1 (AttachmentPoint1,aDirection);
|
||||
gp_Lin L2 (AttachmentPoint2,aDirection);
|
||||
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
|
||||
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
|
||||
gp_Lin L3;
|
||||
if (!Proj1.IsEqual(Proj2,Precision::Confusion())) {
|
||||
L3 = gce_MakeLin(Proj1,Proj2);
|
||||
}
|
||||
else {
|
||||
L3 = gp_Lin(Proj1,aDirection);
|
||||
}
|
||||
Standard_Real parmin,parmax,parcur;
|
||||
parmin = ElCLib::Parameter(L3,Proj1);
|
||||
parmax = parmin;
|
||||
parcur = ElCLib::Parameter(L3,Proj2);
|
||||
Standard_Real dist = Abs(parmin-parcur);
|
||||
if (parcur < parmin) parmin = parcur;
|
||||
if (parcur > parmax) parmax = parcur;
|
||||
parcur = ElCLib::Parameter(L3,OffsetPoint);
|
||||
gp_Pnt offp = ElCLib::Value(parcur,L3);
|
||||
|
||||
Standard_Boolean outside = Standard_False;
|
||||
if (parcur < parmin) {
|
||||
parmin = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
if (parcur > parmax) {
|
||||
parmax = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
|
||||
gp_Pnt PointMin = ElCLib::Value(parmin,L3);
|
||||
gp_Pnt PointMax = ElCLib::Value(parmax,L3);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
PointMin.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
PointMax.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
// trait de cote : 1er groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
|
||||
outside = Standard_True;
|
||||
}
|
||||
gp_Dir arrdir = L3.Direction().Reversed();
|
||||
|
||||
if (outside) {
|
||||
arrdir.Reverse();
|
||||
}
|
||||
// fleche 1 : 2eme groupe
|
||||
Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
// fleche 2 : 3eme groupe
|
||||
Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(),
|
||||
LA->Arrow2Aspect()->Angle(),
|
||||
LA->Arrow2Aspect()->Length());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
|
||||
// texte : 4eme groupe
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
|
||||
|
||||
AttachmentPoint1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj1.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// trait de rappel 1 : 5eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
AttachmentPoint2.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// trait de rappel 2 : 6eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
}
|
||||
|
||||
//==================================================================================
|
||||
//function : Add
|
||||
//purpose : Adds presentation of length dimension between two planar faces
|
||||
//==================================================================================
|
||||
|
||||
void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Pln& PlaneOfFaces,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const DsgPrs_ArrowSide ArrowPrs )
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Pnt EndOfArrow1, EndOfArrow2;
|
||||
gp_Dir DirOfArrow1;
|
||||
|
||||
DsgPrs::ComputePlanarFacesLengthPresentation( LA->Arrow1Aspect()->Length(),
|
||||
LA->Arrow2Aspect()->Length(),
|
||||
AttachmentPoint1,
|
||||
AttachmentPoint2,
|
||||
aDirection,
|
||||
OffsetPoint,
|
||||
PlaneOfFaces,
|
||||
EndOfArrow1,
|
||||
EndOfArrow2,
|
||||
DirOfArrow1 );
|
||||
Graphic3d_Array1OfVertex VertexArray( 1, 2 );
|
||||
|
||||
// Parameters for length's line
|
||||
gp_Lin LengthLine( OffsetPoint, DirOfArrow1 );
|
||||
Standard_Real Par1 = ElCLib::Parameter( LengthLine, EndOfArrow1 );
|
||||
Standard_Real Par2 = ElCLib::Parameter( LengthLine, EndOfArrow2 );
|
||||
gp_Pnt FirstPoint, LastPoint;
|
||||
if (Par1 > 0.0 && Par2 > 0.0 || Par1 < 0.0 && Par2 < 0.0)
|
||||
{
|
||||
FirstPoint = OffsetPoint;
|
||||
LastPoint = (Abs( Par1 ) > Abs( Par2 ))? EndOfArrow1 : EndOfArrow2;
|
||||
}
|
||||
else
|
||||
{
|
||||
FirstPoint = EndOfArrow1;
|
||||
LastPoint = EndOfArrow2;
|
||||
}
|
||||
|
||||
// Creating the length's line
|
||||
VertexArray(1).SetCoord( FirstPoint.X(), FirstPoint.Y(), FirstPoint.Z() );
|
||||
VertexArray(2).SetCoord( LastPoint.X(), LastPoint.Y(), LastPoint.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
// Add presentation of arrows
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA,
|
||||
EndOfArrow1, EndOfArrow2, //EndOfArrow1,
|
||||
DirOfArrow1, DirOfArrow1.Reversed(), ArrowPrs );
|
||||
|
||||
// Drawing the text
|
||||
Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, OffsetPoint );
|
||||
|
||||
// Line from AttachmentPoint1 to end of Arrow1
|
||||
VertexArray(1).SetCoord(AttachmentPoint1.X(),
|
||||
AttachmentPoint1.Y(),
|
||||
AttachmentPoint1.Z());
|
||||
VertexArray(2).SetCoord( EndOfArrow1.X(), EndOfArrow1.Y(), EndOfArrow1.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
// Line from AttachmentPoint2 to end of Arrow2
|
||||
VertexArray(1).SetCoord(AttachmentPoint2.X(),
|
||||
AttachmentPoint2.Y(),
|
||||
AttachmentPoint2.Z());
|
||||
VertexArray(2).SetCoord( EndOfArrow2.X(), EndOfArrow2.Y(), EndOfArrow2.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================================
|
||||
//function : Add
|
||||
//purpose : adds presentation of length between two edges, vertex and edge or two vertices
|
||||
//=========================================================================================
|
||||
|
||||
void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Lin L1 (AttachmentPoint1,aDirection);
|
||||
gp_Lin L2 (AttachmentPoint2,aDirection);
|
||||
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
|
||||
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
|
||||
gp_Lin L3;
|
||||
if (!Proj1.IsEqual(Proj2,Precision::Confusion())) {
|
||||
L3 = gce_MakeLin(Proj1,Proj2);
|
||||
}
|
||||
else {
|
||||
L3 = gp_Lin(Proj1,aDirection);
|
||||
}
|
||||
Standard_Real parmin,parmax,parcur;
|
||||
parmin = ElCLib::Parameter(L3,Proj1);
|
||||
parmax = parmin;
|
||||
parcur = ElCLib::Parameter(L3,Proj2);
|
||||
Standard_Real dist = Abs(parmin-parcur);
|
||||
if (parcur < parmin) parmin = parcur;
|
||||
if (parcur > parmax) parmax = parcur;
|
||||
parcur = ElCLib::Parameter(L3,OffsetPoint);
|
||||
gp_Pnt offp = ElCLib::Value(parcur,L3);
|
||||
|
||||
Standard_Boolean outside = Standard_False;
|
||||
if (parcur < parmin) {
|
||||
parmin = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
if (parcur > parmax) {
|
||||
parmax = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
|
||||
gp_Pnt PointMin = ElCLib::Value(parmin,L3);
|
||||
gp_Pnt PointMax = ElCLib::Value(parmax,L3);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
PointMin.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
PointMax.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
|
||||
if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
|
||||
outside = Standard_True;
|
||||
}
|
||||
gp_Dir arrdir = L3.Direction().Reversed();
|
||||
|
||||
if (outside) {
|
||||
arrdir.Reverse();
|
||||
}
|
||||
|
||||
|
||||
AttachmentPoint1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj1.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
// trait de rappel 1
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
AttachmentPoint2.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
// trait de rappel 2
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
|
||||
|
||||
// symbols aux extremites de la cote
|
||||
DsgPrs::ComputeSymbol(aPresentation,LA,Proj1,Proj2,arrdir,arrdir.Reversed(),ArrowPrs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================================================
|
||||
//function : Add
|
||||
//purpose : Adds presentation of length dimension between two curvilinear faces
|
||||
//==================================================================================
|
||||
|
||||
void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const Handle( Geom_Surface )& SecondSurf,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const DsgPrs_ArrowSide ArrowPrs )
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Pnt EndOfArrow2;
|
||||
gp_Dir DirOfArrow1;
|
||||
Handle( Geom_Curve ) VCurve, UCurve;
|
||||
Standard_Real FirstU, deltaU = 0.0e0, FirstV, deltaV = 0.0e0;
|
||||
|
||||
DsgPrs::ComputeCurvilinearFacesLengthPresentation( LA->Arrow1Aspect()->Length(),
|
||||
LA->Arrow2Aspect()->Length(),
|
||||
SecondSurf,
|
||||
AttachmentPoint1,
|
||||
AttachmentPoint2,
|
||||
aDirection,
|
||||
EndOfArrow2,
|
||||
DirOfArrow1,
|
||||
VCurve,
|
||||
UCurve,
|
||||
FirstU, deltaU,
|
||||
FirstV, deltaV );
|
||||
|
||||
Graphic3d_Array1OfVertex VertexArray( 1, 2 );
|
||||
|
||||
gp_Lin LengthLine( OffsetPoint, DirOfArrow1 );
|
||||
Standard_Real Par1 = ElCLib::Parameter( LengthLine, AttachmentPoint1 );
|
||||
Standard_Real Par2 = ElCLib::Parameter( LengthLine, EndOfArrow2 );
|
||||
gp_Pnt FirstPoint, LastPoint;
|
||||
if (Par1 > 0.0 && Par2 > 0.0 || Par1 < 0.0 && Par2 < 0.0)
|
||||
{
|
||||
FirstPoint = OffsetPoint;
|
||||
LastPoint = (Abs( Par1 ) > Abs( Par2 ))? AttachmentPoint1 : EndOfArrow2;
|
||||
}
|
||||
else
|
||||
{
|
||||
FirstPoint = AttachmentPoint1;
|
||||
LastPoint = EndOfArrow2;
|
||||
}
|
||||
|
||||
// Creating the length's line
|
||||
VertexArray(1).SetCoord( FirstPoint.X(), FirstPoint.Y(), FirstPoint.Z() );
|
||||
VertexArray(2).SetCoord( LastPoint.X(), LastPoint.Y(), LastPoint.Z() );
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
|
||||
// Add presentation of arrows
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA,
|
||||
AttachmentPoint1, EndOfArrow2,
|
||||
DirOfArrow1, DirOfArrow1.Reversed(), ArrowPrs );
|
||||
|
||||
// Drawing the text
|
||||
Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, OffsetPoint );
|
||||
|
||||
// Two curves from end of Arrow2 to AttachmentPoint2
|
||||
Standard_Real Alpha, delta;
|
||||
Standard_Integer NodeNumber;
|
||||
|
||||
Alpha = Abs( deltaU );
|
||||
if (Alpha > Precision::Angular() && Alpha<Precision::Infinite())
|
||||
{
|
||||
NodeNumber = Max( 4 , Standard_Integer (50. * Alpha / PI) );
|
||||
Graphic3d_Array1OfVertex ApproxCurve( 1, NodeNumber );
|
||||
delta = deltaU / (Standard_Real)( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 1; i <= NodeNumber; i++)
|
||||
{
|
||||
CurPnt = VCurve->Value( FirstU );
|
||||
ApproxCurve(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
FirstU += delta;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxCurve );
|
||||
}
|
||||
Alpha = Abs( deltaV );
|
||||
if (Alpha > Precision::Angular() && Alpha<Precision::Infinite())
|
||||
{
|
||||
NodeNumber = Max( 4 , Standard_Integer (50. * Alpha / PI) );
|
||||
Graphic3d_Array1OfVertex ApproxCurve( 1, NodeNumber );
|
||||
delta = deltaV / (Standard_Real)( NodeNumber - 1 );
|
||||
gp_Pnt CurPnt;
|
||||
for (Standard_Integer i = 1; i <= NodeNumber; i++)
|
||||
{
|
||||
CurPnt = UCurve->Value( FirstV );
|
||||
ApproxCurve(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() );
|
||||
FirstV += delta;
|
||||
}
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxCurve );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//================================
|
||||
// Function:
|
||||
// Purpose: Rob 26-mar-96
|
||||
//=================================
|
||||
|
||||
void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPrs,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& Pt1,
|
||||
const gp_Pnt& Pt2,
|
||||
const DsgPrs_ArrowSide ArrowPrs)
|
||||
{
|
||||
Prs3d_Root::CurrentGroup(aPrs)->BeginPrimitives();
|
||||
Graphic3d_Array1OfVertex Vx(1,2);
|
||||
Vx(1).SetCoord(Pt1.X(),Pt1.Y(),Pt1.Z());
|
||||
Vx(2).SetCoord(Pt2.X(),Pt2.Y(),Pt2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPrs)->Polyline(Vx);
|
||||
|
||||
gp_Vec V ;
|
||||
switch(ArrowPrs){
|
||||
case DsgPrs_AS_NONE:
|
||||
break;
|
||||
case DsgPrs_AS_LASTAR:
|
||||
Prs3d_Arrow::Draw(aPrs,Pt2,gp_Dir(gp_Vec(Pt1,Pt2)),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Angle(),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Length());
|
||||
break;
|
||||
case DsgPrs_AS_FIRSTAR:
|
||||
Prs3d_Arrow::Draw(aPrs,Pt1,gp_Dir(gp_Vec(Pt2,Pt1)),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Angle(),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Length());
|
||||
break;
|
||||
case DsgPrs_AS_BOTHAR:
|
||||
V = gp_Vec(Pt1,Pt2);
|
||||
Prs3d_Arrow::Draw(aPrs,Pt2,gp_Dir(V),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Angle(),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Length());
|
||||
Prs3d_Arrow::Draw(aPrs,Pt1,gp_Dir(V.Reversed()),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Angle(),
|
||||
aDrawer->LengthAspect()->Arrow1Aspect()->Length());
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPrs)->EndPrimitives();
|
||||
|
||||
}
|
65
src/DsgPrs/DsgPrs_MidPointPresentation.cdl
Executable file
65
src/DsgPrs/DsgPrs_MidPointPresentation.cdl
Executable file
@@ -0,0 +1,65 @@
|
||||
-- File: DsgPrs_MidPointPresentation.cdl
|
||||
-- Created: Fri Oct 20 15:57:32 2000
|
||||
-- Author: Julia DOROVSKIKH
|
||||
-- <jfa@androx.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
class MidPointPresentation from DsgPrs
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp,
|
||||
Lin from gp,
|
||||
Circ from gp,
|
||||
Elips from gp,
|
||||
Ax2 from gp
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
theAxe : Ax2 from gp;
|
||||
MidPoint : Pnt from gp;
|
||||
Position : Pnt from gp;
|
||||
AttachPoint : Pnt from gp;
|
||||
first : Boolean from Standard);
|
||||
---Purpose: draws the representation of a MidPoint between
|
||||
-- two vertices.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
theAxe : Ax2 from gp;
|
||||
MidPoint : Pnt from gp;
|
||||
Position : Pnt from gp;
|
||||
AttachPoint : Pnt from gp;
|
||||
Point1 : Pnt from gp;
|
||||
Point2 : Pnt from gp;
|
||||
first : Boolean from Standard);
|
||||
---Purpose: draws the representation of a MidPoint between
|
||||
-- two lines or linear segments.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aCircle : Circ from gp;
|
||||
MidPoint : Pnt from gp;
|
||||
Position : Pnt from gp;
|
||||
AttachPoint : Pnt from gp;
|
||||
Point1 : Pnt from gp;
|
||||
Point2 : Pnt from gp;
|
||||
first : Boolean from Standard);
|
||||
---Purpose: draws the representation of a MidPoint between
|
||||
-- two entire circles or two circular arcs.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
anElips : Elips from gp;
|
||||
MidPoint : Pnt from gp;
|
||||
Position : Pnt from gp;
|
||||
AttachPoint : Pnt from gp;
|
||||
Point1 : Pnt from gp;
|
||||
Point2 : Pnt from gp;
|
||||
first : Boolean from Standard);
|
||||
---Purpose: draws the representation of a MidPoint between
|
||||
-- two entire ellipses or two elliptic arcs.
|
||||
|
||||
end MidPointPresentation;
|
369
src/DsgPrs/DsgPrs_MidPointPresentation.cxx
Executable file
369
src/DsgPrs/DsgPrs_MidPointPresentation.cxx
Executable file
@@ -0,0 +1,369 @@
|
||||
// File: DsgPrs_MidPointPresentation.cxx
|
||||
// Created: Fri Oct 20 16:00:58 2000
|
||||
// Author: Julia DOROVSKIKH
|
||||
// <jfa@androx.nnov.matra-dtv.fr>
|
||||
|
||||
#include <DsgPrs_MidPointPresentation.ixx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
|
||||
//===================================================================
|
||||
//Function:Add
|
||||
//Purpose: draws the representation of a radial symmetry between two vertices.
|
||||
//===================================================================
|
||||
void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Ax2& theAxe,
|
||||
const gp_Pnt& MidPoint,
|
||||
const gp_Pnt& Position,
|
||||
const gp_Pnt& AttachPoint,
|
||||
const Standard_Boolean first)
|
||||
{
|
||||
Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0;
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
gp_Pnt Ptmp;
|
||||
|
||||
gp_Ax2 ax = theAxe;
|
||||
ax.SetLocation(MidPoint);
|
||||
gp_Circ aCircleM (ax,rad);
|
||||
|
||||
if ( first )
|
||||
{
|
||||
// center of the symmetry - circle around the MidPoint
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Standard_Real alpha = 2*Standard_PI;
|
||||
Standard_Integer nbp = 100;
|
||||
Graphic3d_Array1OfVertex VC(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i <= nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(dteta*(i-1),aCircleM);
|
||||
VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC);
|
||||
|
||||
// segment from mid point to the text position
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
if ( Position.IsEqual(MidPoint,rad) )
|
||||
Ptmp = MidPoint;
|
||||
else
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// text position
|
||||
V(2).SetCoord(Position.X(),Position.Y(),Position.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// texte
|
||||
TCollection_ExtendedString aText (" (+)");
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position);
|
||||
}
|
||||
|
||||
if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) )
|
||||
{
|
||||
// segment from mid point to the geometry
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// attach point to the geometry
|
||||
V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
}
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
//Function:Add
|
||||
//Purpose: draws the representation of a radial symmetry between two linear segments.
|
||||
//===================================================================
|
||||
void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Ax2& theAxe,
|
||||
const gp_Pnt& MidPoint,
|
||||
const gp_Pnt& Position,
|
||||
const gp_Pnt& AttachPoint,
|
||||
const gp_Pnt& Point1,
|
||||
const gp_Pnt& Point2,
|
||||
const Standard_Boolean first)
|
||||
{
|
||||
Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0;
|
||||
if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0;
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
gp_Pnt Ptmp;
|
||||
|
||||
gp_Ax2 ax = theAxe;
|
||||
ax.SetLocation(MidPoint);
|
||||
gp_Circ aCircleM (ax,rad);
|
||||
|
||||
if ( first )
|
||||
{
|
||||
// center of the symmetry - circle around the MidPoint
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Standard_Real alpha = 2*Standard_PI;
|
||||
Standard_Integer nbp = 100;
|
||||
Graphic3d_Array1OfVertex VC(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
gp_Pnt ptcur;
|
||||
for (Standard_Integer i = 1; i <= nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(dteta*(i-1),aCircleM);
|
||||
VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC);
|
||||
|
||||
// segment from mid point to the text position
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
if ( Position.IsEqual(MidPoint,rad) )
|
||||
Ptmp = MidPoint;
|
||||
else
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// text position
|
||||
V(2).SetCoord(Position.X(),Position.Y(),Position.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// texte
|
||||
TCollection_ExtendedString aText (" (+)");
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position);
|
||||
}
|
||||
|
||||
if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) )
|
||||
{
|
||||
// segment from mid point to the geometry
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// attach point to the geometry
|
||||
V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
}
|
||||
|
||||
// segment on line
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
V(1).SetCoord(Point1.X(),Point1.Y(),Point1.Z());
|
||||
V(2).SetCoord(Point2.X(),Point2.Y(),Point2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
//Function:Add
|
||||
//Purpose: draws the representation of a radial symmetry between two circular arcs.
|
||||
//===================================================================
|
||||
void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Circ& aCircle,
|
||||
const gp_Pnt& MidPoint,
|
||||
const gp_Pnt& Position,
|
||||
const gp_Pnt& AttachPoint,
|
||||
const gp_Pnt& Point1,
|
||||
const gp_Pnt& Point2,
|
||||
const Standard_Boolean first)
|
||||
{
|
||||
Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0;
|
||||
if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0;
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
gp_Pnt Ptmp,ptcur;
|
||||
|
||||
gp_Ax2 ax = aCircle.Position();
|
||||
ax.SetLocation(MidPoint);
|
||||
gp_Circ aCircleM (ax,rad);
|
||||
|
||||
if ( first )
|
||||
{
|
||||
// center of the symmetry - circle around the MidPoint
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Standard_Real alpha = 2*Standard_PI;
|
||||
Standard_Integer nbp = 100;
|
||||
Graphic3d_Array1OfVertex VC(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
for (Standard_Integer i = 1; i <= nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(dteta*(i-1),aCircleM);
|
||||
VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC);
|
||||
|
||||
// segment from mid point to the text position
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
if ( Position.IsEqual(MidPoint,rad) )
|
||||
Ptmp = MidPoint;
|
||||
else
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// text position
|
||||
V(2).SetCoord(Position.X(),Position.Y(),Position.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// texte
|
||||
TCollection_ExtendedString aText (" (+)");
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position);
|
||||
}
|
||||
|
||||
if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) )
|
||||
{
|
||||
// segment from mid point to the geometry
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// attach point to the geometry
|
||||
V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
}
|
||||
|
||||
// segment on circle
|
||||
Standard_Real pf = ElCLib::Parameter(aCircle,Point1);
|
||||
Standard_Real pl = ElCLib::Parameter(aCircle,Point2);
|
||||
Standard_Real alpha = pl - pf;
|
||||
if ( alpha < 0 ) alpha += 2*Standard_PI;
|
||||
Standard_Integer nb = (Standard_Integer)(50.0*alpha/PI);
|
||||
Standard_Integer nbp = Max(4,nb);
|
||||
Graphic3d_Array1OfVertex VC1(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
|
||||
for (Standard_Integer i = 1; i <= nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(pf + dteta*(i-1),aCircle);
|
||||
VC1(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC1);
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
//Function:Add
|
||||
//Purpose: draws the representation of a radial symmetry between two elliptic arcs.
|
||||
//===================================================================
|
||||
void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Elips& aCircle,
|
||||
const gp_Pnt& MidPoint,
|
||||
const gp_Pnt& Position,
|
||||
const gp_Pnt& AttachPoint,
|
||||
const gp_Pnt& Point1,
|
||||
const gp_Pnt& Point2,
|
||||
const Standard_Boolean first)
|
||||
{
|
||||
Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0;
|
||||
if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0;
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
gp_Pnt Ptmp,ptcur;
|
||||
|
||||
gp_Ax2 ax = aCircle.Position();
|
||||
ax.SetLocation(MidPoint);
|
||||
gp_Circ aCircleM (ax,rad);
|
||||
|
||||
if ( first )
|
||||
{
|
||||
// center of the symmetry - circle around the MidPoint
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Standard_Real alpha = 2*Standard_PI;
|
||||
Standard_Integer nbp = 100;
|
||||
Graphic3d_Array1OfVertex VC(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
for (Standard_Integer i = 1; i <= nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(dteta*(i-1),aCircleM);
|
||||
VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC);
|
||||
|
||||
// segment from mid point to the text position
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
if ( Position.IsEqual(MidPoint,rad) )
|
||||
Ptmp = MidPoint;
|
||||
else
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// text position
|
||||
V(2).SetCoord(Position.X(),Position.Y(),Position.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// texte
|
||||
TCollection_ExtendedString aText (" (+)");
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position);
|
||||
}
|
||||
|
||||
if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) )
|
||||
{
|
||||
// segment from mid point to the geometry
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// mid point
|
||||
Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM);
|
||||
V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z());
|
||||
// attach point to the geometry
|
||||
V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
}
|
||||
|
||||
// segment on ellipse
|
||||
Standard_Real pf = ElCLib::Parameter(aCircle,Point1);
|
||||
Standard_Real pl = ElCLib::Parameter(aCircle,Point2);
|
||||
Standard_Real alpha = pl - pf;
|
||||
if ( alpha < 0 ) alpha += 2*Standard_PI;
|
||||
Standard_Integer nb = (Standard_Integer)(50.0*alpha/PI);
|
||||
Standard_Integer nbp = Max(4,nb);
|
||||
Graphic3d_Array1OfVertex VC1(1,nbp);
|
||||
Standard_Real dteta = alpha/(nbp-1);
|
||||
|
||||
for (Standard_Integer i = 1; i <= nbp; i++)
|
||||
{
|
||||
ptcur = ElCLib::Value(pf + dteta*(i-1),aCircle);
|
||||
VC1(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
|
||||
}
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC1);
|
||||
}
|
47
src/DsgPrs/DsgPrs_OffsetPresentation.cdl
Executable file
47
src/DsgPrs/DsgPrs_OffsetPresentation.cdl
Executable file
@@ -0,0 +1,47 @@
|
||||
-- File: DsgPrs_OffsetPresentation.cdl
|
||||
-- Created: Wed Sep 18 17:27:47 1996
|
||||
-- Author: Jacques MINOT
|
||||
-- <jmi@anotax.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
class OffsetPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to define display of offsets.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection,
|
||||
ArrowSide from DsgPrs
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aDirection: Dir from gp;
|
||||
aDirection2: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Defines the display of elements showing offset shapes.
|
||||
-- These include the two points of attachment
|
||||
-- AttachmentPoint1 and AttachmentPoint1, the two
|
||||
-- directions aDirection and aDirection2, and the offset point OffsetPoint.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
AddAxes( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aDirection: Dir from gp;
|
||||
aDirection2: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: draws the representation of axes alignement Constraint
|
||||
-- between the point AttachmentPoint1 and the
|
||||
-- point AttachmentPoint2, along direction
|
||||
-- aDirection, using the offset point OffsetPoint.
|
||||
|
||||
end OffsetPresentation;
|
256
src/DsgPrs/DsgPrs_OffsetPresentation.cxx
Executable file
256
src/DsgPrs/DsgPrs_OffsetPresentation.cxx
Executable file
@@ -0,0 +1,256 @@
|
||||
// Copyright: Matra-Datavision 1996
|
||||
// File: DsgPrs_OffsetPresentation.cxx
|
||||
// Created: Wed Sep 18 17:29:20 1996
|
||||
// Author: Jacques MINOT
|
||||
// <jmi>
|
||||
|
||||
#include <DsgPrs_OffsetPresentation.ixx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <gce_MakeLin.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
|
||||
void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Dir& aDirection2,
|
||||
const gp_Pnt& OffsetPoint) {
|
||||
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Lin L1 (AttachmentPoint1,aDirection);
|
||||
gp_Lin L2 (AttachmentPoint2,aDirection2);
|
||||
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
|
||||
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
|
||||
gp_Lin L3,L4;
|
||||
Standard_Boolean DimNulle = Standard_False;
|
||||
if (!Proj1.IsEqual(Proj2,Precision::Confusion()*100.)) {
|
||||
L3 = gce_MakeLin(Proj1,Proj2);
|
||||
}
|
||||
else {
|
||||
//cout<<"DsgPrs_OffsetPresentation Cote nulle"<<endl;
|
||||
DimNulle = Standard_True;
|
||||
L3 = gp_Lin(Proj1,aDirection);
|
||||
gp_Vec v4 (Proj1,OffsetPoint);
|
||||
gp_Dir d4 (v4);
|
||||
L4 = gp_Lin(Proj1,d4); // normale
|
||||
}
|
||||
Standard_Real parmin,parmax,parcur;
|
||||
parmin = ElCLib::Parameter(L3,Proj1);
|
||||
parmax = parmin;
|
||||
parcur = ElCLib::Parameter(L3,Proj2);
|
||||
Standard_Real dist = Abs(parmin-parcur);
|
||||
if (parcur < parmin) parmin = parcur;
|
||||
if (parcur > parmax) parmax = parcur;
|
||||
parcur = ElCLib::Parameter(L3,OffsetPoint);
|
||||
gp_Pnt offp = ElCLib::Value(parcur,L3);
|
||||
|
||||
Standard_Boolean outside = Standard_False;
|
||||
if (parcur < parmin) {
|
||||
parmin = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
if (parcur > parmax) {
|
||||
parmax = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
|
||||
gp_Pnt PointMin = ElCLib::Value(parmin,L3);
|
||||
gp_Pnt PointMax = ElCLib::Value(parmax,L3);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
PointMin.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
PointMax.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
// trait de cote : 1er groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
|
||||
if (DimNulle) {
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction(),
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction().Reversed(),
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
} else {
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
|
||||
outside = Standard_True;
|
||||
}
|
||||
gp_Dir arrdir = L3.Direction().Reversed();
|
||||
|
||||
if (outside) {
|
||||
arrdir.Reverse();
|
||||
}
|
||||
// fleche 1 : 2eme groupe
|
||||
Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
// ball 1 : 3eme groupe
|
||||
|
||||
Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
|
||||
MarkerAsp->SetType(Aspect_TOM_BALL);
|
||||
MarkerAsp->SetScale(0.8);
|
||||
Quantity_Color acolor;
|
||||
Aspect_TypeOfLine atype;
|
||||
Standard_Real awidth;
|
||||
LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
|
||||
MarkerAsp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
|
||||
Graphic3d_Vertex V3d(Proj2.X() ,Proj2.Y(), Proj2.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
|
||||
// texte : 4eme groupe
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
|
||||
}
|
||||
|
||||
AttachmentPoint1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj1.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// trait de rappel 1 : 5eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
AttachmentPoint2.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// trait de rappel 2 : 6eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
}
|
||||
|
||||
void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Dir& aDirection2,
|
||||
const gp_Pnt& OffsetPoint) {
|
||||
|
||||
|
||||
|
||||
gp_Lin L1 (AttachmentPoint1,aDirection);
|
||||
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
|
||||
|
||||
gp_Lin L2 (AttachmentPoint2,aDirection);
|
||||
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Quantity_Color acolor;
|
||||
Aspect_TypeOfLine atype;
|
||||
Standard_Real awidth;
|
||||
LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
|
||||
|
||||
Handle(Graphic3d_AspectLine3d) AxeAsp = new Graphic3d_AspectLine3d (acolor, atype, awidth);
|
||||
AxeAsp->SetType( Aspect_TOL_DOTDASH);
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(AxeAsp);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
AttachmentPoint1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
Proj1.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
// trait d'axe : 1er groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Handle(Graphic3d_AspectLine3d) Axe2Asp = new Graphic3d_AspectLine3d (acolor, atype, awidth);
|
||||
Axe2Asp->SetType ( Aspect_TOL_DOTDASH);
|
||||
Axe2Asp->SetWidth ( 4.);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Axe2Asp);
|
||||
|
||||
AttachmentPoint2.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
Proj2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
// trait d'axe: 2eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// anneau : 3eme et 4eme groupes
|
||||
|
||||
Graphic3d_Vertex V3d(Proj2.X() ,Proj2.Y(), Proj2.Z());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
|
||||
MarkerAsp->SetType(Aspect_TOM_O);
|
||||
MarkerAsp->SetScale(4.);
|
||||
//MarkerAsp->SetColor(Quantity_Color(Quantity_NOC_RED));
|
||||
MarkerAsp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Handle(Graphic3d_AspectMarker3d) Marker2Asp = new Graphic3d_AspectMarker3d();
|
||||
Marker2Asp->SetType(Aspect_TOM_O);
|
||||
Marker2Asp->SetScale(2.);
|
||||
//Marker2Asp->SetColor(Quantity_Color(Quantity_NOC_GREEN));
|
||||
Marker2Asp->SetColor(acolor);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Marker2Asp);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
|
||||
|
||||
}
|
52
src/DsgPrs/DsgPrs_ParalPresentation.cdl
Executable file
52
src/DsgPrs/DsgPrs_ParalPresentation.cdl
Executable file
@@ -0,0 +1,52 @@
|
||||
-- File: DsgPrs_ParalPresentation.cdl
|
||||
-- Created: Tue Nov 28 10:13:06 1995
|
||||
-- Author: Jean-Pierre COMBE
|
||||
-- <jpi@pdalon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class ParalPresentation from DsgPrs
|
||||
---Purpose: A framework to define display of relations of parallelism between shapes.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d,
|
||||
ArrowSide from DsgPrs,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aDirection: Dir from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Defines the display of elements showing relations of
|
||||
-- parallelism between shapes.
|
||||
-- These include the two points of attachment
|
||||
-- AttachmentPoint1 and AttachmentPoint1, the
|
||||
-- direction aDirection, and the offset point OffsetPoint.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aDirection: Dir from gp;
|
||||
OffsetPoint: Pnt from gp;
|
||||
ArrowSide: ArrowSide from DsgPrs);
|
||||
---Purpose: Defines the display of elements showing relations of
|
||||
-- parallelism between shapes.
|
||||
-- These include the two points of attachment
|
||||
-- AttachmentPoint1 and AttachmentPoint1, the
|
||||
-- direction aDirection, the offset point OffsetPoint and
|
||||
-- the text aText.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
end ParalPresentation;
|
221
src/DsgPrs/DsgPrs_ParalPresentation.cxx
Executable file
221
src/DsgPrs/DsgPrs_ParalPresentation.cxx
Executable file
@@ -0,0 +1,221 @@
|
||||
// File: DsgPrs_ParalPresentation.cxx
|
||||
// Created: Tue Nov 28 10:14:40 1995
|
||||
// Author: Jean-Pierre COMBE
|
||||
// <jpi>
|
||||
|
||||
|
||||
#include <DsgPrs_ParalPresentation.ixx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
|
||||
void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& OffsetPoint) {
|
||||
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
gp_Lin L1 (AttachmentPoint1,aDirection);
|
||||
gp_Lin L2 (AttachmentPoint2,aDirection);
|
||||
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
|
||||
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
|
||||
gp_Lin L3 = gce_MakeLin(Proj1,Proj2);
|
||||
Standard_Real parmin,parmax,parcur;
|
||||
parmin = ElCLib::Parameter(L3,Proj1);
|
||||
parmax = parmin;
|
||||
parcur = ElCLib::Parameter(L3,Proj2);
|
||||
Standard_Real dist = Abs(parmin-parcur);
|
||||
if (parcur < parmin) parmin = parcur;
|
||||
if (parcur > parmax) parmax = parcur;
|
||||
parcur = ElCLib::Parameter(L3,OffsetPoint);
|
||||
gp_Pnt offp = ElCLib::Value(parcur,L3);
|
||||
|
||||
Standard_Boolean outside = Standard_False;
|
||||
if (parcur < parmin) {
|
||||
parmin = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
if (parcur > parmax) {
|
||||
parmax = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
|
||||
gp_Pnt PointMin = ElCLib::Value(parmin,L3);
|
||||
gp_Pnt PointMax = ElCLib::Value(parmax,L3);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
PointMin.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
PointMax.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
// trait de cote : 1er groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
|
||||
outside = Standard_True;
|
||||
}
|
||||
gp_Dir arrdir = L3.Direction().Reversed();
|
||||
|
||||
if (outside) {
|
||||
arrdir.Reverse();
|
||||
}
|
||||
// fleche 1 : 2eme groupe
|
||||
Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
// fleche 2 : 3eme groupe
|
||||
Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(),
|
||||
LA->Arrow2Aspect()->Angle(),
|
||||
LA->Arrow2Aspect()->Length());
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
|
||||
// texte : 4eme groupe
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
|
||||
|
||||
AttachmentPoint1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj1.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// trait de rappel 1 : 5eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
AttachmentPoint2.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
// trait de rappel 2 : 6eme groupe
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// function : DsgPrs_ParalPresentation::Add
|
||||
// purpose : ODL 4-fevrier-97
|
||||
// on peut choisir le symbol des extremites de la cote (fleche, point ...)
|
||||
//==========================================================================
|
||||
void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint1,
|
||||
const gp_Pnt& AttachmentPoint2,
|
||||
const gp_Dir& aDirection,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const DsgPrs_ArrowSide ArrowPrs){
|
||||
|
||||
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
gp_Lin L1 (AttachmentPoint1,aDirection);
|
||||
gp_Lin L2 (AttachmentPoint2,aDirection);
|
||||
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
|
||||
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
|
||||
gp_Lin L3 = gce_MakeLin(Proj1,Proj2);
|
||||
Standard_Real parmin,parmax,parcur;
|
||||
parmin = ElCLib::Parameter(L3,Proj1);
|
||||
parmax = parmin;
|
||||
parcur = ElCLib::Parameter(L3,Proj2);
|
||||
Standard_Real dist = Abs(parmin-parcur);
|
||||
if (parcur < parmin) parmin = parcur;
|
||||
if (parcur > parmax) parmax = parcur;
|
||||
parcur = ElCLib::Parameter(L3,OffsetPoint);
|
||||
gp_Pnt offp = ElCLib::Value(parcur,L3);
|
||||
|
||||
Standard_Boolean outside = Standard_False;
|
||||
if (parcur < parmin) {
|
||||
parmin = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
if (parcur > parmax) {
|
||||
parmax = parcur;
|
||||
outside = Standard_True;
|
||||
}
|
||||
|
||||
gp_Pnt PointMin = ElCLib::Value(parmin,L3);
|
||||
gp_Pnt PointMax = ElCLib::Value(parmax,L3);
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
PointMin.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
PointMax.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
// trait de cote
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
|
||||
outside = Standard_True;
|
||||
}
|
||||
gp_Dir arrdir = L3.Direction().Reversed();
|
||||
|
||||
if (outside) {
|
||||
arrdir.Reverse();
|
||||
}
|
||||
|
||||
|
||||
AttachmentPoint1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj1.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
// trait de rappel 1
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
AttachmentPoint2.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
Proj2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
// trait de rappel 2
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
|
||||
|
||||
//fleches
|
||||
DsgPrs::ComputeSymbol(aPresentation,LA,Proj1,Proj2,arrdir,arrdir.Reversed(),ArrowPrs);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
38
src/DsgPrs/DsgPrs_PerpenPresentation.cdl
Executable file
38
src/DsgPrs/DsgPrs_PerpenPresentation.cdl
Executable file
@@ -0,0 +1,38 @@
|
||||
-- File: DsgPrs_PerpenPresentation.cdl
|
||||
-- Created: Tue Nov 28 12:13:52 1995
|
||||
-- Author: Jean-Pierre COMBE
|
||||
-- <jpi@pdalon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class PerpenPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to define display of perpendicular
|
||||
-- constraints between shapes.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
pAx1: Pnt from gp;
|
||||
pAx2: Pnt from gp;
|
||||
pnt1: Pnt from gp;
|
||||
pnt2: Pnt from gp;
|
||||
OffsetPoint: Pnt from gp;
|
||||
intOut1: Boolean from Standard;
|
||||
intOut2: Boolean from Standard);
|
||||
---Purpose: Defines the display of elements showing
|
||||
-- perpendicular constraints between shapes.
|
||||
-- These include the two axis points pAx1 and pAx2,
|
||||
-- the two points pnt1 and pnt2, the offset point
|
||||
-- OffsetPoint and the two Booleans intOut1} and intOut2{.
|
||||
-- These arguments are added to the presentation
|
||||
-- object aPresentation. Their display attributes are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
|
||||
end PerpenPresentation;
|
121
src/DsgPrs/DsgPrs_PerpenPresentation.cxx
Executable file
121
src/DsgPrs/DsgPrs_PerpenPresentation.cxx
Executable file
@@ -0,0 +1,121 @@
|
||||
// File: DsgPrs_PerpenPresentation.cxx
|
||||
// Created: Tue Nov 28 12:15:12 1995
|
||||
// Author: Jean-Pierre COMBE
|
||||
// <jpi>
|
||||
|
||||
|
||||
#include <DsgPrs_PerpenPresentation.ixx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
#include <StdPrs_Point.hxx>
|
||||
|
||||
void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& pAx1,
|
||||
const gp_Pnt& pAx2,
|
||||
const gp_Pnt& pnt1,
|
||||
const gp_Pnt& pnt2,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const Standard_Boolean intOut1,
|
||||
const Standard_Boolean intOut2)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
Graphic3d_Array1OfVertex V1(1,2);
|
||||
Graphic3d_Array1OfVertex V2(1,2);
|
||||
Quantity_Length X1,Y1,Z1;
|
||||
Quantity_Length X2,Y2,Z2;
|
||||
|
||||
// 1er segment
|
||||
OffsetPoint.Coord(X1,Y1,Z1);
|
||||
V1(1).SetCoord(X1,Y1,Z1);
|
||||
pAx1.Coord(X2,Y2,Z2);
|
||||
V1(2).SetCoord(X2,Y2,Z2); //ou directt dir1.XYZ
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V1);
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
// 2e segment
|
||||
pAx2.Coord(X2,Y2,Z2);
|
||||
V2(1).SetCoord(X1,Y1,Z1);
|
||||
V2(2).SetCoord(X2,Y2,Z2);
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
|
||||
// points attache
|
||||
Graphic3d_Array1OfVertex V3(1,2);
|
||||
if (intOut1) {
|
||||
pAx1.Coord(X1,Y1,Z1);
|
||||
V3(1).SetCoord(X1,Y1,Z1);
|
||||
pnt1.Coord(X2,Y2,Z2);
|
||||
V3(2).SetCoord(X2,Y2,Z2);
|
||||
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
|
||||
}
|
||||
if (intOut2) {
|
||||
pAx2.Coord(X1,Y1,Z1);
|
||||
V3(1).SetCoord(X1,Y1,Z1);
|
||||
pnt2.Coord(X2,Y2,Z2);
|
||||
V3(2).SetCoord(X2,Y2,Z2);
|
||||
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->
|
||||
SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
|
||||
}
|
||||
|
||||
// Symbol
|
||||
Graphic3d_Array1OfVertex V4(1,3);
|
||||
gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1));
|
||||
gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2));
|
||||
Standard_Real dist1(OffsetPoint.Distance(pAx1));
|
||||
Standard_Real dist2(OffsetPoint.Distance(pAx2));
|
||||
vec1 *= dist1;
|
||||
vec1 *= .2;
|
||||
vec2 *= dist2;
|
||||
vec2 *= .2;
|
||||
|
||||
gp_Pnt pAx11 = OffsetPoint.Translated(vec1);
|
||||
gp_Pnt pAx22 = OffsetPoint.Translated(vec2);
|
||||
gp_Pnt p_symb = pAx22.Translated(vec1);
|
||||
|
||||
pAx11.Coord(X1,Y1,Z1);
|
||||
V4(1).SetCoord(X1,Y1,Z1);
|
||||
p_symb.Coord(X1,Y1,Z1);
|
||||
V4(2).SetCoord(X1,Y1,Z1);
|
||||
pAx22.Coord(X1,Y1,Z1);
|
||||
V4(3).SetCoord(X1,Y1,Z1);
|
||||
|
||||
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V4);
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
83
src/DsgPrs/DsgPrs_RadiusPresentation.cdl
Executable file
83
src/DsgPrs/DsgPrs_RadiusPresentation.cdl
Executable file
@@ -0,0 +1,83 @@
|
||||
-- File: DsgPrs_RadiusPresentation.cdl
|
||||
-- Created: Wed Mar 1 15:47:49 1995
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@houblon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class RadiusPresentation from DsgPrs
|
||||
---Purpose: A framework to define display of radii.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Circ from gp,
|
||||
Drawer from Prs3d,
|
||||
ArrowSide from DsgPrs,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
aCircle : Circ from gp;
|
||||
firstparam : Real;
|
||||
lastparam : Real;
|
||||
drawFromCenter : Boolean = Standard_True;
|
||||
reverseArrow : Boolean = Standard_False);
|
||||
---Purpose: Adds the point AttachmentPoint, the circle aCircle,
|
||||
-- the text aText, and the parameters firstparam and
|
||||
-- lastparam to the presentation object aPresentation.
|
||||
-- The display attributes of these elements is defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- If the Boolean drawFromCenter is false, the
|
||||
-- arrowhead will point towards the center of aCircle.
|
||||
-- If the Boolean reverseArrow is true, the arrowhead
|
||||
-- will point away from the attachment point.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
aCircle : Circ from gp;
|
||||
firstparam : Real;
|
||||
lastparam : Real;
|
||||
ArrowSide: ArrowSide from DsgPrs;
|
||||
drawFromCenter : Boolean = Standard_True;
|
||||
reverseArrow : Boolean = Standard_False);
|
||||
---Purpose: Adds the point AttachmentPoint, the circle aCircle,
|
||||
-- the text aText, and the parameters firstparam and
|
||||
-- lastparam to the presentation object aPresentation.
|
||||
-- The display attributes of these elements is defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- The value of the enumeration Arrowside determines
|
||||
-- the type of arrow displayed: whether there will be
|
||||
-- arrowheads at both ends or only one, for example.
|
||||
-- If the Boolean drawFromCenter is false, the
|
||||
-- arrowhead will point towards the center of aCircle.
|
||||
-- If the Boolean reverseArrow is true, the arrowhead
|
||||
-- will point away from the attachment point.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
AttachmentPoint : Pnt from gp;
|
||||
Center : Pnt from gp;
|
||||
EndOfArrow : Pnt from gp;
|
||||
ArrowSide: ArrowSide from DsgPrs;
|
||||
drawFromCenter : Boolean = Standard_True;
|
||||
reverseArrow : Boolean = Standard_False);
|
||||
---Purpose: Adds the circle aCircle, the text aText, the points
|
||||
-- AttachmentPoint, Center and EndOfArrow to the
|
||||
-- presentation object aPresentation.
|
||||
-- The display attributes of these elements is defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- The value of the enumeration Arrowside determines
|
||||
-- the type of arrow displayed: whether there will be
|
||||
-- arrowheads at both ends or only one, for example.
|
||||
-- If the Boolean drawFromCenter is false, the
|
||||
-- arrowhead will point towards the center of aCircle.
|
||||
-- If the Boolean reverseArrow is true, the arrowhead
|
||||
-- will point away from the attachment point.
|
||||
|
||||
|
||||
end RadiusPresentation;
|
191
src/DsgPrs/DsgPrs_RadiusPresentation.cxx
Executable file
191
src/DsgPrs/DsgPrs_RadiusPresentation.cxx
Executable file
@@ -0,0 +1,191 @@
|
||||
// File: DsgPrs_RadiusPresentation.cxx
|
||||
// Created: Wed Mar 1 15:50:43 1995
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
//modified 20-feb-98 by <SZY>
|
||||
// Sergei Zaritchny
|
||||
|
||||
#include <DsgPrs_RadiusPresentation.ixx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_AspectMarker.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
|
||||
|
||||
static Standard_Boolean DsgPrs_InDomain(const Standard_Real fpar,
|
||||
const Standard_Real lpar,
|
||||
const Standard_Real para)
|
||||
{
|
||||
if (fpar >= 0.) {
|
||||
return ((para >= fpar) && (para <= lpar));
|
||||
}
|
||||
if (para >= (fpar+2*PI)) return Standard_True;
|
||||
if (para <= lpar) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_RadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint,
|
||||
const gp_Circ& aCircle,
|
||||
const Standard_Real firstparam,
|
||||
const Standard_Real lastparam,
|
||||
const Standard_Boolean drawFromCenter,
|
||||
const Standard_Boolean reverseArrow)
|
||||
{
|
||||
Standard_Real fpara = firstparam;
|
||||
Standard_Real lpara = lastparam;
|
||||
while (lpara > 2*PI) {
|
||||
fpara -= 2*PI;
|
||||
lpara -= 2*PI;
|
||||
}
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Standard_Real parat = ElCLib::Parameter(aCircle,AttachmentPoint);
|
||||
gp_Pnt attpoint = AttachmentPoint;
|
||||
Standard_Boolean otherside = Standard_False;
|
||||
if ( !DsgPrs_InDomain(fpara,lpara,parat)) {
|
||||
Standard_Real otherpar = parat + PI;
|
||||
if (otherpar > 2*PI) otherpar -= 2*PI;
|
||||
if (DsgPrs_InDomain(fpara,lpara,otherpar)) {
|
||||
parat = otherpar;
|
||||
otherside = Standard_True;
|
||||
}
|
||||
else {
|
||||
Standard_Real ecartpar = Min(Abs(fpara-parat),
|
||||
Abs(lpara-parat));
|
||||
Standard_Real ecartoth = Min(Abs(fpara-otherpar),
|
||||
Abs(lpara-otherpar));
|
||||
if (ecartpar <= ecartoth) {
|
||||
if (parat < fpara) {
|
||||
parat = fpara;
|
||||
}
|
||||
else {
|
||||
parat = lpara;
|
||||
}
|
||||
}
|
||||
else {
|
||||
otherside = Standard_True;
|
||||
if (otherpar < fpara) {
|
||||
parat = fpara;
|
||||
}
|
||||
else {
|
||||
parat = lpara;
|
||||
}
|
||||
}
|
||||
gp_Pnt ptdir = ElCLib::Value(parat,aCircle);
|
||||
gp_Lin lsup(aCircle.Location(),
|
||||
gp_Dir(ptdir.XYZ()-aCircle.Location().XYZ()));
|
||||
Standard_Real parpos = ElCLib::Parameter(lsup,AttachmentPoint);
|
||||
attpoint = ElCLib::Value(parpos,lsup);
|
||||
}
|
||||
}
|
||||
gp_Pnt ptoncirc = ElCLib::Value(parat,aCircle);
|
||||
gp_Lin L (aCircle.Location(),gp_Dir(attpoint.XYZ()-aCircle.Location().XYZ()));
|
||||
gp_Pnt firstpoint = attpoint;
|
||||
gp_Pnt drawtopoint = ptoncirc;
|
||||
if (drawFromCenter && !otherside) {
|
||||
Standard_Real uatt = ElCLib::Parameter(L,attpoint);
|
||||
Standard_Real uptc = ElCLib::Parameter(L,ptoncirc);
|
||||
if (Abs(uatt) > Abs(uptc)) {
|
||||
drawtopoint = aCircle.Location();
|
||||
}
|
||||
else {
|
||||
firstpoint = aCircle.Location();
|
||||
}
|
||||
}
|
||||
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
firstpoint.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
|
||||
drawtopoint.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
gp_Dir arrdir = L.Direction();
|
||||
if (reverseArrow) {
|
||||
arrdir.Reverse();
|
||||
}
|
||||
// fleche
|
||||
Prs3d_Arrow::Draw(aPresentation,ptoncirc,arrdir,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
// texte
|
||||
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,attpoint);
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DsgPrs_RadiusPresentation::Add
|
||||
//purpose : SZY 20-february-98
|
||||
// : adds radius representation according drawFromCenter value
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_RadiusPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& AttachmentPoint,
|
||||
const gp_Pnt& Center,
|
||||
const gp_Pnt& EndOfArrow,
|
||||
const DsgPrs_ArrowSide ArrowPrs,
|
||||
const Standard_Boolean drawFromCenter,
|
||||
const Standard_Boolean reverseArrow)
|
||||
{
|
||||
Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect();
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
|
||||
|
||||
Graphic3d_Array1OfVertex VertexArray( 1, 2 );
|
||||
gp_Pnt LineOrigin, LineEnd;
|
||||
Quantity_Length X,Y,Z;
|
||||
|
||||
DsgPrs::ComputeRadiusLine( Center, EndOfArrow, AttachmentPoint, drawFromCenter,
|
||||
LineOrigin, LineEnd);
|
||||
//
|
||||
LineOrigin.Coord( X, Y, Z );
|
||||
VertexArray(1).SetCoord( X, Y, Z );
|
||||
|
||||
LineEnd.Coord( X, Y, Z );
|
||||
VertexArray(2).SetCoord( X, Y, Z );
|
||||
|
||||
Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray );
|
||||
// text
|
||||
Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, AttachmentPoint );
|
||||
|
||||
gp_Dir ArrowDir = gce_MakeDir( LineOrigin , LineEnd );
|
||||
if (reverseArrow)
|
||||
ArrowDir.Reverse();
|
||||
DsgPrs::ComputeSymbol( aPresentation, LA, Center, EndOfArrow, ArrowDir.Reversed(), ArrowDir,
|
||||
ArrowPrs, drawFromCenter );
|
||||
}
|
||||
|
33
src/DsgPrs/DsgPrs_ShadedPlanePresentation.cdl
Executable file
33
src/DsgPrs/DsgPrs_ShadedPlanePresentation.cdl
Executable file
@@ -0,0 +1,33 @@
|
||||
-- File: DsgPrs_ShadedPlanePresentation.cdl
|
||||
-- Created: Fri Dec 5 16:04:08 1997
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@robox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
class ShadedPlanePresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to define display of shaded planes.
|
||||
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp
|
||||
|
||||
is
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aPt1 : Pnt from gp;
|
||||
aPt2 : Pnt from gp;
|
||||
aPt3 : Pnt from gp);
|
||||
|
||||
---Purpose: Adds the points aPt1, aPt2 and aPt3 to the
|
||||
-- presentation object, aPresentation.
|
||||
-- The display attributes of the shaded plane are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
|
||||
end ShadedPlanePresentation;
|
44
src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx
Executable file
44
src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx
Executable file
@@ -0,0 +1,44 @@
|
||||
// File: DsgPrs_ShadedPlanePresentation.cxx
|
||||
// Created: Fri Dec 5 16:06:04 1997
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <DsgPrs_ShadedPlanePresentation.ixx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_PlaneAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_ShadedPlanePresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aPt1,
|
||||
const gp_Pnt& aPt2,
|
||||
const gp_Pnt& aPt3)
|
||||
{
|
||||
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
|
||||
TheGroup->SetPrimitivesAspect(aDrawer->PlaneAspect()->EdgesAspect()->Aspect());
|
||||
TheGroup->SetPrimitivesAspect(aDrawer->ShadingAspect()->Aspect());
|
||||
Quantity_Length x1,y1,z1,x2,y2,z2,x3,y3,z3;
|
||||
|
||||
aPt1.Coord(x1,y1,z1);
|
||||
aPt2.Coord(x2,y2,z2);
|
||||
aPt3.Coord(x3,y3,z3);
|
||||
|
||||
Graphic3d_Array1OfVertex A(1,5);
|
||||
A(1).SetCoord(x1,y1,z1);
|
||||
A(2).SetCoord(x2,y2,z2);
|
||||
A(3).SetCoord(x3,y3,z3);
|
||||
A(4).SetCoord(x1,y1,z1);
|
||||
A(5)=A(1);
|
||||
|
||||
TheGroup->Polygon(A);
|
||||
}
|
32
src/DsgPrs/DsgPrs_ShapeDirPresentation.cdl
Executable file
32
src/DsgPrs/DsgPrs_ShapeDirPresentation.cdl
Executable file
@@ -0,0 +1,32 @@
|
||||
-- File: DsgPrs_ShapeDirPresentation.cdl
|
||||
-- Created: Fri Oct 6 12:31:52 1995
|
||||
-- Author: Jing Cheng MEI
|
||||
-- <mei@junon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class ShapeDirPresentation from DsgPrs
|
||||
|
||||
---Purpose: A framework to define display of the normal to the
|
||||
-- surface of a shape.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d
|
||||
|
||||
is
|
||||
|
||||
Add(myclass; prs: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
shape: Shape from TopoDS;
|
||||
mode: Integer from Standard);
|
||||
---Purpose: Adds the shape shape and the mode mode to the
|
||||
-- presentation object prs.
|
||||
-- The display attributes of the normal are defined by the
|
||||
-- attribute manager aDrawer.
|
||||
-- mode determines whether the first or the last point of
|
||||
-- the normal is given to the presentation object. If the
|
||||
-- first point: 0; if the last point, 1.
|
||||
|
||||
end ShapeDirPresentation;
|
274
src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx
Executable file
274
src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx
Executable file
@@ -0,0 +1,274 @@
|
||||
|
||||
// File: DsgPrs_ShapeDirPresentation.cxx
|
||||
// Created: Fri Oct 6 12:33:19 1995
|
||||
// Author: Jing Cheng MEI
|
||||
// <mei@junon>
|
||||
|
||||
#include <DsgPrs_ShapeDirPresentation.ixx>
|
||||
|
||||
#include <gp.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <GeomLProp_CLProps.hxx>
|
||||
#include <GeomLProp_SLProps.hxx>
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
//#include <BRepAdaptor_Curve2d.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <BRepClass_Edge.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
#include <Quantity_Length.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindPointOnFace
|
||||
//purpose : internal use
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean FindPointOnFace(const TopoDS_Face& face, gp_Pnt2d& pt2d)
|
||||
{
|
||||
// discredisation of the external contour and computing the center of gravity
|
||||
|
||||
TopExp_Explorer wireExp;
|
||||
wireExp.Init(face, TopAbs_WIRE);
|
||||
if (!wireExp.More()) {
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Integer npoints, nptt = 21;
|
||||
TColgp_Array1OfPnt2d points(1, nptt);
|
||||
Standard_Real area=0., xcent=0., ycent=0.;
|
||||
TopExp_Explorer edgeExp;
|
||||
|
||||
for (edgeExp.Init(wireExp.Current(), TopAbs_EDGE); edgeExp.More(); edgeExp.Next()) {
|
||||
// discretize the 2d curve
|
||||
Standard_Real first, last;
|
||||
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(edgeExp.Current()), face, first, last);
|
||||
if (TopoDS::Edge(edgeExp.Current()).Orientation() == TopAbs_REVERSED) {
|
||||
Standard_Real change = first;
|
||||
first = last;
|
||||
last = change;
|
||||
}
|
||||
if (c2d->DynamicType() == STANDARD_TYPE(Geom2d_Line)) {
|
||||
npoints = 2;
|
||||
c2d->D0(first, points(1));
|
||||
c2d->D0(last, points(2));
|
||||
}
|
||||
else {
|
||||
Standard_Real deltaT, t;
|
||||
npoints = nptt;
|
||||
deltaT = (last - first) / (nptt-1);
|
||||
for (Standard_Integer i=1; i<=nptt; i++) {
|
||||
if (i == 1) {
|
||||
t = first;
|
||||
}
|
||||
else if (i == nptt) {
|
||||
t = last;
|
||||
}
|
||||
else {
|
||||
t = first + (i-1) * deltaT;
|
||||
}
|
||||
c2d->D0(t, points(i));
|
||||
}
|
||||
}
|
||||
|
||||
// compute the contribution to the center of gravity
|
||||
|
||||
Standard_Real h, c, d;
|
||||
for (Standard_Integer i=1; i<=npoints-1; i++) {
|
||||
|
||||
h = 0.5*(points(i).Y() + points(i+1).Y());
|
||||
c = points(i+1).X() - points(i).X();
|
||||
d = points(i+1).X() + points(i).X();
|
||||
area += h*c;
|
||||
xcent += 0.5*h*c*d;
|
||||
ycent += 0.5*h*h*c;
|
||||
}
|
||||
}
|
||||
|
||||
if (Abs(area) < gp::Resolution()) {
|
||||
pt2d.SetCoord(points(1).X(), points(1).Y());
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
pt2d.SetCoord(xcent / area, ycent / area);
|
||||
|
||||
// verify that (upar vpar) is a point on the face
|
||||
|
||||
BRepClass_FaceClassifier fClass(face, pt2d, gp::Resolution());
|
||||
#ifdef DEB
|
||||
TopAbs_State state =
|
||||
#endif
|
||||
fClass.State();
|
||||
if ((fClass.State() == TopAbs_OUT) || (fClass.State() == TopAbs_UNKNOWN)) {
|
||||
// try to find a point on face
|
||||
pt2d=points(1);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDir
|
||||
//purpose : internal use
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean ComputeDir(const TopoDS_Shape& shape, gp_Pnt& pt, gp_Dir& dir, const Standard_Integer mode)
|
||||
{
|
||||
TopLoc_Location loc;
|
||||
if (shape.ShapeType() == TopAbs_EDGE) {
|
||||
Standard_Real first, last;
|
||||
Handle(Geom_Curve) curv0 = BRep_Tool::Curve(TopoDS::Edge(shape), loc, first, last);
|
||||
Handle(Geom_Curve) curve = Handle(Geom_Curve)::DownCast(curv0->Copy());
|
||||
curve->Transform(loc.Transformation());
|
||||
GeomLProp_CLProps lProps(curve, 1, gp::Resolution());
|
||||
if (mode == 0) {
|
||||
lProps.SetParameter(last);
|
||||
}
|
||||
else if (mode == 1) {
|
||||
lProps.SetParameter(first);
|
||||
}
|
||||
if (!lProps.IsTangentDefined()) {
|
||||
return Standard_False;
|
||||
}
|
||||
pt = lProps.Value();
|
||||
lProps.Tangent(dir);
|
||||
}
|
||||
else if (shape.ShapeType() == TopAbs_FACE) {
|
||||
gp_Pnt2d pt2d;
|
||||
Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(shape));
|
||||
if (BRep_Tool::NaturalRestriction(TopoDS::Face(shape))) {
|
||||
Standard_Real u1, u2, v1, v2;
|
||||
surface->Bounds(u1, u2, v1, v2);
|
||||
pt2d.SetCoord((u1+u2)*0.5, (v1+v2)*0.5);
|
||||
}
|
||||
else {
|
||||
Standard_Boolean found = FindPointOnFace(TopoDS::Face(shape), pt2d);
|
||||
if (!found) {
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
GeomLProp_SLProps lProps(surface, pt2d.X(), pt2d.Y(), 1, gp::Resolution());
|
||||
if (!lProps.IsNormalDefined()) {
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
pt = lProps.Value();
|
||||
dir = lProps.Normal();
|
||||
}
|
||||
if ((shape.Orientation() == TopAbs_FORWARD) && (mode == 1) ||
|
||||
(shape.Orientation() == TopAbs_REVERSED) && (mode == 0)) {
|
||||
dir.Reverse();
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_ShapeDirPresentation::Add(const Handle(Prs3d_Presentation)& prs,
|
||||
const Handle(Prs3d_Drawer)& drawer,
|
||||
const TopoDS_Shape& shape,
|
||||
const Standard_Integer mode)
|
||||
|
||||
{
|
||||
if ((mode != 0) && (mode != 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Dir dir;
|
||||
gp_Pnt pt;
|
||||
Bnd_Box box;
|
||||
|
||||
if (shape.ShapeType() == TopAbs_EDGE) {
|
||||
ComputeDir(shape, pt, dir, mode);
|
||||
BRepBndLib::Add(shape, box);
|
||||
}
|
||||
else if (shape.ShapeType() == TopAbs_FACE) {
|
||||
ComputeDir(shape, pt, dir, mode);
|
||||
BRepBndLib::Add(shape, box);
|
||||
}
|
||||
else if (shape.ShapeType() == TopAbs_WIRE) {
|
||||
TopTools_ListOfShape aList;
|
||||
Standard_Integer nb = 0;
|
||||
BRepTools_WireExplorer anExp;
|
||||
for (anExp.Init(TopoDS::Wire(shape)); anExp.More(); anExp.Next()) {
|
||||
const TopoDS_Edge& edge = anExp.Current();
|
||||
nb++;
|
||||
if (nb <=3) {
|
||||
BRepBndLib::Add(edge, box);
|
||||
}
|
||||
aList.Append(edge);
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(aList.Last());
|
||||
ComputeDir(edge, pt, dir, mode);
|
||||
}
|
||||
else {
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(aList.First());
|
||||
ComputeDir(edge, pt, dir, mode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
TopExp_Explorer faceExp;
|
||||
|
||||
TopTools_ListOfShape aList;
|
||||
Standard_Integer nb = 0;
|
||||
for (faceExp.Init(shape, TopAbs_FACE); faceExp.More(); faceExp.Next()) {
|
||||
nb++;
|
||||
const TopoDS_Face& face = TopoDS::Face(faceExp.Current());
|
||||
aList.Append(face);
|
||||
BRepBndLib::Add(face, box);
|
||||
if (nb > 3) break;
|
||||
}
|
||||
const TopoDS_Face& face = TopoDS::Face(aList.Last());
|
||||
ComputeDir(face, pt, dir, mode);
|
||||
}
|
||||
|
||||
Standard_Real c[6];
|
||||
box.Get(c[0],c[1],c[2],c[3],c[4],c[5]);
|
||||
|
||||
gp_Pnt ptmin(c[0], c[1], c[2]), ptmax(c[3], c[4], c[5]);
|
||||
Quantity_Length leng = ptmin.Distance(ptmax)/3.;
|
||||
// mei 19/09/96 extrusion infinie -> taille fixe
|
||||
if (leng >= 20000.) leng = 50;
|
||||
|
||||
gp_Pnt pt2(pt.X()+leng*dir.X(), pt.Y()+leng*dir.Y(), pt.Z()+leng*dir.Z());
|
||||
Graphic3d_Array1OfVertex line(1,2);
|
||||
line(1).SetCoord(pt.X(), pt.Y(), pt.Z());
|
||||
line(2).SetCoord(pt2.X(), pt2.Y(), pt2.Z());
|
||||
|
||||
Prs3d_Root::CurrentGroup(prs)->SetPrimitivesAspect(drawer->LineAspect()->Aspect());
|
||||
Prs3d_Root::CurrentGroup(prs)->Polyline(line);
|
||||
|
||||
Prs3d_Arrow::Draw(prs, pt2, dir, PI/180.*10., leng*0.3);
|
||||
}
|
||||
|
||||
|
25
src/DsgPrs/DsgPrs_SymbPresentation.cdl
Executable file
25
src/DsgPrs/DsgPrs_SymbPresentation.cdl
Executable file
@@ -0,0 +1,25 @@
|
||||
-- File: DsgPrs_SymbPresentation.cdl
|
||||
-- Created: Fri Dec 8 16:44:46 1995
|
||||
-- Author: Jean-Pierre COMBE
|
||||
-- <jpi@pdalon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class SymbPresentation from DsgPrs
|
||||
---Purpose: A framework to define display of symbols.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
aText: ExtendedString from TCollection;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Adds the text aText and the point OffsetPoint to the
|
||||
-- presentation object aPresentation.
|
||||
-- The display attributes of the shaded plane are
|
||||
-- defined by the attribute manager aDrawer.
|
||||
|
||||
end SymbPresentation;
|
36
src/DsgPrs/DsgPrs_SymbPresentation.cxx
Executable file
36
src/DsgPrs/DsgPrs_SymbPresentation.cxx
Executable file
@@ -0,0 +1,36 @@
|
||||
// File: DsgPrs_SymbPresentation.cxx
|
||||
// Created: Fri Dec 8 16:45:28 1995
|
||||
// Author: Jean-Pierre COMBE
|
||||
// <jpi>
|
||||
|
||||
|
||||
#include <DsgPrs_SymbPresentation.ixx>
|
||||
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <StdPrs_Point.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
|
||||
void DsgPrs_SymbPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const TCollection_ExtendedString& aText,
|
||||
const gp_Pnt& OffsetPoint)
|
||||
{
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
Handle(Prs3d_TextAspect) TA = LA->TextAspect();
|
||||
TA->SetColor(Quantity_NOC_GREEN);
|
||||
Prs3d_Text::Draw(aPresentation,TA,aText, OffsetPoint);
|
||||
|
||||
// 2eme groupe : marker
|
||||
Handle(Geom_CartesianPoint) theP = new Geom_CartesianPoint(OffsetPoint);
|
||||
Handle(Prs3d_PointAspect) PA = aDrawer->PointAspect();
|
||||
PA->SetTypeOfMarker(Aspect_TOM_RING2);
|
||||
StdPrs_Point::Add(aPresentation,theP,aDrawer);
|
||||
}
|
||||
|
||||
|
71
src/DsgPrs/DsgPrs_SymmetricPresentation.cdl
Executable file
71
src/DsgPrs/DsgPrs_SymmetricPresentation.cdl
Executable file
@@ -0,0 +1,71 @@
|
||||
-- File: DsgPrs_SymmetricPresentation.cdl
|
||||
-- Created: Wed Jan 22 18:43:39 1997
|
||||
-- Author: Prestataire Michael ALEONARD
|
||||
-- <mal@matrox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
class SymmetricPresentation from DsgPrs
|
||||
---Purpose: A framework to define display of symmetry between shapes.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Lin from gp,
|
||||
Circ from gp,
|
||||
Drawer from Prs3d,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aDirection1: Dir from gp;
|
||||
aAxis: Lin from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Adds the points OffsetPoint, AttachmentPoint1,
|
||||
-- AttachmentPoint2, the direction aDirection1 and the
|
||||
-- axis anAxis to the presentation object aPresentation.
|
||||
-- The display attributes of the symmetry are defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- This syntax is used for display of symmetries between two segments.
|
||||
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aCircle1: Circ from gp;
|
||||
aAxis: Lin from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Adds the points OffsetPoint, AttachmentPoint1,
|
||||
-- AttachmentPoint2, the direction aDirection1 the circle
|
||||
-- aCircle1 and the axis anAxis to the presentation
|
||||
-- object aPresentation.
|
||||
-- The display attributes of the symmetry are defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- This syntax is used for display of symmetries between two arcs.
|
||||
|
||||
Add( myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
AttachmentPoint1: Pnt from gp;
|
||||
AttachmentPoint2: Pnt from gp;
|
||||
aAxis: Lin from gp;
|
||||
OffsetPoint: Pnt from gp);
|
||||
---Purpose: Adds the points OffsetPoint, AttachmentPoint1,
|
||||
-- AttachmentPoint2 and the axis anAxis to the
|
||||
-- presentation object aPresentation.
|
||||
-- The display attributes of the symmetry are defined by
|
||||
-- the attribute manager aDrawer.
|
||||
-- This syntax is used for display of symmetries between two vertices.
|
||||
|
||||
end SymmetricPresentation;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1093
src/DsgPrs/DsgPrs_SymmetricPresentation.cxx
Executable file
1093
src/DsgPrs/DsgPrs_SymmetricPresentation.cxx
Executable file
File diff suppressed because it is too large
Load Diff
27
src/DsgPrs/DsgPrs_TangentPresentation.cdl
Executable file
27
src/DsgPrs/DsgPrs_TangentPresentation.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: DsgPrs_TangentPresentation.cdl
|
||||
-- Created: Tue Jan 16 14:27:16 1996
|
||||
-- Author: Jean-Pierre COMBE
|
||||
-- <jpi@clipox>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
class TangentPresentation from DsgPrs
|
||||
---Purpose: A framework to define display of tangents.
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
Drawer from Prs3d
|
||||
|
||||
is
|
||||
Add (myclass; aPresentation: Presentation from Prs3d;
|
||||
aDrawer: Drawer from Prs3d;
|
||||
OffsetPoint: Pnt from gp;
|
||||
aDirection: Dir from gp;
|
||||
aLength : Real from Standard);
|
||||
|
||||
---Purpose: Adds the point OffsetPoint, the direction aDirection
|
||||
-- and the length aLength to the presentation object aPresentation.
|
||||
-- The display attributes of the tangent are defined by
|
||||
-- the attribute manager aDrawer.
|
||||
|
||||
end TangentPresentation;
|
67
src/DsgPrs/DsgPrs_TangentPresentation.cxx
Executable file
67
src/DsgPrs/DsgPrs_TangentPresentation.cxx
Executable file
@@ -0,0 +1,67 @@
|
||||
// File: DsgPrs_TangentPresentation.cxx
|
||||
// Created: Tue Jan 16 14:29:33 1996
|
||||
// Author: Jean-Pierre COMBE
|
||||
// <jpi>
|
||||
|
||||
|
||||
#include <DsgPrs_TangentPresentation.ixx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_LengthAspect.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <StdPrs_Point.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
|
||||
void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& OffsetPoint,
|
||||
const gp_Dir& aDirection,
|
||||
const Standard_Real length)
|
||||
{
|
||||
gp_Vec vec(aDirection);
|
||||
gp_Vec vec1 = vec.Multiplied(length);
|
||||
gp_Vec vec2 = vec.Multiplied(-length);
|
||||
gp_Pnt p1 = OffsetPoint.Translated(vec1);
|
||||
gp_Pnt p2 = OffsetPoint.Translated(vec2);
|
||||
|
||||
// Aspect
|
||||
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
|
||||
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID);
|
||||
Handle(Prs3d_ArrowAspect) ARR1 = LA->Arrow1Aspect();
|
||||
Handle(Prs3d_ArrowAspect) ARR2 = LA->Arrow2Aspect();
|
||||
ARR1->SetLength(length/5);
|
||||
ARR2->SetLength(length/5);
|
||||
|
||||
// Array1OfVertex
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Graphic3d_Array1OfVertex V(1,2);
|
||||
Quantity_Length X,Y,Z;
|
||||
p1.Coord(X,Y,Z);
|
||||
V(1).SetCoord(X,Y,Z);
|
||||
p2.Coord(X,Y,Z);
|
||||
V(2).SetCoord(X,Y,Z);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
|
||||
|
||||
// fleche 1 :
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Arrow::Draw(aPresentation,p1,aDirection,
|
||||
LA->Arrow1Aspect()->Angle(),
|
||||
LA->Arrow1Aspect()->Length());
|
||||
|
||||
// fleche 2
|
||||
Prs3d_Root::NewGroup(aPresentation);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
|
||||
Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),
|
||||
LA->Arrow2Aspect()->Angle(),
|
||||
LA->Arrow2Aspect()->Length());
|
||||
}
|
||||
|
||||
|
56
src/DsgPrs/DsgPrs_XYZAxisPresentation.cdl
Executable file
56
src/DsgPrs/DsgPrs_XYZAxisPresentation.cdl
Executable file
@@ -0,0 +1,56 @@
|
||||
-- File: DsgPrs_XYZAxisPresentation.cdl
|
||||
-- Created: Mon Feb 10 14:50:11 1997
|
||||
-- Author: Odile Olivier
|
||||
-- <odl@sacadox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
-- SAV : OCC218 06/03/02 : Add(...) overloaded to take into account arrow & text
|
||||
-- aspects.
|
||||
|
||||
class XYZAxisPresentation from DsgPrs
|
||||
---Purpose: A framework for displaying the axes of an XYZ trihedron.
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
LineAspect from Prs3d,
|
||||
Pnt from gp,
|
||||
Dir from gp,
|
||||
ArrowAspect from Prs3d,
|
||||
TextAspect from Prs3d
|
||||
|
||||
is
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
anLineAspect : LineAspect from Prs3d;
|
||||
aDir : Dir from gp;
|
||||
aVal : Real from Standard;
|
||||
aText : CString from Standard;
|
||||
aPfirst : Pnt from gp;
|
||||
aPlast : Pnt from gp);
|
||||
|
||||
---Purpose: Draws each axis of a trihedron displayed in the
|
||||
-- presentation aPresentation and with lines shown by
|
||||
-- the values of aLineAspect. Each axis is defined by:
|
||||
-- - the first and last points aPfirst and aPlast
|
||||
-- - the direction aDir and
|
||||
-- - the value aVal which provides a value for length.
|
||||
-- The value for length is provided so that the trihedron
|
||||
-- can vary in length relative to the scale of shape display.
|
||||
-- Each axis will be identified as X, Y, or Z by the text aText.
|
||||
|
||||
|
||||
Add(myclass;
|
||||
aPresentation : Presentation from Prs3d;
|
||||
aLineAspect : LineAspect from Prs3d;
|
||||
anArrowAspect : ArrowAspect from Prs3d;
|
||||
aTextAspect : TextAspect from Prs3d;
|
||||
aDir : Dir from gp;
|
||||
aVal : Real from Standard;
|
||||
aText : CString from Standard;
|
||||
aPfirst : Pnt from gp;
|
||||
aPlast : Pnt from gp);
|
||||
|
||||
---Purpose: draws the presentation X ,Y ,Z axis
|
||||
|
||||
end XYZAxisPresentation;
|
86
src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx
Executable file
86
src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx
Executable file
@@ -0,0 +1,86 @@
|
||||
// File: DsgPrs_XYZAxisPresentation.cdl
|
||||
// Created: Mon Feb 10 14:50:11 1997
|
||||
// Author: Odile Olivier
|
||||
// <odl@sacadox.paris1.matra-dtv.fr>
|
||||
//Copyright: Matra Datavision 1997
|
||||
|
||||
#define OCC218 // SAV Enable to compute the triedhron color texts and arrows.
|
||||
|
||||
|
||||
#include <DsgPrs_XYZAxisPresentation.ixx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_XYZAxisPresentation::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_LineAspect)& aLineAspect,
|
||||
const gp_Dir & aDir,
|
||||
const Standard_Real aVal,
|
||||
const Standard_CString aText,
|
||||
const gp_Pnt& aPfirst,
|
||||
const gp_Pnt& aPlast)
|
||||
{
|
||||
|
||||
|
||||
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
|
||||
|
||||
Quantity_Length xo,yo,zo,x,y,z;
|
||||
|
||||
aPfirst.Coord(xo,yo,zo);
|
||||
aPlast.Coord(x,y,z);
|
||||
|
||||
Graphic3d_Array1OfVertex A(1,2);
|
||||
A(1).SetCoord(xo,yo,zo);
|
||||
A(2).SetCoord(x,y,z);
|
||||
|
||||
G->SetPrimitivesAspect(aLineAspect->Aspect());
|
||||
G->Polyline(A);
|
||||
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),aDir,PI/180.*10.,aVal/10.);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,A(2),1./81.);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_LineAspect)& aLineAspect,
|
||||
const Handle(Prs3d_ArrowAspect)& anArrowAspect,
|
||||
const Handle(Prs3d_TextAspect)& aTextAspect,
|
||||
const gp_Dir & aDir,
|
||||
const Standard_Real aVal,
|
||||
const Standard_CString aText,
|
||||
const gp_Pnt& aPfirst,
|
||||
const gp_Pnt& aPlast)
|
||||
{
|
||||
#ifdef OCC218
|
||||
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
|
||||
|
||||
Quantity_Length xo,yo,zo,x,y,z;
|
||||
|
||||
aPfirst.Coord(xo,yo,zo);
|
||||
aPlast.Coord(x,y,z);
|
||||
|
||||
Graphic3d_Array1OfVertex A(1,2);
|
||||
A(1).SetCoord(xo,yo,zo);
|
||||
A(2).SetCoord(x,y,z);
|
||||
|
||||
#ifdef DEB
|
||||
Quantity_Length arrowAngle = anArrowAspect->Angle();
|
||||
Quantity_Length textHeight = aTextAspect->Height();
|
||||
#endif
|
||||
|
||||
G->SetPrimitivesAspect(aLineAspect->Aspect());
|
||||
G->Polyline(A);
|
||||
G->SetPrimitivesAspect( anArrowAspect->Aspect() );
|
||||
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),aDir,PI/180.*10.,aVal/10.);
|
||||
G->SetPrimitivesAspect(aTextAspect->Aspect());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,A(2),1./81.);
|
||||
#endif
|
||||
}
|
30
src/DsgPrs/DsgPrs_XYZPlanePresentation.cdl
Executable file
30
src/DsgPrs/DsgPrs_XYZPlanePresentation.cdl
Executable file
@@ -0,0 +1,30 @@
|
||||
-- File: DsgPrs_XYZPlanePresentation.cdl
|
||||
-- Created: Mon Feb 10 14:50:11 1997
|
||||
-- Author: Odile Olivier
|
||||
-- <odl@sacadox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
class XYZPlanePresentation from DsgPrs
|
||||
---Purpose: A framework for displaying the planes of an XYZ trihedron.
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Pnt from gp
|
||||
|
||||
is
|
||||
|
||||
Add(myclass;
|
||||
aPresentation: Presentation from Prs3d;
|
||||
aDrawer : Drawer from Prs3d;
|
||||
aPt1 : Pnt from gp;
|
||||
aPt2 : Pnt from gp;
|
||||
aPt3 : Pnt from gp);
|
||||
|
||||
---Purpose: Draws each plane of a trihedron displayed in the
|
||||
-- presentation aPresentation and with attributes
|
||||
-- defined by the attribute manager aDrawer. Each
|
||||
-- triangular plane is defined by the points aPt1 aPt2 and aPt3.
|
||||
|
||||
end XYZPlanePresentation;
|
46
src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx
Executable file
46
src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx
Executable file
@@ -0,0 +1,46 @@
|
||||
// File: DsgPrs_XYZPlanePresentation.cdl
|
||||
// Created: Mon Feb 10 14:50:11 1997
|
||||
// Author: Odile Olivier
|
||||
// <odl@sacadox.paris1.matra-dtv.fr>
|
||||
//Copyright: Matra Datavision 1997
|
||||
|
||||
#include <DsgPrs_XYZPlanePresentation.ixx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_PlaneAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DsgPrs_XYZPlanePresentation::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const gp_Pnt& aPt1,
|
||||
const gp_Pnt& aPt2,
|
||||
const gp_Pnt& aPt3)
|
||||
{
|
||||
|
||||
|
||||
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
|
||||
TheGroup->SetPrimitivesAspect(aDrawer->PlaneAspect()->EdgesAspect()->Aspect());
|
||||
|
||||
Quantity_Length x1,y1,z1,x2,y2,z2,x3,y3,z3;
|
||||
|
||||
aPt1.Coord(x1,y1,z1);
|
||||
aPt2.Coord(x2,y2,z2);
|
||||
aPt3.Coord(x3,y3,z3);
|
||||
|
||||
Graphic3d_Array1OfVertex A(1,4);
|
||||
A(1).SetCoord(x1,y1,z1);
|
||||
A(2).SetCoord(x2,y2,z2);
|
||||
A(3).SetCoord(x3,y3,z3);
|
||||
A(4).SetCoord(x1,y1,z1);
|
||||
|
||||
TheGroup->Polyline(A);
|
||||
|
||||
}
|
Reference in New Issue
Block a user