gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
OCCVertex.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "GmshConfig.h"
7 #include "GModel.h"
8 #include "MVertex.h"
9 #include "MPoint.h"
10 #include "OCCVertex.h"
11 #include "OCCEdge.h"
12 #include "OCCFace.h"
13 
14 #if defined(HAVE_OCC)
15 
16 #include "GModelIO_OCC.h"
17 #include <gp_Pnt.hxx>
18 
19 OCCVertex::OCCVertex(GModel *m, TopoDS_Vertex v, int num, double lc)
20  : GVertex(m, num, lc), _v(v)
21 {
22  gp_Pnt pnt = BRep_Tool::Pnt(_v);
23  _x = pnt.X();
24  _y = pnt.Y();
25  _z = pnt.Z();
26 }
27 
28 void OCCVertex::setPosition(GPoint &p)
29 {
30  _x = p.x();
31  _y = p.y();
32  _z = p.z();
33  if(mesh_vertices.size()) {
34  mesh_vertices[0]->x() = p.x();
35  mesh_vertices[0]->y() = p.y();
36  mesh_vertices[0]->z() = p.z();
37  }
38 }
39 
40 SPoint2 OCCVertex::reparamOnFace(const GFace *gf, int dir) const
41 {
42  std::vector<GEdge *> const &l = gf->edges();
43  for(auto ge : l_edges) {
44  if(std::find(l.begin(), l.end(), ge) != l.end()) {
46  ge->getNativeType() == GEntity::OpenCascadeModel) {
47  const TopoDS_Face *s = (TopoDS_Face *)gf->getNativePtr();
48  const TopoDS_Edge *c = (TopoDS_Edge *)ge->getNativePtr();
49  double s1, s0;
50  Handle(Geom2d_Curve) curve2d =
51  BRep_Tool::CurveOnSurface(*c, *s, s0, s1);
52  if(ge->getBeginVertex() == this)
53  return ge->reparamOnFace(gf, s0, dir);
54  else if(ge->getEndVertex() == this)
55  return ge->reparamOnFace(gf, s1, dir);
56  }
57  else {
58  const GPoint pt = point();
59  SPoint3 sp(pt.x(), pt.y(), pt.z());
60  return gf->parFromPoint(sp);
61  }
62  }
63  }
64 
65  // normally never here
66  return GVertex::reparamOnFace(gf, dir);
67 }
68 
69 #endif
GFace::edges
virtual std::vector< GEdge * > const & edges() const
Definition: GFace.h:121
GPoint::y
double y() const
Definition: GPoint.h:22
GFace
Definition: GFace.h:33
SPoint2
Definition: SPoint2.h:12
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
GEntity::OpenCascadeModel
@ OpenCascadeModel
Definition: GEntity.h:82
OCCFace.h
SPoint3
Definition: SPoint3.h:14
OCCVertex.h
GModelIO_OCC.h
GEntity::getNativeType
virtual ModelType getNativeType() const
Definition: GEntity.h:268
MPoint.h
GPoint
Definition: GPoint.h:13
GPoint::z
double z() const
Definition: GPoint.h:23
GEntity::getNativePtr
virtual void * getNativePtr() const
Definition: GEntity.h:271
OCCEdge.h
GVertex
Definition: GVertex.h:23
MVertex.h
GModel
Definition: GModel.h:44
GFace::parFromPoint
virtual SPoint2 parFromPoint(const SPoint3 &, bool onSurface=true, bool convTestXYZ=false) const
Definition: GFace.cpp:1254
GVertex::reparamOnFace
virtual SPoint2 reparamOnFace(const GFace *gf, int) const
Definition: GVertex.cpp:49
GModel.h
GPoint::x
double x() const
Definition: GPoint.h:21