コード例 #1
0
ファイル: CubitFacetEdge.cpp プロジェクト: chrismullins/cgma
//====================================================================== 
// Function: dist_to_edge 
// Description: return the distance from the point to this edge 
// Author: sjowen 
// Date: 2/01 
// Corrected by JFowler 5/03
//====================================================================== 
double CubitFacetEdge::dist_to_edge( 
  const CubitVector &this_point,  
  CubitVector &close_point,  
  CubitBoolean &outside_edge ) 
{ 
  double dist = 0.0; 
  CubitVector p0 = point(0)->coordinates(); 
  CubitVector p1 = point(1)->coordinates(); 
  CubitVector edge_vec( p1, p0 ); 
  CubitVector point_vec( this_point, p0 ); 
  double edge_length;  
  edge_length = edge_vec.normalize(); 
  double dist_on_edge = edge_vec % point_vec; 
  if (dist_on_edge < 0.0e0) 
  { 
    close_point = p0; 
    outside_edge = CUBIT_TRUE; 
  } 
  else if (dist_on_edge > edge_length) 
  { 
    close_point = p1; 
    outside_edge = CUBIT_TRUE; 
  } 
  else 
  { 
    close_point = p0 - edge_vec * dist_on_edge; 
    outside_edge = CUBIT_FALSE; 
  } 
  dist = close_point.distance_between( this_point );  
  return dist; 
}
コード例 #2
0
ファイル: OCCSurface.cpp プロジェクト: tenpercent/cp-sandbox
CubitPointContainment OCCSurface::point_containment( const CubitVector &point )
{
   TopoDS_Face *face = get_TopoDS_Face();
   gp_Pnt p(point.x(), point.y(), point.z());
   double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();

   //It's checking the state of the projected point of THIS Point
   BRepClass_FaceClassifier face_classifier;
   face_classifier.Perform(*face, p, tol);
   TopAbs_State state = face_classifier.State();
   
   //if surface is part of a periodic TopoDS_Face, it'll check the point
   //againt the whole periodic Face, even it outside the occsurface 
   //boundary, if it's on its periodic extension, it'll return as in. 
   if (state == TopAbs_IN)
   {
     //double check if the point is projected on the surface
     CubitVector closest_point;
     this->closest_point_trimmed(point, closest_point);
     if(point.distance_between(closest_point) < tol) 
       return CUBIT_PNT_INSIDE;
     else
       return CUBIT_PNT_OUTSIDE;
   }
   else if (state == TopAbs_OUT)
     return CUBIT_PNT_OUTSIDE;
   else if (state == TopAbs_ON)
     return CUBIT_PNT_BOUNDARY;

   return CUBIT_PNT_UNKNOWN;
}
コード例 #3
0
ファイル: CubitFacetEdge.cpp プロジェクト: chrismullins/cgma
//====================================================================== 
// Function: length 
// Description: return length of an edge 
// Author: sjowen 
// Date: 2/01 
//====================================================================== 
double CubitFacetEdge::length() 
{ 
  CubitVector start = point(0)->coordinates(); 
  CubitVector end = point(1)->coordinates(); 
  return start.distance_between( end ); 
}