示例#1
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;
}
示例#2
0
//=============================================================================
//Function:  get_vertices (PUBLIC)
//Description: get the list of ChollaPoints on this surface
//Author: sjowen
//Date: 09/11/09
//=============================================================================
void ChollaSurface::get_vertices( DLIList<ChollaPoint *> &chpt_list )
{
  chpt_list.clean_out();
  ChollaCurve *chcurv_ptr;
  for (int ii=0; ii<curveList.size(); ii++)
  {
    chcurv_ptr = curveList.get_and_step();
    DLIList<ChollaPoint *> chc_pts = chcurv_ptr->get_points(); 
    chpt_list += chc_pts;
  }
  chpt_list.uniquify_unordered();
}
示例#3
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);
        }
    }
}
示例#4
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;
}
示例#5
0
CubitStatus SimplifyTool::simplify_curves_in_volume(
    DLIList<RefEdge*> ref_edge_list, 
    double angle_in,
    DLIList<RefEdge*> respect_edge_list,
    DLIList<RefVertex*> respect_vertex_list,
    CubitBoolean respect_imprints,
    CubitBoolean local_normals,
    CubitBoolean preview)
{
  if(local_normals){
    PRINT_WARNING("When simplifying curves, 'local_normals' is currently ignored.\n");
  }
  
    if(ref_edge_list.size()==0)
    {
        PRINT_ERROR("No curves specified for simplification\n");
        return CUBIT_FAILURE;
    }
    else if(ref_edge_list.size() == 1)
    {
        PRINT_ERROR("Only one curve specified for simplification\n");
        return CUBIT_FAILURE;
    }

    RefVolume* ref_volume = ref_edge_list.get()->ref_volume();
    if (NULL == ref_volume)
    {
      PRINT_WARNING("Simplifying free curves is not supported.\n"); 
      return CUBIT_FAILURE;
    }

    DLIList<RefEdge*> seed_edges;
    DLIList<RefVertex*> preview_vertices;
    DLIList<RefVertex*> preview_removed;

    if(preview)
        ref_volume->ref_vertices(preview_vertices);

    int j,k;

    int new_edge_count = 0;
    int combined_edge_count = 0;
    ProgressTool *prog_ptr = 0;
    if(ref_edge_list.size() > 100 )
    {
        char title[200];
        if(preview)
            sprintf(title, "Previewing Volume %d",ref_volume->id());
        else
            sprintf(title, "Simplifying Curves in Volume %d",ref_volume->id());

        prog_ptr = AppUtil::instance()->progress_tool();
        assert(prog_ptr != NULL);
        prog_ptr->start(0,100, title);
    }
    int start_edge_count = ref_edge_list.size();
    while(ref_edge_list.size())
    {
        DLIList<RefEdge*> composite_edges;
        seed_edges.append_unique(ref_edge_list.pop());

        for ( j = ref_edge_list.size(); j--; )
            ref_edge_list.get_and_step()->marked( CUBIT_FALSE );

        while(seed_edges.size())
        {
            RefEdge *seed_ref_edge = seed_edges.pop();
            seed_ref_edge->marked(CUBIT_TRUE);

            composite_edges.append(seed_ref_edge);

            // Get the vertices
            DLIList<RefVertex*> ref_vertex_list;
            seed_ref_edge->ref_vertices( ref_vertex_list );
            RefVertex *ref_vertex_ptr;
            RefEdge *ref_edge_ptr;
            for( k = ref_vertex_list.size(); k--; )
            {
                ref_vertex_ptr = ref_vertex_list.get_and_step();

                // Don't go propagate across surface splits if the user asks for it
                GeometryFeatureTool* gft = GeometryFeatureTool::instance();
                if( respect_imprints &&
                    gft->feature_type(ref_vertex_ptr) == GeometryFeatureEngine::FEATURE_IMPRINT)
                    continue;

                // Don't cross a curve if we want it respected
                if(respect_vertex_list.is_in_list(ref_vertex_ptr))
                    continue;

                DLIList<RefEdge*> attached_ref_edges;
                ref_vertex_ptr->ref_edges( attached_ref_edges );

                attached_ref_edges.remove(seed_ref_edge);
                ref_edge_ptr = attached_ref_edges.size()!=0?attached_ref_edges.get():0;

                // keep the face if we want it respected
                if(attached_ref_edges.size() == 1 &&
                    respect_edge_list.is_in_list(attached_ref_edges.get()))
                    continue;

                // Don't consider ref_faces that are already in the list
                if( attached_ref_edges.size() == 1 &&
                    !ref_edge_ptr->marked())
                {
                    DLIList<RefVolume*> ref_volumes;
                    ref_edge_ptr->ref_volumes( ref_volumes );
                    if( !ref_volumes.size() || ref_volumes.size()==1 )
                    {
                        // Only add the ref_face if it meets the feature angle criteria
                        if(composite_curves(seed_ref_edge,ref_edge_ptr,angle_in))
                        {
                          ref_edge_ptr->marked( CUBIT_TRUE );
                          seed_edges.append(ref_edge_ptr);
                          composite_edges.append(ref_edge_ptr);
                        }
                    }
                }
            }
        }
        composite_edges.uniquify_unordered();
        ref_edge_list -= composite_edges;

        if(!preview &&
            composite_edges.size()>1)
        {
            DLIList<RefVertex*> result_vertices;
            DLIList<RefEdge*> result_edges;
            CompositeTool::instance()->composite(
                composite_edges,
                result_edges,
                &result_vertices);

            combined_edge_count +=composite_edges.size();
            for(int m = result_edges.size();m--;)
                result_edges.get_and_step()->marked(CUBIT_TRUE);

            new_edge_count+=result_edges.size();
        }
        else if(preview)
        {
            int edge_count = composite_edges.size();
            for(int i =0;i<edge_count;i++)
            {
                RefEdge* cur_comp_edge = composite_edges[i];
                DLIList<RefVertex*> refvertices; 
                for(int j =0;j<edge_count;j++)
                {
                    if(i==j) continue;
                    composite_edges[j]->ref_vertices(refvertices);
                }

                refvertices.uniquify_unordered();

                DLIList<RefVertex*> temp_refvertices; 
                cur_comp_edge->ref_vertices(temp_refvertices);
                refvertices.intersect_unordered(temp_refvertices);
                preview_removed+=refvertices;
            }
        }

        if(prog_ptr)
        {
            double frac = 1.0-(double)ref_edge_list.size()/(double)start_edge_count;
            prog_ptr->percent(frac);
        }
    }

    if(prog_ptr)
    {
        prog_ptr->end();
        prog_ptr = 0;
    }

    if(preview)
    {
        preview_vertices -=preview_removed;
        for(int c = preview_vertices.size();c--;)
            GfxDebug::draw_ref_vertex(preview_vertices.get_and_step(),7);
    }
    else if(combined_edge_count>new_edge_count)
    {
        PRINT_INFO("Simplified %d curves into %d curves\n",
            combined_edge_count,
            new_edge_count);
	}

	// make sure to set all of the surface markers to false
	DLIList<RefEdge*> marked_edge_list;
	ref_volume->ref_edges(marked_edge_list);
	for(int i =0;i<marked_edge_list.size();i++)
		marked_edge_list[i]->marked(CUBIT_FALSE);

    return CUBIT_SUCCESS;
}