1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and / or modify it
6 // under the terms of the GNU Lesser General Public version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Prs3d_Point_H__
15 #define _Prs3d_Point_H__
18 #include <Graphic3d_ArrayOfPoints.hxx>
19 #include <Graphic3d_Vertex.hxx>
20 #include <Graphic3d_Group.hxx>
21 #include <Prs3d_Drawer.hxx>
22 #include <Prs3d_PointAspect.hxx>
23 #include <Prs3d_Root.hxx>
24 #include <Quantity_Length.hxx>
26 template <class AnyPoint, class PointTool>
27 class Prs3d_Point : Prs3d_Root
33 Standard_EXPORT static void DrawPoint
34 (const AnyPoint& thePoint,
35 const Handle(Graphic3d_Group) theGroup)
37 Quantity_Length aX,aY,aZ;
38 PointTool::Coord(thePoint,aX,aY,aZ);
39 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
40 anArrayOfPoints->AddVertex (aX, aY, aZ);
41 theGroup->AddPrimitiveArray (anArrayOfPoints);
45 Standard_EXPORT static void Add
46 (const Handle (Prs3d_Presentation)& thePresentation,
47 const AnyPoint& thePoint,
48 const Handle (Prs3d_Drawer)& theDrawer)
50 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
51 aGroup->SetPrimitivesAspect(theDrawer->PointAspect()->Aspect());
52 DrawPoint(thePoint, aGroup);
55 Standard_EXPORT static Standard_Boolean Match
56 (const AnyPoint& thePoint,
57 const Quantity_Length theX,
58 const Quantity_Length theY,
59 const Quantity_Length theZ,
60 const Quantity_Length theDistance)
62 Quantity_Length aX,aY,aZ;
63 PointTool::Coord(thePoint, aX, aY, aZ);
64 return Sqrt((theX - aX)*(theX - aX) + (theY - aY)*(theY - aY)
65 + (theZ - aZ)*(theZ - aZ)) <= theDistance;