// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
#include <DsgPrs_MidPointPresentation.ixx>
#include <Precision.hxx>
#include <ElCLib.hxx>
#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Root.hxx>
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 * M_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);
- }
+ {
+ // center of the symmetry - circle around the MidPoint
+ Prs3d_Root::NewGroup(aPresentation);
+ Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
+
+ const Standard_Real alpha = 2. * M_PI;
+ const Standard_Integer nbp = 100;
+ const Standard_Real dteta = alpha/(nbp-1);
+
+ Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2);
+ aPrims->AddBound(nbp);
+ for (Standard_Integer i = 1; i <= nbp; i++)
+ aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM));
+
+ // segment from mid point to the text position
+ aPrims->AddBound(2);
+ aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point
+ aPrims->AddVertex(Position); // text position
+
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ // texte
+ TCollection_ExtendedString aText(" (+)");
+ Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position);
+ }
if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) )
+ {
+ if ( !first )
{
- // 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 from mid point to the geometry
+ Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
+ aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); // mid point
+ aPrims->AddVertex(AttachPoint); // attach point to the geometry
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+ }
}
//===================================================================
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 * M_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);
+
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2);
+ aPrims->AddVertex(Point1);
+ aPrims->AddVertex(Point2);
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ if ( first )
+ {
+ // center of the symmetry - circle around the MidPoint
+ const Standard_Real alpha = 2. * M_PI;
+ const Standard_Integer nbp = 100;
+ const Standard_Real dteta = alpha/(nbp-1);
+
+ aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2);
+ aPrims->AddBound(nbp);
+ for (Standard_Integer i = 1; i <= nbp; i++)
+ aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM));
+
+ // segment from mid point to the text position
+ aPrims->AddBound(2);
+ aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point
+ aPrims->AddVertex(Position); // text position
+
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ // texte
+ TCollection_ExtendedString aText (" (+)");
+ Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position);
+ }
+
+ if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) )
+ {
+ // mid point
+ aPrims = new Graphic3d_ArrayOfSegments(2);
+ aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM));
+ aPrims->AddVertex(AttachPoint); // attach point to the geometry
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+ }
}
//===================================================================
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 * M_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);
+ Prs3d_Root::NewGroup(aPresentation);
+ Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
+
+ const Standard_Real pf = ElCLib::Parameter(aCircle,Point1);
+ const Standard_Real pl = ElCLib::Parameter(aCircle,Point2);
Standard_Real alpha = pl - pf;
- if ( alpha < 0 ) alpha += 2 * M_PI;
- Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI);
+ if ( alpha < 0 ) alpha += 2. * M_PI;
+ const Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI);
Standard_Integer nbp = Max(4,nb);
- Graphic3d_Array1OfVertex VC1(1,nbp);
Standard_Real dteta = alpha/(nbp-1);
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(nbp);
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);
+ aPrims->AddVertex(ElCLib::Value(pf + dteta*(i-1),aCircle));
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ if ( first )
+ {
+ // center of the symmetry - circle around the MidPoint
+ alpha = 2. * M_PI;
+ nbp = 100;
+ dteta = alpha/(nbp-1);
+
+ aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2);
+ aPrims->AddBound(nbp);
+ for (Standard_Integer i = 1; i <= nbp; i++)
+ aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM));
+
+ // segment from mid point to the text position
+ aPrims->AddBound(2);
+ aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point
+ aPrims->AddVertex(Position); // text position
+
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ // 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
+ aPrims = new Graphic3d_ArrayOfSegments(2);
+ aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); // mid point
+ aPrims->AddVertex(AttachPoint); // attach point to the geometry
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+ }
}
//===================================================================
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;
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 * M_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);
+ Prs3d_Root::NewGroup(aPresentation);
+ Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
+
+ const Standard_Real pf = ElCLib::Parameter(aCircle,Point1);
+ const Standard_Real pl = ElCLib::Parameter(aCircle,Point2);
Standard_Real alpha = pl - pf;
if ( alpha < 0 ) alpha += 2 * M_PI;
- Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI);
+ const Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI);
Standard_Integer nbp = Max(4,nb);
- Graphic3d_Array1OfVertex VC1(1,nbp);
Standard_Real dteta = alpha/(nbp-1);
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(nbp);
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);
+ aPrims->AddVertex(ElCLib::Value(pf + dteta*(i-1),aCircle));
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ if ( first )
+ {
+ // center of the symmetry - circle around the MidPoint
+ alpha = 2. * M_PI;
+ nbp = 100;
+ dteta = alpha/(nbp-1);
+
+ aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2);
+ aPrims->AddBound(nbp);
+ for (Standard_Integer i = 1; i <= nbp; i++)
+ aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM));
+
+ // segment from mid point to the text position
+ aPrims->AddBound(2);
+ aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point
+ aPrims->AddVertex(Position); // text position
+
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+
+ // 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
+ aPrims = new Graphic3d_ArrayOfSegments(2);
+ aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); // mid point
+ aPrims->AddVertex(AttachPoint); // attach point to the geometry
+ Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+ }
}