Exemplo n.º 1
0
void PST_Edge::points( DLIList<PST_Edge*>& edges, DLIList<PST_Point*>& points )
{
  int e;
  for( e = edges.size(); e--; )
  {
    PST_Edge* edge_ptr = edges.get_and_step();
    edge_ptr->start_point()->private_mark_ = 1;
    edge_ptr->end_point()->private_mark_ = 1;
  }
  for( e = edges.size(); e--; )
  {
    PST_Edge* edge_ptr = edges.get_and_step();
    PST_Point* sp = edge_ptr->start_point();
    PST_Point* ep = edge_ptr->end_point();
    if( sp->private_mark_ )
    {
      sp->private_mark_ = 0;
      points.append( sp );
    }
    if( ep->private_mark_ )
    {
      ep->private_mark_ = 0;
      points.append( ep );
    }
  }
}
Exemplo n.º 2
0
void PST_Edge::edges( DLIList<PST_Point*>& pts, DLIList<PST_Edge*>& edges )
{
  int p;
  for( p = pts.size(); p--; )
  {
    PST_Point* pt = pts.get_and_step();
    PST_Edge* edge = pt->edge();
    if( edge ) do
    {
      edge->private_mark_ = 1;
      edge = edge->next( pt );
    } while( edge != pt->edge() );
  }
  
  for( p = pts.size(); p--; )
  {
    PST_Point* pt = pts.get_and_step();
    PST_Edge* edge = pt->edge();
    if( edge ) do
    {
      if( edge->private_mark_ )
      {
        edge->private_mark_ = 0;
        edges.append( edge );
      }
      edge = edge->next( pt );
    } while( edge != pt->edge() );
  }
}
Exemplo n.º 3
0
void PST_Edge::edges( DLIList<PST_Face*>& faces, DLIList<PST_Edge*>& edges )
{
  int f;
  for( f = faces.size(); f--; )
  {
    PST_CoEdge* first = faces.get_and_step()->first_coedge();
    PST_CoEdge* coedge = first;
    do
    {
      coedge->edge()->private_mark_ = 1;
      coedge = coedge->next();
    } while( coedge != first );
  }
  
  for( f = faces.size(); f--; )
  {
    PST_CoEdge* first = faces.get_and_step()->first_coedge();
    PST_CoEdge* coedge = first;
    do
    {
      if( coedge->edge()->private_mark_ )
      {
        coedge->edge()->private_mark_ = 0;
        edges.append( coedge->edge() );
      }
      coedge = coedge->next();
    } while( coedge != first );
  }
}  
Exemplo n.º 4
0
void PST_Edge::faces( DLIList<PST_Edge*>& edges, DLIList<PST_Face*>& faces )
{
  int e;
  for( e = edges.size(); e--; )
  {
    PST_Edge* edge_ptr = edges.get_and_step();
    if( edge_ptr->forward()->face() )
      edge_ptr->forward()->face()->private_mark_ = 1;
    if( edge_ptr->reverse()->face() )
      edge_ptr->reverse()->face()->private_mark_ = 1;
  }
  for( e = edges.size(); e--; )
  {
    PST_Edge* edge_ptr = edges.get_and_step();
    PST_Face* fface_ptr = edge_ptr->forward()->face();
    PST_Face* rface_ptr = edge_ptr->reverse()->face();
    if( fface_ptr && fface_ptr->private_mark_ )
    {
      fface_ptr->private_mark_ = 0;
      faces.append( fface_ptr );
    }
    if( rface_ptr && rface_ptr->private_mark_ )
    {
      rface_ptr->private_mark_ = 0;
      faces.append( rface_ptr );
    }
  }
}
Exemplo n.º 5
0
//----------------------------------------------------------------
// Function: private function to update the core compound and      
//           for any movement of the body.
// Note:     input shape must have the same number of Compound
//           as the body's lumps number.
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_ModifyShape *aBRepTrsf,
                                       BRepAlgoAPI_BooleanOperation *op) 
{
  assert(aBRepTrsf != NULL || op != NULL);

  TopoDS_Compound compsolid;
  TopoDS_Shape shape;
  shape = aBRepTrsf->Shape();
  if(aBRepTrsf && myTopoDSShape)
  {
    compsolid = TopoDS::Compound(shape);
  
    if(OCCQueryEngine::instance()->OCCMap->IsBound(*myTopoDSShape) )
       OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShape, shape);
    else if (!shape.IsEqual(*myTopoDSShape))
       set_TopoDS_Shape(compsolid);
  }

  //Boolean operation works only on one lump body
  //set the lumps
  DLIList<Lump *> lumps;
  lumps = this->lumps();
  for (int i = 1; i <= lumps.size(); i++)
  {
     OCCLump *lump = CAST_TO(lumps.get_and_step(), OCCLump);
     lump->update_OCC_entity(aBRepTrsf, op);
  }

  for(int i = 0; i < mySheetSurfaces.size(); i++)
  {
    OCCSurface* surface = mySheetSurfaces.get_and_step();
    surface->update_OCC_entity(aBRepTrsf, op);
  }
  for(int i = 0; i <myShells.size() ; i++)
  {
    OCCShell* occ_shell = myShells.get_and_step();
    occ_shell->update_OCC_entity(aBRepTrsf,op);
  }

  if (aBRepTrsf && !compsolid.IsNull())
    set_TopoDS_Shape(compsolid);

  update_bounding_box(); 

  //unset marks.
  DLIList<OCCCurve*> curves;
  DLIList<OCCPoint*> points;
  get_all_curves(curves);
  get_all_points(points);

  for(int i = 0; i < curves.size(); i++)
    curves.get_and_step()->set_myMarked(CUBIT_FALSE);

  for(int i = 0; i < points.size(); i++)
    points.get_and_step()->set_myMarked(CUBIT_FALSE);
  return CUBIT_SUCCESS;
}
Exemplo n.º 6
0
void SimplifyTool::process_rounds(RefVolume* ref_volume,
                                  double min_radius, 
                                  double max_radius)
{
    DLIList<RefEdge*> edges;
    ref_volume->ref_edges(edges);

    DLIList<RefFace*> rounds;

    // a edge must have curvature within the tolerance
    for(int j = edges.size();j--;)
    {
        RefEdge* edge = edges.get_and_step();
        CubitVector loc,tan,curv;
        edge->closest_point(edge->curve_center(),loc,&tan,&curv);

        double curv_mag = curv.length();

        if(curv_mag > GEOMETRY_RESABS &&
            1.0/curv_mag >= min_radius &&
            1.0/curv_mag <= max_radius)
        {
            DLIList<RefFace*> new_rounds;
            edge->ref_faces(new_rounds);
            rounds+=new_rounds;
        }

    }

    rounds.uniquify_unordered();
    for(int i = rounds.size();i--;)
    {
        // cull any flat surfaces
        RefFace* curr_face = rounds.get_and_step();

        double curve_0,curve_1;
        curr_face->get_principal_curvatures(curr_face->center_point(),curve_0,curve_1);
        curve_0 = fabs(curve_0);
        curve_1 = fabs(curve_1);

        if((curve_0 > GEOMETRY_RESABS &&
            1.0/curve_0 >= min_radius &&
            1.0/curve_0 <= max_radius) ||
            (curve_1 > GEOMETRY_RESABS &&
            1.0/curve_1 >= min_radius &&
            1.0/curve_1 <= max_radius))     
        {
            GfxDebug::highlight_ref_face(curr_face);
        }
    }
}
Exemplo n.º 7
0
void Surface::are_positions_on( DLIList<CubitVector *> &test_position_list,
                              DLIList<CubitBoolean *> &is_on_list )
{
  CubitVector *test_position;
  CubitBoolean *is_on;
  test_position_list.reset();
  is_on_list.reset();
  for (int i=0; i<test_position_list.size(); i++)
  {
    test_position = test_position_list.get_and_step();
    is_on = is_on_list.get_and_step();
    *is_on = is_position_on( *test_position );
  }
}
Exemplo n.º 8
0
void Surface::closest_points_trimmed(DLIList<CubitVector *> &from_point_list, 
                                    DLIList<CubitVector *> &point_on_surface_list)
{
  CubitVector *from_point;
  CubitVector *point_on_surface;
  from_point_list.reset();
  point_on_surface_list.reset();
  for (int i=0; i<from_point_list.size(); i++)
  {
    from_point = from_point_list.get_and_step();
    point_on_surface = point_on_surface_list.get_and_step();
    closest_point_trimmed( *from_point, *point_on_surface );
  }
}
Exemplo n.º 9
0
//-----------------------------------------------------------------------------
// Purpose       : Determines if entities are from the same engine.
//
// Creator       : Tyronne Lim (CAT)
//
// Creation Date : 08/01/03
//-----------------------------------------------------------------------------
CubitBoolean GeometryHealerTool::same_healer_engine( DLIList<TopologyEntity*> &topo_list ) const
{
   GeometryHealerEngine *gePtr1 = get_engine(topo_list.get_and_step());
   GeometryHealerEngine *gePtr2;

   for (int i = 1; i < topo_list.size(); i++)
   {
      gePtr2 = get_engine(topo_list.get_and_step());
      if (gePtr1 != gePtr2)
      {
         return CUBIT_FALSE;   
      }
   }
   return CUBIT_TRUE;
}
Exemplo n.º 10
0
void DagDrawingTool::printDag(DLIList<ModelEntity*> &entity_list, int depth) 
{
  int i;
  for (i = entity_list.size(); i > 0; i--) {
    printDag(entity_list.get_and_step(), depth);
  }
}
Exemplo n.º 11
0
//==================================================================================
//Function:  skin_1d  (PUBLIC)
//Description:  creates a skin of the given facet entities.
//==================================================================================
CubitStatus ChollaSkinTool::skin_1d(DLIList<FacetEntity*> &facet_list,
                                   ChollaCurve *&facet_curve_mesh_ptr)
{
  CubitStatus rv = CUBIT_SUCCESS;
  
  // create a ChollaCurve if we have to (only if this is a 1D facet)
  
  if (!facet_curve_mesh_ptr)
  {
    FacetEntity *edge_ptr = facet_list.get();
    TDGeomFacet *td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
    facet_curve_mesh_ptr = new ChollaCurve( td_gm->get_block_id() );
    
    // associate all of the tooldata on the faces of this surf with the 
    // new ChollaCurve
    
    int ii;
    for (ii=0; ii<facet_list.size(); ii++)
    {
      edge_ptr = facet_list.get_and_step();
      facet_curve_mesh_ptr->add_facet( edge_ptr );
      td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
      td_gm->add_cholla_curve( facet_curve_mesh_ptr );
    }
  }
  
  // Note: the start and end points of this curve will be defined in 
  // ChollaCurve::split_curve.  The BlockPointMesh objects at these points
  // will be defined in MeshGeometryCreator::classify_node
  
  return rv;
}
Exemplo n.º 12
0
CubitStatus point_project()
{
  GeometryQueryTool *gti = GeometryQueryTool::instance();

  const char *argv = "box-w-hole.brep";
  CubitStatus status = read_geometry(1, &argv);
  if (status == CUBIT_FAILURE) exit(1);
  
  DLIList<Body*> test_bodies;
  gti->bodies(test_bodies);
  DLIList<Surface*> surfaces;
  BodySM* body = test_bodies.get()->get_body_sm_ptr();
  body->surfaces(surfaces);
  Surface* surf;
  for (int i = 0 ; i <  surfaces.size(); i++)
  {
    surf = surfaces.get_and_step();
    double d = surf->measure();
    if (d < 82.1 && d > 81.9)
      break;
  } 
  CubitVector point(1,1,-5); 
  CubitVector on_surf;
  surf->closest_point_trimmed(point, on_surf); 
  assert (fabs(on_surf.z() + 5) < 0.0001);
  assert (on_surf.y() < 1.001 && on_surf.y() > 0.999);
  assert (on_surf.x() < 2.122 && on_surf.x() > 2.121 );

  CubitVector p1(0, 1.5, -6 );
  surf->closest_point_trimmed(p1, on_surf);
  assert (fabs(on_surf.z() + 5) < 0.0001);
  assert (on_surf.y() < 2.122 && on_surf.y() > 2.121);
  assert (on_surf.x() < 0.0001 && on_surf.x() > -0.0001 );
  return CUBIT_SUCCESS;
}
Exemplo n.º 13
0
//-----------------------------------------------------------------------------
// Purpose       : Determines if entities are from the same engine.
//
// Creator       : Tyronne Lim (CAT)
//
// Creation Date : 08/01/03
//-----------------------------------------------------------------------------
CubitBoolean GeometryHealerTool::same_healer_engine( DLIList<RefEntity*> &ref_entity_list,
						                                   CubitBoolean check_children ) const
{
   DLIList<RefEntity*> complete_entity_list;

   //Check the check_children option and check all the children if necessary
   if (check_children)
   {
      //Make a complete list of all the RefEntities and their children
      DLIList<RefEntity*> temp = ref_entity_list;
      RefEntity* ref_entity_ptr;

      for (int i = 0; i < ref_entity_list.size(); i++)
      {
         ref_entity_ptr = ref_entity_list.get_and_step();
         complete_entity_list.clean_out();
         ref_entity_ptr->get_all_child_ref_entities(complete_entity_list);
         temp += complete_entity_list;
      }

      complete_entity_list.clean_out();
      complete_entity_list.merge_unique(temp);
   }

   //Now make sure all the RefEntities are from the same geometry engine
   DLIList<TopologyEntity*> te_list;
   CAST_LIST(complete_entity_list, te_list, TopologyEntity);
   return same_healer_engine(te_list);
}
Exemplo n.º 14
0
void OCCSurface::get_parents_virt( DLIList<TopologyBridge*>& parents )
{ 
  if(myShell) //shell or sheet body
  {
    parents.append(myShell);
    return;
  }

  OCCQueryEngine* oqe = (OCCQueryEngine*) get_geometry_query_engine();
  OCCBody * body = NULL;
  DLIList <OCCBody* > *bodies = oqe->BodyList;
  TopTools_IndexedDataMapOfShapeListOfShape M;
  for(int i = 0; i <  bodies->size(); i++)
  {
     body = bodies->get_and_step();
     TopExp::MapShapesAndAncestors(*(body->get_TopoDS_Shape()),
                                   TopAbs_FACE, TopAbs_SHELL, M);
     if(!M.Contains(*(get_TopoDS_Face())))
	continue;

     const TopTools_ListOfShape& ListOfShapes =
                                M.FindFromKey(*(get_TopoDS_Face()));
     if (!ListOfShapes.IsEmpty())
     {
         TopTools_ListIteratorOfListOfShape it(ListOfShapes) ;
         for (;it.More(); it.Next())
         {
           TopoDS_Shell Shell = TopoDS::Shell(it.Value());
           int k = oqe->OCCMap->Find(Shell);
           parents.append((OCCShell*)(oqe->OccToCGM->find(k))->second);
         }
     }
  }
}
Exemplo n.º 15
0
CubitStatus SimplifyTool::simplify_volumes(DLIList<RefVolume*> ref_volume_list,
                                           double surf_angle_in,
                                           DLIList<RefFace*> respect_face_list,
                                           DLIList<RefEdge*> respect_edge_list,
                                           CubitBoolean respect_rounds,
                                           CubitBoolean respect_imprints,
                                           CubitBoolean local_normals,
                                           CubitBoolean preview)
{
    ref_volume_list.uniquify_unordered();
    for(int i = ref_volume_list.size();i--;)
        simplify_volume(
        ref_volume_list.get_and_step(),
        surf_angle_in,
        respect_face_list,
        respect_edge_list,
        respect_rounds,
        respect_imprints,
        local_normals,
        preview);

    if(preview)
        GfxDebug::flush();

    return CUBIT_SUCCESS;
}
Exemplo n.º 16
0
void PointGridSearch::bounding_range(DLIList<CubitPoint*>& point_list)
{

  if ( !point_list.size() )
    return;
  
    // initialize min and max range values to the first point coordinates
  boundingRangeMinimum = point_list.get()->coordinates();
  boundingRangeMaximum = point_list.get_and_step()->coordinates();
  
    // find the min and max coordinates that completely encloses the
    // point list
  
  for (int i = 1; i < point_list.size(); i++)
    bounding_range(point_list.get_and_step());

}
Exemplo n.º 17
0
void CAMergePartner::merge_prepare(DLIList<RefEntity*> &merge_list)
{
  DLIList<CubitAttrib*> my_ca_list;
  CAMergePartner *my_camp_ptr;
  RefEntity* re_ptr;

    // get all the merge partner attributes that are on my owner
  attribOwnerEntity->find_cubit_attrib_type(CA_MERGE_PARTNER, my_ca_list);
  merge_list.clean_out();
  DLIList<ToolDataUser*> td_list, temp_td_list;
  int i;
  for (i = my_ca_list.size(); i > 0; i--)
  {
    my_camp_ptr = CAST_TO(my_ca_list.get(),CAMergePartner);
    my_ca_list.step();
    td_list.clean_out();
      // get all the objects with this unique id (which is also the merge id)
    TDUniqueId::find_td_unique_id(my_camp_ptr->merge_id(), temp_td_list);
    td_list += temp_td_list;
  }
  
    // now put those entities into the merge_list
  for (i = td_list.size(); i > 0; i--) 
  {
    re_ptr = CAST_TO(td_list.get(), RefEntity);
    if (re_ptr) 
    {
      CubitAttrib *tmp_attrib = re_ptr->get_cubit_attrib( CA_MERGE_PARTNER, CUBIT_FALSE );
      if( tmp_attrib )
        merge_list.append(re_ptr);
    }
    td_list.step();
  }
  
    // Now get bridge sense for each entity in list.
    // Add this entity to list, too.
  merge_list.append( attribOwnerEntity );
  for( i = merge_list.size(); i--; )
  {
    RefEntity* ent = merge_list.get_and_step();
    TopologyEntity* te = dynamic_cast<TopologyEntity*>(ent);
    if( te->bridge_manager()->number_of_bridges() != 1 )
      continue;
    
    my_ca_list.clean_out();
    ent->find_cubit_attrib_type(CA_MERGE_PARTNER, my_ca_list);
    assert( my_ca_list.size() < 2);
    if( !my_ca_list.size() )
      continue;
    
    my_camp_ptr = dynamic_cast<CAMergePartner*>(my_ca_list.get());
    if( my_camp_ptr->bridge_sense() == CUBIT_UNKNOWN )
      continue;
  }  
  merge_list.pop(); // take attribOwnerEntity back off list
    
  return;
}
Exemplo n.º 18
0
CubitStatus SimplifyTool::simplify_surfaces(DLIList<RefFace*> ref_face_list, 
                                            double angle_in,
                                            DLIList<RefFace*> respect_face_list,
                                            DLIList<RefEdge*> respect_edge_list,
                                            CubitBoolean respect_rounds,
                                            CubitBoolean respect_imprints,
                                            CubitBoolean local_normals,
                                            CubitBoolean preview)
{
    CubitStatus status = CUBIT_FAILURE;
    ref_face_list.uniquify_unordered();
    while(ref_face_list.size())
    {
        DLIList<RefFace*> ref_faces_in_volume;
        ref_face_list.reset();
        RefFace* cur_face = ref_face_list.get_and_step();
        RefVolume* cur_vol = cur_face->ref_volume();
        ref_faces_in_volume.append(cur_face);
        for(int i =1;i<ref_face_list.size();i++)
        {
            RefFace* face = ref_face_list.get_and_step();
            if(face->ref_volume() == cur_vol)
                ref_faces_in_volume.append(face);
        }

        if(ref_faces_in_volume.size()>1)
        {
            status = simplify_surfaces_in_volume(
                ref_faces_in_volume,
                angle_in,
                respect_face_list,
                respect_edge_list,
                respect_rounds,
                respect_imprints,
                local_normals,
                preview);
        }
        ref_face_list -= ref_faces_in_volume;
    }

    if(preview)
        GfxDebug::flush();

    return CUBIT_SUCCESS;
}
Exemplo n.º 19
0
//----------------------------------------------------------------
// Function: to update the core Surface
//           for any movement  or Boolean operation of the body.
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCSurface::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
                                         BRepAlgoAPI_BooleanOperation *op)
{
  assert(aBRepTrsf != NULL || op != NULL);

  TopoDS_Shape shape;
  if (aBRepTrsf)
    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Face());
  else
  {
    TopTools_ListOfShape shapes;
    shapes.Assign(op->Modified(*get_TopoDS_Face()));
    if(shapes.Extent() == 0)
         shapes.Assign(op->Generated(*get_TopoDS_Face()));
    if (shapes.Extent() == 1)
      shape = shapes.First();
    else if(shapes.Extent() > 1)
    {
      //update all attributes first.
      TopTools_ListIteratorOfListOfShape it;
      it.Initialize(shapes);
      for(; it.More(); it.Next())
      {
        shape = it.Value();
        OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Face(), shape);
      }
      shape = shapes.First();
    }
    else if(op->IsDeleted(*get_TopoDS_Face()))
      ;
    else
      return CUBIT_SUCCESS;
  }
 
  TopoDS_Face surface; 
  if(!shape.IsNull())
    surface = TopoDS::Face(shape);

  if (aBRepTrsf) 
  {
    //set the loops
    DLIList<OCCLoop *> loops;
    this->get_loops(loops);
    for (int i = 1; i <= loops.size(); i++)
    {
       OCCLoop *loop = loops.get_and_step();
       loop->update_OCC_entity(aBRepTrsf, op);
    }
    OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
  }

  else if(op)
    update_OCC_entity(*myTopoDSFace, surface, op);

  return CUBIT_SUCCESS;
}
Exemplo n.º 20
0
int PST_Edge::validate( DLIList<PST_Edge*>& edges, CubitBoolean print )
{
  DLIList<PST_Face*> faces;
  PST_Edge::faces( edges, faces );
  
  int result = 0;
  for( int f = faces.size(); f--; )
    result += faces.get_and_step()->validate(print);
  return result;
}
Exemplo n.º 21
0
void DagDrawingTool::get_relatives( DLIList<ModelEntity*>& source_set,
	DLIList<ModelEntity*>& result_set, int direction )
{
	DLIList<ModelEntity*> temp_set;
	result_set.clean_out();
	for( int i = 0; i < source_set.size();  i++ )
	{
		get_relatives( source_set.get_and_step(), temp_set, direction );
		result_set.merge_unique( temp_set );
	}
}
Exemplo n.º 22
0
//-------------------------------------------------------------------------
// Purpose       : Get the bounding box of the object.
//
// Special Notes :
//
//-------------------------------------------------------------------------
CubitBox FacetLump::bounding_box() const 
{
  CubitBox my_box, temp_box;
  DLIList<FacetSurface*> surfaces;
  int ii;
  const_cast<FacetLump*>(this)->get_surfaces(surfaces);
  if (surfaces.size() > 0)
  {
    Surface* surface = surfaces.get_and_step();
    my_box = surface->bounding_box();
    for ( ii = surfaces.size(); ii > 1; ii-- )
    {
      surface = surfaces.get_and_step();
      temp_box = surface->bounding_box();
        //unite the boxes..
      my_box |= temp_box;
    }
  }
  return my_box;
}
Exemplo n.º 23
0
DagNodeRow::DagNodeRow( DLIList<ModelEntity*>& node_list )
{
	length_ = node_list.size();
	array_ = 0;
	if( length_ > 0 )
	{
		array_ = new ModelEntity*[length_];
		node_list.reset();
		for( int i = 0; i < length_; i++ )
			array_[i] = node_list.get_and_step();
	}
}
Exemplo n.º 24
0
//-------------------------------------------------------------------------
// Purpose       : Returns the volume of the Lump
//
// Special Notes :
//
// Creator       : 
//
// Creation Date : 
//-------------------------------------------------------------------------
double FacetLump::measure()
{
  DLIList<CubitFacet*> bounding_facets;
  DLIList<CubitPoint*> bounding_points;
  DLIList<FacetSurface*> surfaces;
  Surface *curr_surface;
  FacetSurface *facet_surface;
    //if this is a sheet body... return 0.0
  
    //Body *tmp_body = CAST_TO(myBodyPtr->topology_entity(), Body);
  if( is_sheet() ) 
    return 0.0;
  
  int ii;
  get_surfaces(surfaces);
  if (surfaces.size() > 0)
  { 
    for ( ii = surfaces.size(); ii > 0; ii-- )
    {
      curr_surface = surfaces.get_and_step();
      facet_surface = CAST_TO(curr_surface, FacetSurface);
      if ( facet_surface == NULL )
      {
        PRINT_ERROR("Facet lump has surfaces that aren't facets?");
        return 1;
      }
      facet_surface->get_my_facets(bounding_facets, bounding_points);
    }
  }
  double volume, curr_facet_area, summation = 0.0;
  CubitFacet *curr_facet;
  CubitVector normal_of_curr_facet, vector_of_point;
  CubitPoint *point_1, *point_2, *point_3;

  for( int jj = bounding_facets.size(); jj > 0; jj-- )
  {
    curr_facet = bounding_facets.get_and_step();
    curr_facet_area = curr_facet->area();  // Current facet's area
    
    normal_of_curr_facet = curr_facet->normal(); // Current facet's normal

    curr_facet->points(point_1, point_2, point_3); // Current facet's points

    vector_of_point = point_1->coordinates(); // One point's vector

    summation += ( double(vector_of_point % normal_of_curr_facet) * curr_facet_area);
  }

  volume = summation / 3;
  
  return volume;
}
Exemplo n.º 25
0
//-------------------------------------------------------------------------
// Purpose       : Disconnect input surfaces from "this" shell 
//
// Special Notes : 
//
// Creator       : Corey Ernst 
//
// Creation Date : 08/31/04
//-------------------------------------------------------------------------
void FacetShell::disconnect_surfaces( DLIList<FacetSurface*> &surfs_to_disconnect )
{
  for (int i = surfs_to_disconnect.size(); i--; )
  {
    FacetSurface* surface = surfs_to_disconnect.get_and_step();
    if( mySurfs.move_to( dynamic_cast<Surface*>(surface) ) )
      mySurfs.change_to(NULL);

    if (surface)
      surface->remove_shell(this);
  }
  mySurfs.remove_all_with_value( NULL );
}
Exemplo n.º 26
0
void DagDrawingTool::print_dag( ModelEntity* node_ptr, int indent, int depth )
{
	DLIList<ModelEntity*> relatives;
	if( depth > 0 ) {
		node_ptr->get_children( &relatives );
		for( int i = relatives.size(); i > 0; i-- ) {
			ModelEntity* child_ptr = relatives.get_and_step();
				
			print_node( child_ptr, indent, "<>" );
			print_dag( child_ptr, indent + 1, depth - 1 );
		}
	}
	else if( depth < 0 ) {
		node_ptr->get_parents( &relatives );
		for( int i = relatives.size(); i > 0; i-- ) {
			ModelEntity* parent_ptr = relatives.get_and_step();
				
			print_dag( parent_ptr, indent + 1, depth + 1 );
			print_node( parent_ptr, indent, "<>" );
		}
	}
}
Exemplo n.º 27
0
void Faceter::max_min_edge_ratio( DLIList <DLIList <CubitPoint*>*> &boundary_point_loops,
                                  double &ratio,
                                  double &cell_size)
{
  double max_edge_length = CUBIT_DBL_MIN;
  double min_edge_length = CUBIT_DBL_MAX;
  double sum = 0.0;
  int total_count = 0;
  DLIList<CubitPoint*> *loopPtr;
  CubitPoint *node1, *node2;
  CubitVector edge;
  for (int i = boundary_point_loops.size(); i > 0; i--) {
    loopPtr = boundary_point_loops.get_and_step();
    node2 = loopPtr->prev();
    for (int j = loopPtr->size(); j > 0; j--) {
      node1 = node2;
      node2 = loopPtr->get_and_step();
      CubitVector p1 = node1->coordinates();
      CubitVector p2 = node2->coordinates();
      edge = p2-p1;
      double edge_length = edge.length_squared();
      if (edge_length > max_edge_length) max_edge_length = edge_length;
      if (edge_length < min_edge_length) min_edge_length = edge_length;
      total_count++;
      sum += edge_length;
    }
  }

  if (min_edge_length > CUBIT_RESABS) {
    ratio = sqrt(max_edge_length/min_edge_length);
  }
  else {
    ratio = sqrt(max_edge_length);
  }
  if ( total_count > 0 && sum > 0 )
    cell_size = sqrt(sum/total_count);
  else
    cell_size = 0.0;
}
Exemplo n.º 28
0
RefEdge* RefEdge::get_other_curve(RefVertex* common_vertex,
                         RefFace* ref_face_ptr)
{
  DLIList<RefEdge*> curves;
  ref_face_ptr->ref_edges(curves);
  for(int ii = curves.size(); ii>0; ii--)
  {
    RefEdge* temp_edge = curves.get_and_step();
    if((temp_edge->is_directly_related(common_vertex)) &&
       (this != temp_edge))
       return temp_edge;
  }
  return NULL;
}
Exemplo n.º 29
0
void PST_Edge::debug_draw_edges(  DLIList<PST_Edge*>& edge_list,
                            int color, int boundary_color,
                            bool flush )
{
  if( !boundary_color ) boundary_color = color;
  
  for( int e = edge_list.size(); e--; )
  {
    PST_Edge* edge_ptr = edge_list.get_and_step();
    int c = !edge_ptr->forward()->face() || !edge_ptr->reverse()->face()
       ? boundary_color : color;
    edge_ptr->debug_draw( c, false );
  }
  if( flush ) GfxDebug::flush();
}
Exemplo n.º 30
0
//-------------------------------------------------------------------------
// Purpose       : Used to be OCCQueryEngine::is_point_in_body
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 05/10/04
//-------------------------------------------------------------------------
CubitPointContainment OCCBody::point_containment( const CubitVector &point )
{
  CubitPointContainment pc_value;
  OCCLump *lump;

  int i;
  for( i=myLumps.size(); i--;)
  {
    lump = dynamic_cast<OCCLump*>(myLumps.get_and_step()); 
    pc_value = lump->point_containment( point );
    if( pc_value == CUBIT_PNT_INSIDE )
      return CUBIT_PNT_INSIDE;
    else if( pc_value == CUBIT_PNT_BOUNDARY )
      return CUBIT_PNT_BOUNDARY;
  }

  for(int i = 0; i < mySheetSurfaces.size(); i++)
  {
    OCCSurface* surface = mySheetSurfaces.get_and_step();
    pc_value = surface->point_containment( point );
    if( pc_value == CUBIT_PNT_INSIDE )
      return CUBIT_PNT_INSIDE;
    else if( pc_value == CUBIT_PNT_BOUNDARY )
      return CUBIT_PNT_BOUNDARY;
  }

  for(int i = 0; i <myShells.size() ; i++)
  {
    OCCShell* occ_shell = myShells.get_and_step();
    DLIList<TopologyBridge*> children;
    occ_shell->get_children_virt(children);
    for(int j = 0; j < children.size(); j++)
    {
      OCCSurface* surface = CAST_TO(children.get_and_step(), OCCSurface); 
      pc_value = surface->point_containment( point );
      if( pc_value == CUBIT_PNT_INSIDE )
        return CUBIT_PNT_INSIDE;
      else if( pc_value == CUBIT_PNT_BOUNDARY )
        return CUBIT_PNT_BOUNDARY;
    } 
  }
  return CUBIT_PNT_OUTSIDE;
}