当前位置: 首页>>代码示例>>C++>>正文


C++ ON_SimpleArray类代码示例

本文整理汇总了C++中ON_SimpleArray的典型用法代码示例。如果您正苦于以下问题:C++ ON_SimpleArray类的具体用法?C++ ON_SimpleArray怎么用?C++ ON_SimpleArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ON_SimpleArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ON_Base32ToString

bool ON_Base32ToString( const ON_SimpleArray<unsigned char>& base32_digits, ON_String& sBase32 )
{
  int digit_count = base32_digits.Count();
  sBase32.ReserveArray(digit_count);
  sBase32.SetLength(digit_count);
  bool rc = ON_Base32ToString( base32_digits, digit_count, sBase32.Array() );
  if (!rc)
    sBase32.SetLength(0);
  return rc;
}
开发者ID:ToMadoRe,项目名称:v4r,代码行数:10,代码来源:opennurbs_base32.cpp

示例2: ON_Intersect_MeshLine

RH_C_FUNCTION ON_SimpleArray<ON_CMX_EVENT>* ON_Intersect_MeshLine(const ON_Mesh* pConstMesh, ON_3DPOINT_STRUCT from, ON_3DPOINT_STRUCT to, int* count)
{
  ON_SimpleArray<ON_CMX_EVENT>* rc = NULL;
  if( pConstMesh )
  {
    ON_3dPoint start(from.val);
    ON_3dPoint end(to.val);
    ON_Line line(start, end);
#if defined(RHINO_V5SR) // only available in V5
    const ON_MeshTree* mesh_tree = pConstMesh->MeshTree(true);
#else
    const ON_MeshTree* mesh_tree = pConstMesh->MeshTree();
#endif
    if( mesh_tree )
    {
      rc = new ON_SimpleArray<ON_CMX_EVENT>();
      if( mesh_tree->IntersectLine(line, *rc) && count )
        *count = rc->Count();
    }
  }
  return rc;
}
开发者ID:JohannesKu,项目名称:rhinocommon,代码行数:22,代码来源:on_intersect.cpp

示例3: ON_Hatch_Explode

RH_C_FUNCTION void ON_Hatch_Explode(const ON_Hatch* pConstHatch,
                                    const CRhinoObject* pConstParentRhinoObject,
                                    ON_SimpleArray<ON_Geometry*>* pOutputGeometry)
{
  if( pConstHatch && pOutputGeometry )
  {
    ON_SimpleArray<CRhinoObject*> subobjects;
    CRhinoHatch hatchobject;
    if( NULL==pConstParentRhinoObject )
    {
      hatchobject.SetHatch(*pConstHatch);

      // 5 September 2012 S. Baer (Super-Mega-Hack)
      // The hatch object needs to create a cached hatch display in order
      // for GetSubObjects to properly work.  We need to eventually fix
      // the problem in the core, buit for now I'm just calling Pick since
      // it will create a HatchDisplay when one doesn't exist
      CRhinoPickContext pc;
      CRhinoObjRefArray ar;
      hatchobject.Pick(pc, ar);

      pConstParentRhinoObject = &hatchobject;
    }

    pConstParentRhinoObject->GetSubObjects(subobjects);
    for( int i=0; i<subobjects.Count(); i++ )
    {
      CRhinoObject* pRhinoObject = subobjects[i];
      if( pRhinoObject )
      {
        const ON_Geometry* pGeometry = pRhinoObject->Geometry();
        if( pGeometry )
          pOutputGeometry->Append( pGeometry->Duplicate() );
        delete pRhinoObject;
      }
    }
  }
}
开发者ID:JohannesKu,项目名称:rhinocommon,代码行数:38,代码来源:on_hatch.cpp

示例4: Create

bool ON_Hatch::Create( const ON_Plane& plane,
                       const ON_SimpleArray<const ON_Curve*> loops,
                       int pattern_index,
                       double pattern_rotation,
                       double pattern_scale)
{
  if( loops.Count() < 1)
    return false;
  if( pattern_index < 0)
    return false;
  SetPlane( plane);
  for( int i = 0; i < loops.Count(); i++)
  {
    ON_HatchLoop* pLoop = new ON_HatchLoop;
    pLoop->SetCurve( *loops[i]);
    pLoop->SetType( i?ON_HatchLoop::ltInner:ON_HatchLoop::ltOuter);
    AddLoop( pLoop);
  }
  SetPatternIndex( pattern_index);
  SetPatternRotation( pattern_rotation);
  SetPatternScale( pattern_scale);
  return true;
}
开发者ID:cciechad,项目名称:brlcad,代码行数:23,代码来源:opennurbs_hatch.cpp

示例5: RemapUuids

void ON_UuidList::RemapUuids( const ON_SimpleArray<ON_UuidPair>& uuid_remap )
{
  if( m_count > 0 && uuid_remap.Count() > 0 )
  {
    bool bRemapped = false;
    int i, j;
    for ( i = 0; i < m_count; i++ )
    {
      j = uuid_remap.BinarySearch( (const ON_UuidPair*)&m_a[i], ON_UuidPair::CompareFirstUuid );
      if ( j >= 0 )
      {
        if ( ON_max_uuid == m_a[i] )
          continue;
        m_sorted_count = 0;
        bRemapped = true;
        m_a[i] = uuid_remap[j].m_uuid[1];
        if ( ON_max_uuid == m_a[i] )
          m_removed_count++;
      }
    }

    if ( bRemapped )
    {
      m_sorted_count = 0;
      SortHelper();
      for ( i = m_count-1; i > 0; i-- )
      {
        if ( m_a[i] == m_a[i-1] )
        {
          Remove(i);
          m_sorted_count--;
        }
      }
    }
  }
}
开发者ID:Bastl34,项目名称:PCL,代码行数:36,代码来源:opennurbs_array.cpp

示例6: ON_Intersect_MeshPolyline1

RH_C_FUNCTION ON_SimpleArray<ON_CMX_EVENT>* ON_Intersect_MeshPolyline1(const ON_Mesh* pMesh, const ON_PolylineCurve* pCurve, int* count)
{
  ON_SimpleArray<ON_CMX_EVENT>* rc = NULL;
  if( pMesh && pCurve && count )
  {
    *count = 0;
#if defined(RHINO_V5SR) // only available in V5
    const ON_MeshTree* mesh_tree = pMesh->MeshTree(true);
#else
    const ON_MeshTree* mesh_tree = pMesh->MeshTree();
#endif
    if( mesh_tree )
    {
      rc = new ON_SimpleArray<ON_CMX_EVENT>();
      int pline_count = pCurve->m_pline.Count();
      const ON_3dPoint* points = pCurve->m_pline.Array();
      if( mesh_tree->IntersectPolyline(pline_count, points, *rc) )
      {
        *count = rc->Count();
      }
    }
  }
  return rc;
}
开发者ID:JohannesKu,项目名称:rhinocommon,代码行数:24,代码来源:on_intersect.cpp

示例7: RGB

void CTestOptionsListCtrlDialog::CreateGroup( 
        CRhinoUiOptionsListCtrlGroupComboBox& combo,
        const wchar_t* lpsItem,
        CRhinoUiOptionsListCtrlGroupComboBox* pNestedCombo
        )
{
  const wchar_t* text[] = { L"A", L"B" }; 
  COLORREF colors[] = { RGB(255,0,0), RGB(0,255,0) };
  const int cnt = _countof( text );
  ON_SimpleArray<CRhinoUiOptionsListCtrlItem*> items;
  items.Reserve( cnt );
  items.SetCount( 0 );
  int i;
  for( i = 0; i < cnt; i++)
  {
    //CRhinoUiOptionsListCtrlItem* p = new CRhinoUiOptionsListCtrlStaticText();
    CRhinoUiOptionsListCtrlColorButton* p = new CRhinoUiOptionsListCtrlColorButton();
    if( NULL == p )
      continue;
    items.Append( p );
    p->SetLabel( lpsItem );
    p->SetText( text[i] );
    p->SetColor( colors[i] );
    p->SetIndentLevel( combo.IndentLevel()+1 );
    //ctrl.AddItem( p );
  }
  if( items.Count() < 1 )
    return;

  if( pNestedCombo)
  {
    pNestedCombo->SetLabel( L"Nested group combo" );
    items.Append( pNestedCombo );
  }

  combo.AddGroupItem( lpsItem, items );

  if( pNestedCombo )
  {
    pNestedCombo->SetIndentLevel( combo.IndentLevel()+1 );

    pNestedCombo->AddGroupItem( L"No controls", NULL, 0 );
    CRhinoUiOptionsListCtrlColorButton* pNested = new CRhinoUiOptionsListCtrlColorButton();
    if( pNested )
    {
      pNested->SetLabel(L"Nested group item" );
      pNested->SetText( L"" );
      pNested->SetColor( 0x00000000 );
      pNested->SetIndentLevel( pNestedCombo->IndentLevel()+1 );
      CRhinoUiOptionsListCtrlItem* p = static_cast<CRhinoUiOptionsListCtrlItem*>(pNested);
      pNestedCombo->AddGroupItem( L"color button", &p, 1 );
    }
    pNestedCombo->SetCurGroupSel( 0 );
  }
}
开发者ID:buonmethuoc,项目名称:Rhino4Samples_CPP,代码行数:55,代码来源:TestOptionsListCtrlDialog.cpp

示例8: script1PlugIn

CRhinoCommand::result CGenPianoVis::RunCommand( const CRhinoCommandContext& context )
{

  Cscript1PlugIn& plugin = script1PlugIn();

  if( !plugin.IsDlgVisible() )
  {
    return CRhinoCommand::nothing;
  }


  /*GET THE LAYER NAME*/
  CRhinoGetString gs;
  gs.SetCommandPrompt( L"NAME OF LAYER WHICH CONTAINS VISIONAL PLANE : " );
  gs.GetString();
  if( gs.CommandResult() != CRhinoCommand::success )
  {
	  return gs.CommandResult();
  }
  /*VALIDATE THE STRING*/
  ON_wString layer_name = gs.String();
  layer_name.TrimLeftAndRight();
  if( layer_name.IsEmpty() )
  {
	  return CRhinoCommand::cancel;
  }
    
  /*GET A REFERENCE TO THE LAYER TABLE*/
  CRhinoLayerTable& layer_table = context.m_doc.m_layer_table;
 
  /*FIND THE LAYER*/ 
  int layer_index = layer_table.FindLayer(layer_name );
  if( layer_index < 0 )
  {
    RhinoApp().Print( L"LAYER \"%s\" DOES NOT EXIST.\n", layer_name );
	
  }
  else
  {
	  ON_Layer currentLayer;
	  int numLayers = layer_table.LayerCount();
	  layer_table.SetCurrentLayerIndex(layer_index);
	  for(int i = 0; i < numLayers; i++)
	  {
		  if(i != layer_index)
		  {
			  currentLayer = layer_table[i];
			  currentLayer.SetVisible(false);
			  layer_table.ModifyLayer(currentLayer, i);
		  }
	  }
	  context.m_doc.Redraw();
	  const CRhinoLayer& layer = context.m_doc.m_layer_table[layer_index];
	  ON_SimpleArray<CRhinoObject*> obj_list;

	 
	  
      int object_count = context.m_doc.LookupObject( layer, obj_list );
      if( object_count > 0 )
      {
		 /********************************************************************/
		 //CRhinoObject* obj = obj_list[0];
		 //if( obj && obj->IsSelectable() )
		 //{
			// obj->Select(true);
			// obj->Highlight(true);
			// m_doc.Redraw();
		 //}
		 /********************************************************************/
		 //aniello gegin
		 // Disable redrawing
		 //CRhinoView::EnableDrawing( FALSE ); meglio tenerlo disabilitato altrimenti la schermata non si aggiorna.
 
         // Get the next runtime object serial number before scripting
		 unsigned int first_sn = CRhinoObject::NextRuntimeObjectSerialNumber();
	     //aniello end
	     /////////////////////
		  
		 CRhinoGetObject gc;
		 gc.SetCommandPrompt( L"SELECT LINE TO EXTEND" );
         gc.SetGeometryFilter( CRhinoGetObject::curve_object );
         gc.GetObjects( 1, 1 );
		 if(gc.CommandResult() == CRhinoCommand::success )
		 {
			const CRhinoObjRef& objref = gc.Object(0);
            const ON_Curve* pC = ON_Curve::Cast( objref.Geometry() );
			ON_Curve* crv0 = pC->DuplicateCurve();
			
			bool rc0 = RhinoExtendCurve(crv0, CRhinoExtend::Line, 1, 5);
			bool rc1 = RhinoExtendCurve(crv0, CRhinoExtend::Line, 0, 15);
			context.m_doc.ReplaceObject(objref, *crv0 );
            context.m_doc.Redraw();

			///// begin prova memorizzazione id o name linea pv
		////ON_UUID uuid1 = gc->Attributes().m_uuid;
		////	ON_UUID uuid1 = objref.ObjectUuid();
		//	//ON_UuidToString( uuid1, cvrPrima );
		//	 const CRhinoObject* obj5 = objref.Object();
  //          ON_UUID uuid1 = obj5->Attributes().m_uuid;

//.........这里部分代码省略.........
开发者ID:caffeina,项目名称:PluginMonti,代码行数:101,代码来源:cmdscript1.cpp

示例9: FindAdjacentFaces

static void FindAdjacentFaces(const ON_MeshTopology& Top, 
                              ON_SimpleArray<int>& FacesToCheck, 
                              const ON_SimpleArray<int>& SortedFaceArray,
                              ON_SimpleArray<int>& DupFaceArray,
                              bool bUseVertexConnections, 
                              bool bTopologicalConnections)
{
  int fi, vi, ei, facecount = FacesToCheck.Count(), totalcount = SortedFaceArray.Count();
  DupFaceArray.Zero();
  ON_SimpleArray<int> OldFacesToCheck = FacesToCheck;

  FacesToCheck.Empty();

  for (fi=0;fi<facecount;fi++)
  {
    if (totalcount > OldFacesToCheck[fi])
    {
      if (0 == SortedFaceArray[OldFacesToCheck[fi]])
      {
        FacesToCheck.Append(OldFacesToCheck[fi]);
        DupFaceArray[OldFacesToCheck[fi]] = 1;
      }

      if (false == bUseVertexConnections)
      {
        int j;
        const ON_MeshTopologyFace& face = Top.m_topf[OldFacesToCheck[fi]];
        for(ei=0;ei<(face.IsQuad()?4:3);ei++)
        {
          const ON_MeshTopologyEdge& edge = Top.m_tope[face.m_topei[ei]];

          if (1 == edge.m_topf_count || (false == bTopologicalConnections && true == IsUnweldedEdge(face.m_topei[ei], Top)))
            continue;

          for(j=0;j<edge.m_topf_count;j++)
          {  
            if (0 == SortedFaceArray[edge.m_topfi[j]] && 1 != DupFaceArray[edge.m_topfi[j]])
            {
              FacesToCheck.Append(edge.m_topfi[j]);
              DupFaceArray[edge.m_topfi[j]] = 1;
            }
          }
        }
      }
      else
      {
        int j, k, m;
        ON_3fPoint Pt;
        const ON_MeshFace& face = Top.m_mesh->m_F[OldFacesToCheck[fi]];
        for(vi=0;vi<(face.IsQuad()?4:3);vi++)
        {
          const ON_MeshTopologyVertex& vertex = Top.m_topv[Top.m_topv_map[face.vi[vi]]];
          for (j=0; vertex.m_tope_count>j; j++)
          {
            const ON_MeshTopologyEdge& edge = Top.m_tope[vertex.m_topei[j]];
            for (k=0; edge.m_topf_count>k; k++)
            {
              if (true == bTopologicalConnections)
              {
                if (0 == SortedFaceArray[edge.m_topfi[k]] && 1 != DupFaceArray[edge.m_topfi[k]])
                {
                  FacesToCheck.Append(edge.m_topfi[k]);
                  DupFaceArray[edge.m_topfi[k]] = 1;
                }
              }
              else
              {
                Pt = Top.m_mesh->m_V[vertex.m_vi[0]];
                const ON_MeshFace& thisface = Top.m_mesh->m_F[edge.m_topfi[k]];
                for (m=0; m<(thisface.IsQuad()?4:3);m++)
                {
                  if (Pt != Top.m_mesh->m_V[thisface.vi[m]])
                    continue;

                  if (face.vi[vi] == thisface.vi[m] && 0 == SortedFaceArray[edge.m_topfi[k]] && 1 != DupFaceArray[edge.m_topfi[k]])
                  {
                    //Faces share vertex 
                    FacesToCheck.Append(edge.m_topfi[k]);
                    DupFaceArray[edge.m_topfi[k]] = 1;
                    break;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
开发者ID:2php,项目名称:pcl,代码行数:90,代码来源:opennurbs_mesh_tools.cpp

示例10: GetMeshes

	virtual	int	GetMeshes(ON::mesh_type mesh_type, ON_SimpleArray<const ON_Mesh*>& meshes) const
	{
		meshes.Append(&m_mesh);
		return 1;
	}
开发者ID:KingOfMazes,项目名称:Rhino5Samples_CPP,代码行数:5,代码来源:cmdSamplePhantomObject.cpp

示例11: FindLoops

void FindLoops(ON_Brep **b, const ON_Line* revaxis, const fastf_t ang) {
    ON_3dPoint ptmatch, ptterminate, pstart, pend;

    int *curvearray;
    curvearray = static_cast<int*>(bu_malloc((*b)->m_C3.Count() * sizeof(int), "sketch edge list"));
    for (int i = 0; i < (*b)->m_C3.Count(); i++) {
	curvearray[i] = -1;
    }
    ON_SimpleArray<ON_Curve *> allsegments;
    ON_SimpleArray<ON_Curve *> loopsegments;
    int loop_complete;
    for (int i = 0; i < (*b)->m_C3.Count(); i++) {
	allsegments.Append((*b)->m_C3[i]);
    }

    int allcurvesassigned = 0;
    int assignedcount = 0;
    int curvecount = 0;
    int loopcount = 0;
    while (allcurvesassigned != 1) {
	int havefirstcurve = 0;
	while ((havefirstcurve == 0) && (curvecount < allsegments.Count())) {
	    if (curvearray[curvecount] == -1) {
		havefirstcurve = 1;
	    } else {
		curvecount++;
	    }
	}
	// First, sort through things to assign curves to loops.
	loop_complete = 0;
	while ((loop_complete != 1) && (allcurvesassigned != 1)) {
	    curvearray[curvecount] = loopcount;
	    ptmatch = (*b)->m_C3[curvecount]->PointAtEnd();
	    ptterminate = (*b)->m_C3[curvecount]->PointAtStart();
	    for (int i = 0; i < allsegments.Count(); i++) {
		pstart = (*b)->m_C3[i]->PointAtStart();
		pend = (*b)->m_C3[i]->PointAtEnd();
		if (NEAR_ZERO(ptmatch.DistanceTo(pstart), ON_ZERO_TOLERANCE) && (curvearray[i] == -1)) {
		    curvecount = i;
		    ptmatch = pend;
		    i = allsegments.Count();
		    if (NEAR_ZERO(pend.DistanceTo(ptterminate), ON_ZERO_TOLERANCE)) {
			loop_complete = 1;
			loopcount++;
		    }
		} else {
		    if (i == allsegments.Count() - 1) {
			loop_complete = 1; //If we reach this pass, loop had better be complete
			loopcount++;
			assignedcount = 0;
			for (int j = 0; j < allsegments.Count(); j++) {
			    if (curvearray[j] != -1) assignedcount++;
			}
			if (allsegments.Count() == assignedcount) allcurvesassigned = 1;
		    }
		}
	    }
	}
    }

    double maxdist = 0.0;
    int largest_loop_index = 0;
    for (int i = 0; i <= loopcount ; i++) {
	ON_BoundingBox lbbox;
	for (int j = 0; j < (*b)->m_C3.Count(); j++) {
	    if (curvearray[j] == i) {
		ON_Curve *currcurve = (*b)->m_C3[j];
		currcurve->GetBoundingBox(lbbox, true);
	    }
	}
	point_t minpt, maxpt;
	double currdist;
	VSET(minpt, lbbox.m_min[0], lbbox.m_min[1], lbbox.m_min[2]);
	VSET(maxpt, lbbox.m_max[0], lbbox.m_max[1], lbbox.m_max[2]);
	currdist = DIST_PT_PT(minpt, maxpt);
	if (currdist > maxdist) {
	    maxdist = currdist;
	    largest_loop_index = i;
	}
    }

    for (int i = 0; i < loopcount ; i++) {
	ON_PolyCurve* poly_curve = new ON_PolyCurve();
	for (int j = 0; j < allsegments.Count(); j++) {
	    if (curvearray[j] == i) {
		 poly_curve->Append(allsegments[j]);
	    }
	}

	ON_NurbsCurve *revcurve = ON_NurbsCurve::New();
	poly_curve->GetNurbForm(*revcurve);
	ON_RevSurface* revsurf = ON_RevSurface::New();
	revsurf->m_curve = revcurve;
	revsurf->m_axis = *revaxis;
	revsurf->m_angle = ON_Interval(0, ang);
	ON_BrepFace *face = (*b)->NewFace(*revsurf);

	if (i == largest_loop_index) {
	    (*b)->FlipFace(*face);
	}
//.........这里部分代码省略.........
开发者ID:kanzure,项目名称:brlcad,代码行数:101,代码来源:revolve_brep.cpp

示例12:

int ON_3dmObjectAttributes::GetGroupList(ON_SimpleArray<int>& group_list) const
{
  group_list = m_group;
  return group_list.Count();
}
开发者ID:Bastl34,项目名称:PCL,代码行数:5,代码来源:opennurbs_3dm_attributes.cpp

示例13: rt_ehy_brep

extern "C" void
rt_ehy_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *)
{
    struct rt_ehy_internal *eip;

    RT_CK_DB_INTERNAL(ip);
    eip = (struct rt_ehy_internal *)ip->idb_ptr;
    RT_EHY_CK_MAGIC(eip);

    // Check the parameters
    if (!NEAR_ZERO(VDOT(eip->ehy_Au, eip->ehy_H), RT_DOT_TOL)) {
	bu_log("rt_ehy_brep: Au and H are not perpendicular!\n");
	return;
    }

    if (!NEAR_EQUAL(MAGNITUDE(eip->ehy_Au), 1.0, RT_LEN_TOL)) {
	bu_log("rt_ehy_brep: Au not a unit vector!\n");
	return;
    }

    if (MAGNITUDE(eip->ehy_H) < RT_LEN_TOL
	|| eip->ehy_c < RT_LEN_TOL
	|| eip->ehy_r1 < RT_LEN_TOL
	|| eip->ehy_r2 < RT_LEN_TOL) {
	bu_log("rt_ehy_brep: not all dimensions positive!\n");
	return;
    }

    if (eip->ehy_r2 > eip->ehy_r1) {
	bu_log("rt_ehy_brep: semi-minor axis cannot be longer than semi-major axis!\n");
	return;
    }

    point_t p1_origin;
    ON_3dPoint plane1_origin, plane2_origin;
    ON_3dVector plane_x_dir, plane_y_dir;

    //  First, find plane in 3 space corresponding to the bottom face of the EPA.

    vect_t x_dir, y_dir;

    VMOVE(x_dir, eip->ehy_Au);
    VCROSS(y_dir, eip->ehy_Au, eip->ehy_H);
    VUNITIZE(y_dir);

    VMOVE(p1_origin, eip->ehy_V);
    plane1_origin = ON_3dPoint(p1_origin);
    plane_x_dir = ON_3dVector(x_dir);
    plane_y_dir = ON_3dVector(y_dir);
    const ON_Plane ehy_bottom_plane(plane1_origin, plane_x_dir, plane_y_dir);

    //  Next, create an ellipse in the plane corresponding to the edge of the ehy.

    ON_Ellipse ellipse1(ehy_bottom_plane, eip->ehy_r1, eip->ehy_r2);
    ON_NurbsCurve* ellcurve1 = ON_NurbsCurve::New();
    ellipse1.GetNurbForm((*ellcurve1));
    ellcurve1->SetDomain(0.0, 1.0);

    // Generate the bottom cap
    ON_SimpleArray<ON_Curve*> boundary;
    boundary.Append(ON_Curve::Cast(ellcurve1));
    ON_PlaneSurface* bp = new ON_PlaneSurface();
    bp->m_plane = ehy_bottom_plane;
    bp->SetDomain(0, -100.0, 100.0);
    bp->SetDomain(1, -100.0, 100.0);
    bp->SetExtents(0, bp->Domain(0));
    bp->SetExtents(1, bp->Domain(1));
    (*b)->m_S.Append(bp);
    const int bsi = (*b)->m_S.Count() - 1;
    ON_BrepFace& bface = (*b)->NewFace(bsi);
    (*b)->NewPlanarFaceLoop(bface.m_face_index, ON_BrepLoop::outer, boundary, true);
    const ON_BrepLoop* bloop = (*b)->m_L.Last();
    bp->SetDomain(0, bloop->m_pbox.m_min.x, bloop->m_pbox.m_max.x);
    bp->SetDomain(1, bloop->m_pbox.m_min.y, bloop->m_pbox.m_max.y);
    bp->SetExtents(0, bp->Domain(0));
    bp->SetExtents(1, bp->Domain(1));
    (*b)->SetTrimIsoFlags(bface);
    delete ellcurve1;

    //  Now, the hard part.  Need an elliptical hyperbolic NURBS surface
    //  First step is to create a nurbs curve.

    double intercept_calc = (eip->ehy_c)*(eip->ehy_c)/(MAGNITUDE(eip->ehy_H) + eip->ehy_c);
    double intercept_dist = MAGNITUDE(eip->ehy_H) + eip->ehy_c - intercept_calc;
    double intercept_length = intercept_dist - MAGNITUDE(eip->ehy_H);
    double MX = MAGNITUDE(eip->ehy_H);
    double MP = MX + intercept_length;
    double w = (MX/MP)/(1-MX/MP);

    point_t ep1, ep2, ep3;
    VSET(ep1, -eip->ehy_r1, 0, 0);
    VSET(ep2, 0, 0, w*intercept_dist);
    VSET(ep3, eip->ehy_r1, 0, 0);
    ON_3dPoint onp1 = ON_3dPoint(ep1);
    ON_3dPoint onp2 = ON_3dPoint(ep2);
    ON_3dPoint onp3 = ON_3dPoint(ep3);

    ON_3dPointArray cpts(3);
    cpts.Append(onp1);
    cpts.Append(onp2);
//.........这里部分代码省略.........
开发者ID:kanzure,项目名称:brlcad,代码行数:101,代码来源:ehy_brep.cpp

示例14: RhinoApp

CRhinoCommand::result CCommandSampleRemovePoints::RunCommand( const CRhinoCommandContext& context )
{
    CRhinoGetObject go;
    go.SetCommandPrompt( L"Select point cloud" );
    go.SetGeometryFilter( CRhinoGetObject::pointset_object );
    go.EnableSubObjectSelect( false );
    go.GetObjects( 1, 1 );
    if( go.CommandResult() != CRhinoCommand::success )
        return go.CommandResult();

    const CRhinoObjRef& obj_ref = go.Object(0);
    const CRhinoPointCloudObject* obj = CRhinoPointCloudObject::Cast( obj_ref.Object() );
    if( 0 == obj )
        return CRhinoCommand::failure;

    const ON_PointCloud& cloud = obj->PointCloud();

    obj->Select( false );
    context.m_doc.Redraw();

    CRhGetRegionPoints gp;
    gp.SetCommandPrompt( L"Click and drag, or repeatedly click to lasso point cloud points. Press Enter when done" );
    gp.AcceptNothing();
    gp.SetGetPointCursor( RhinoApp().m_default_cursor );
    gp.GetPoints();
    if( gp.Result() == CRhinoGet::point )
        return CRhinoCommand::cancel;

    ON_SimpleArray<int> indices;
    const int index_count = RhRegionSelectPointCloudPoints( gp.View(), cloud, gp.m_points, indices );
    if( 0 == index_count )
        return CRhinoCommand::nothing;

    indices.QuickSort( &ON_CompareIncreasing<int> );

    const CRhinoObjectAttributes& atts = obj->Attributes();
    bool bColors = cloud.HasPointColors();
    bool bNormals = cloud.HasPointNormals();

    ON_PointCloud new_cloud;
    new_cloud.m_P.SetCapacity( index_count );
    new_cloud.m_P.SetCount( index_count );
    if( bColors )
    {
        new_cloud.m_C.SetCapacity( index_count );
        new_cloud.m_C.SetCount( index_count );
    }
    if( bNormals )
    {
        new_cloud.m_N.SetCapacity( index_count );
        new_cloud.m_N.SetCount( index_count );
    }

    ON_PointCloud dup_cloud( cloud );
    dup_cloud.DestroyHiddenPointArray();

    const int cloud_count = dup_cloud.PointCount();
    int last_point_index = indices[indices.Count() - 1];
    for( int i = cloud_count - 1; i >= 0; i-- )
    {
        if( i == last_point_index )
        {
            int last_array_index = indices.Count() - 1;

            new_cloud.m_P[last_array_index] = dup_cloud.m_P[i];
            if( bColors )
                new_cloud.m_C[last_array_index] = dup_cloud.m_C[i];
            if( bNormals )
                new_cloud.m_N[last_array_index] = dup_cloud.m_N[i];

            dup_cloud.m_P.Remove( i );
            if( bColors )
                dup_cloud.m_C.Remove( i );
            if( bNormals )
                dup_cloud.m_N.Remove( i );

            indices.Remove( last_array_index );

            if( 0 == indices.Count() )
                break;

            last_point_index = indices[indices.Count() - 1];
        }
    }

    CRhinoPointCloudObject* new_cloud_obj = new CRhinoPointCloudObject( atts );
    new_cloud_obj->SetPointCloud( new_cloud );
    new_cloud.Destroy();
    if( context.m_doc.AddObject(new_cloud_obj) )
    {
        new_cloud_obj->Select();
    }
    else
    {
        delete new_cloud_obj;
        return CRhinoCommand::failure;
    }

    dup_cloud.m_P.Shrink();
    if( bColors )
//.........这里部分代码省略.........
开发者ID:krzyzacy,项目名称:Rhino5Samples_CPP,代码行数:101,代码来源:cmdSampleSelectRegion.cpp

示例15: ON_Intersect_MeshRay1

RH_C_FUNCTION double ON_Intersect_MeshRay1(const ON_Mesh* pMesh, ON_3dRay* ray, ON_SimpleArray<int>* face_indices)
{
  double rc = -1.0;
  // it is ok if face_indices is null
  if( pMesh && ray )
  {
#if defined(RHINO_V5SR) // only available in V5
    const ON_MeshTree* mt = pMesh->MeshTree(true);
#else
    const ON_MeshTree* mt = pMesh->MeshTree();
#endif
    ON_3dVector rayVec = ray->m_V;
    if( mt && rayVec.Unitize() )
    {
      // increase the range by a factor of 2 so we are confident the
      // line passes entirely through the mesh
      double rayRange = RhCmnMaxDistance_Helper( mt->m_bbox, ray->m_P ) * 2.0;
      ON_Line line(ray->m_P, ray->m_P + rayRange * rayVec );

      ON_SimpleArray<ON_CMX_EVENT> hits;
      mt->IntersectLine( line, hits );
      int hitCount = hits.Count();
      if( hitCount > 0 )
      {
        ON_SimpleArray<double> tvals;
        ON_SimpleArray<int> indices;
        // tMin should be between 0 and 1 for the line
        double tMin = 100.0;
        for( int i=0; i<hitCount; i++ )
        {
          const ON_CMX_EVENT& e = hits[i];
          if( e.m_C[0].m_t <= tMin )
          {
            tMin = e.m_C[0].m_t;
            if( face_indices )
            {
              tvals.Append(tMin);
              indices.Append(e.m_M[0].m_face_index);
            }
          }
          if( e.m_type == ON_CMX_EVENT::cmx_overlap && e.m_C[1].m_t <= tMin )
          {
            tMin = e.m_C[1].m_t;
            if( face_indices )
            {
              tvals.Append(tMin);
              indices.Append( e.m_M[1].m_face_index);
            }
          }
        }
        if( tMin >=0 && tMin <= 1.0 )
        {
          if( face_indices )
          {
            for( int i=0; i<tvals.Count(); i++ )
            {
              if( tvals[i]==tMin )
                face_indices->Append(indices[i]);
            }
          }

          double lineLength = line.Length();
          double rayLength = ray->m_V.Length();
          if( rayLength > ON_SQRT_EPSILON )
          {
            rc = tMin * lineLength / rayLength;
          }
        }
      }
    }
  }
  return rc;
}
开发者ID:JohannesKu,项目名称:rhinocommon,代码行数:73,代码来源:on_intersect.cpp


注:本文中的ON_SimpleArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。