Ejemplo n.º 1
0
double RefEdge::get_chord_length()
{
  CubitVector start_pos(start_vertex()->coordinates());
  CubitVector end_pos(start_vertex()->coordinates());
  double distance = (start_pos - end_pos).length();
  return distance;
}
Ejemplo n.º 2
0
CubitVector RefEdge::curve_center()
{
  CubitVector p1 = start_vertex()->coordinates();
  CubitVector p2 = end_vertex()->coordinates();
  if ( start_vertex() == end_vertex() )
    {
      mid_point(p2);
    }
  p1 += p2;
  p1 /= 2.0;
  return p1;
}
Ejemplo n.º 3
0
RefVertex *RefEdge::other_vertex( RefVertex *vertex )
{
  if ( vertex == start_vertex() )
  { 
    return end_vertex();
  }
  else if ( vertex == end_vertex() )
  {
    return start_vertex();
  }
  else
  {
    return NULL;
  }
}
Ejemplo n.º 4
0
//-------------------------------------------------------------------------
// Purpose       : Initializes the member data of the RefEdge
//
// Special Notes :
//
// Creator       : Malcolm J. Panthaki
//
// Creation Date : 10/07/96
//-------------------------------------------------------------------------
void RefEdge::initialize()
{
    // Initialize some member data
  refEdgeClone = 0;
  markedFlag = CUBIT_FALSE;

    // Make sure the arc length is not zero if there are start and end 
    // RefVertex'es already assigned to this RefEdge
  if ( get_arc_length() < CUBIT_DBL_MIN )  
  {
    if ( start_vertex() && end_vertex() )
    {
      CubitVector start_pt = start_vertex()->coordinates();
      CubitVector end_pt   = end_vertex()->coordinates();
      PRINT_WARNING ( "(RefEdge::initialize): Edge has zero arclength.\n"
                      "  Start vertex location is (%9.2f, %9.2f, %9.2f ).\n"
                      "  End   vertex location is (%9.2f, %9.2f, %9.2f ).\n",
          start_pt.x(), start_pt.y(), start_pt.z(),
          end_pt.x(), end_pt.y(), end_pt.z() );
    }
    else if (!mSuppressEdgeLengthWarning)
    {
      PRINT_WARNING( "Edge found with zero arclength\n"
                     "  For cones, this may be normal.\n");
    }
    
  }
  
    // Set the Entity ID for this new RefEdge
   GeometryEntity* geom_ptr = get_geometry_entity_ptr();
   int saved_id = geom_ptr->get_saved_id();
   if ( !saved_id || RefEntityFactory::instance()->get_ref_edge(saved_id) )
   {
     saved_id =  RefEntityFactory::instance()->next_ref_edge_id();
     geom_ptr->set_saved_id(saved_id);
   }
   entityId = saved_id;
  
     // read and initialize attributes
   auto_read_cubit_attrib();
   auto_actuate_cubit_attrib();

     // Assign a default entity name
   assign_default_name();
}
Ejemplo n.º 5
0
double RefEdge::fraction_from_arc_length(RefVertex *root_vertex,
                                         double     length)
{
  if (root_vertex != start_vertex() && root_vertex != end_vertex())
    return -1.0;
 
  if (geometry_type() == POINT_CURVE_TYPE || get_arc_length() < GEOMETRY_RESABS)
    return 0.0;
 
  if (length >= get_arc_length())
    return 1.0;

  if (root_vertex == start_vertex())
    return length/get_arc_length();

  else
    return 1-length/get_arc_length();
}
Ejemplo n.º 6
0
RefVertex *RefEdge::common_ref_vertex( RefEdge *next_ref_edge,
                                       RefFace *ref_face_ptr )
{
  CoEdge *co_edge_this = NULL;
  CoEdge *co_edge_next = NULL;
  
    //First get the two coedges that corrispond to
    //this ref_edge an the next one, with reference to
    //the ref_face_ptr.
  CubitStatus status = get_two_co_edges( next_ref_edge,
                                         ref_face_ptr,
                                         co_edge_this,
                                         co_edge_next );
  if (status == CUBIT_FAILURE )
      return NULL;
  assert(co_edge_this != NULL );
  assert(co_edge_next != NULL );
  RefVertex *common_vertex;
  
    //Now according to the sense get the vertex at the
    //end of this edge (start if reversed).
  if ( co_edge_this->get_sense() == CUBIT_FORWARD )
      common_vertex = end_vertex();
  else
      common_vertex = start_vertex();
  
    //Lets just do a sanitiy check...
  if (common_vertex == NULL ||
      !next_ref_edge->is_directly_related( common_vertex )) {
    
      // let's check for bad sense, then print warning and return
      // correct vertex
    common_vertex = other_vertex(common_vertex);
    if (common_vertex != NULL &&
        next_ref_edge->is_directly_related( common_vertex )) {
      
      PRINT_ERROR(" bad sense between curve %d and surface %d; please"
                  " report this.\n", id(), ref_face_ptr->id());
    }
    else {
      PRINT_ERROR("unable to find common vertex (curves %d, %d)",
                  this->id(), next_ref_edge->id());
      assert(CUBIT_TRUE);
      return (RefVertex*)NULL;
    }
  }
    //Hurray, Success...
  return common_vertex;
}
Ejemplo n.º 7
0
RefVertex *RefEdge::common_ref_vertex( RefEdge *other_edge )
{
  RefVertex *this_start = start_vertex();
  RefVertex *this_end   = end_vertex();
  RefVertex *other_start = other_edge->start_vertex();
  RefVertex *other_end   = other_edge->end_vertex();
  
  if ( this_start == other_start || this_start == other_end )
  {
    return this_start;
  }
  else if ( this_end == other_start || this_end == other_end )
  {
    return this_end;
  }
  else
  {
    return NULL;
  }
}
Ejemplo n.º 8
0
CubitBoolean RefEdge::common_vertices( RefEdge *other_edge,
                                       DLIList<RefVertex*> &common_verts)
{
  CubitBoolean result = CUBIT_FALSE;
  RefVertex *this_start = start_vertex();
  RefVertex *this_end   = end_vertex();
  RefVertex *other_start = other_edge->start_vertex();
  RefVertex *other_end   = other_edge->end_vertex();
  
  if ( this_start == other_start || this_start == other_end )
  {
    common_verts.append(this_start);
    result = CUBIT_TRUE;
  }
  if ( this_end == other_start || this_end == other_end )
  {
    common_verts.append(this_end);
    result = CUBIT_TRUE;
  }

  return result;
}
Ejemplo n.º 9
0
//-------------------------------------------------------------------------
// Purpose       : Spatially compare two RefEdges.  Does not go down to EDGE
//                 level.  It does it at the ref_edge level so the parameter
//                 values are consistant.
//
// Special Notes :
//
// Creator       : David White
//
// Creation Date : 04/07/97
//-------------------------------------------------------------------------
CubitBoolean RefEdge::about_spatially_equal(
    RefEdge* ref_edge_ptr_2,
    double tol_factor,
    CubitSense* sensePtr,
    CubitBoolean notify_refEntity )

{
  if( this == ref_edge_ptr_2)
  {
    if (sensePtr)
      *sensePtr = CUBIT_FORWARD;
    if (notify_refEntity)
      remove_compare_data();
    return CUBIT_TRUE;
  }
  
  CubitBoolean spatially_equal = CUBIT_FALSE;
  CubitSense rel_sense = CUBIT_FORWARD;
  CubitStatus stat = CUBIT_SUCCESS;
  stat = relative_sense( ref_edge_ptr_2, tol_factor,
                         &rel_sense, spatially_equal);

  if (stat != CUBIT_SUCCESS || !spatially_equal)
  {
    return CUBIT_FALSE;
  }

  if (sensePtr)
    *sensePtr = rel_sense;

    //compare the start and end vertices to be spatially equal.
  RefVertex* this_start = start_vertex();
  RefVertex* this_end = end_vertex();
  RefVertex* edge2_start = ref_edge_ptr_2->start_vertex();
  RefVertex* edge2_end = ref_edge_ptr_2->end_vertex();
  
    // Swap vertices to simplify things later.
  if (rel_sense == CUBIT_REVERSED)
    std::swap(edge2_start, edge2_end);

    //compare vertex locations unless force_merge is true.
      // closed curve case
    if (this_start == this_end || edge2_start == edge2_end)
    {
      if ((this_start != this_end)   ||
          (edge2_start != edge2_end) ||
          !this_start->about_spatially_equal(edge2_start, tol_factor, CUBIT_FALSE))
        return CUBIT_FALSE;
    }
    else
    {
      if ((this_start == edge2_end) ||
          (this_end == edge2_start) ||
          !this_start->about_spatially_equal(edge2_start, tol_factor, CUBIT_FALSE) ||
          !this_end->about_spatially_equal(edge2_end, tol_factor, CUBIT_FALSE))
        return CUBIT_FALSE;
    }

    //Now if they match report it.
    //Do vertices explicitly here rather than in
    //RefVertex::about_spatially_equal(..) because we don't call 
    //RefVertex::about_spatially_equal(..) if force_merge is true.
  if (notify_refEntity)
  {
    this->comparison_found(ref_edge_ptr_2);
    if (this_start != edge2_start)
      this_start->comparison_found(edge2_start);
    else
      this_start->remove_compare_data();
    if (this_end != edge2_end)
      this_end->comparison_found(edge2_end);
    else
      this_end->remove_compare_data();
  }
  
  return CUBIT_TRUE;
}
Ejemplo n.º 10
0
void process_drivingDistance(G &graph, const std::vector<std::string> &tokens) {
      std::string::size_type sz;
      if (tokens[1].compare("from") != 0) {
        std::cout << "missing 'from' kewyword\n";
        return;
      }

      std::vector< int64_t > sources;
      unsigned int i_ptr = 2;

      for ( ; i_ptr < tokens.size(); ++i_ptr) {
          if (tokens[i_ptr].compare("dist") == 0) break;
          try {
            uint64_t start_vertex(stol(tokens[i_ptr], &sz));
            sources.push_back(start_vertex);
          } catch(...) {
            break;
          }
      }

      if (i_ptr == tokens.size() || tokens[i_ptr].compare("dist") != 0) {
        std::cout << "drivDist: 'dist' kewyword not found\n";
        return;
      }

      if (sources.size() == 0) {
        std::cout << "drivDist: No start value found\n";
        return;
      }

      ++i_ptr;
      if (i_ptr == tokens.size()) {
        std::cout << " 'distance' value not found\n";
        return;
      }

      double distance = stod(tokens[i_ptr], &sz);

      ++i_ptr;
      bool equiCost(false);
      if (i_ptr != tokens.size()) {
        if (tokens[i_ptr].compare("equi") != 0) {
          std::cout << " Unknown keyword '" << tokens[i_ptr] << "' found\n";
          return;
        } else {
          equiCost = true;
        }
      }

      std::cout << "found " << sources.size() << "starting locations\n";
      Pgr_dijkstra< G > fn_dijkstra;

      if (sources.size() == 1) {
        std::cout << "Performing pgr_DrivingDistance for single source\n";
        Path path;
        pgr_drivingDistance(graph, path, sources[0], distance);
        std::cout << "\t\t\tTHE OPUTPUT\n";
        std::cout << "seq\tfrom\tnode\tedge\tcost\n";
        path.print_path();
      } else {
        std::deque< Path >  paths;
        pgr_drivingDistance(graph, paths, sources, distance);
        if (equiCost == false) {
          std::cout << "Performing pgr_DrivingDistance for multiple sources\n";
          std::cout << "\t\t\tTHE OPUTPUT\n";
          std::cout << "seq\tfrom\tnode\tedge\tcost\n";
          for (const auto &path :  paths) {
            if (sizeof(path) == 0) return;  // no solution found
            path.print_path();
          }
        } else {
          std::cout << "Performing pgr_DrivingDistance for multiple sources with equi-cost\n";
          Path path = equi_cost(paths);
          std::cout << "\t\t\tTHE EquiCost OPUTPUT\n";
          std::cout << "seq\tfrom\tnode\tedge\tcost\n";
          path.print_path();
        }
      }
}