/**
 * A simple sphere model for the bullet engine - Friction, rolling friction and restitution all set to 0.5
 */
CBulletSphereModel::CBulletSphereModel(CBulletEngine &engine, CSphereEntity &entity) : CBulletModel(engine, entity.GetEmbodiedEntity()),
																					   positionOffset(0,0,0)
{
	// Retain a reference to the engine and associated ARGoS entity
	this->entity = &entity;
	this->engine = &engine;

	// Bullet requires boxes to be initialised with half side lengths
	collisionShape = new btSphereShape{(btScalar)entity.GetRadius()};

	// Setup the location of the box in bullet compensating for the difference between ARGoS and Bullet coordinate origins
	position = entity.GetEmbodiedEntity().GetOriginAnchor().Position;
	orientation = entity.GetEmbodiedEntity().GetOriginAnchor().Orientation;
	btTransform t = bulletTransformFromARGoS(position - rotateARGoSVector(positionOffset, orientation), orientation);
	motionState = new btDefaultMotionState{t};

	// Setup the object, setting the mass to 0 if it should be static
	btScalar mass = (btScalar)(entity.IsEnabled() ? entity.GetMass() : 0);

	// Setup inertia to enable rotations
	btVector3 inertia;
	collisionShape->calculateLocalInertia(mass, inertia);

	rigidBody = new btRigidBody{mass, motionState, collisionShape, inertia};
	rigidBody->setActivationState(DISABLE_DEACTIVATION);

	rigidBody->setFriction(0.5);
	rigidBody->setRestitution(0.5);
	rigidBody->setRollingFriction(0.5);

	CalculateBoundingBox();
}
예제 #2
0
void MODULE::SetOrientation( double newangle )
{
    double  angleChange = newangle - m_Orient;  // change in rotation

    NORMALIZE_ANGLE_POS( newangle );

    m_Orient = newangle;

    for( D_PAD* pad = m_Pads;  pad;  pad = pad->Next() )
    {
        pad->SetOrientation( pad->GetOrientation() + angleChange );
        pad->SetDrawCoord();
    }

    // Update of the reference and value.
    m_Reference->SetDrawCoord();
    m_Value->SetDrawCoord();

    // Displace contours and text of the footprint.
    for( BOARD_ITEM* item = m_Drawings;  item;  item = item->Next() )
    {
        if( item->Type() == PCB_MODULE_EDGE_T )
        {
            static_cast<EDGE_MODULE*>( item )->SetDrawCoord();
        }
        else if( item->Type() == PCB_MODULE_TEXT_T )
        {
            static_cast<TEXTE_MODULE*>( item )->SetDrawCoord();
        }
    }

    CalculateBoundingBox();
}
예제 #3
0
// Make the original points the same as the working points
void wxPolygonShape::UpdateOriginalPoints()
{
	if (!m_originalPoints) m_originalPoints = new wxList;
	wxNode *original_node = m_originalPoints->GetFirst();
	while (original_node)
	{
		wxNode *next_node = original_node->GetNext();
		wxRealPoint *original_point = (wxRealPoint *)original_node->GetData();
		delete original_point;
		delete original_node;

		original_node = next_node;
	}

	wxNode *node = m_points->GetFirst();
	while (node)
	{
		wxRealPoint *point = (wxRealPoint *)node->GetData();
		wxRealPoint *original_point = new wxRealPoint(point->x, point->y);
		m_originalPoints->Append((wxObject *) original_point);

		node = node->GetNext();
	}
	CalculateBoundingBox();
	m_originalWidth = m_boundWidth;
	m_originalHeight = m_boundHeight;
}
예제 #4
0
void wxPolygonShape::Create(wxList *the_points)
{
	ClearPoints();

	if (!the_points)
	{
		m_originalPoints = new wxList;
		m_points = new wxList;
	}
	else
	{
		m_originalPoints = the_points;

		// Duplicate the list of points
		m_points = new wxList;

		wxNode *node = the_points->GetFirst();
		while (node)
		{
			wxRealPoint *point = (wxRealPoint *)node->GetData();
			wxRealPoint *new_point = new wxRealPoint(point->x, point->y);
			m_points->Append((wxObject *) new_point);
			node = node->GetNext();
		}
		CalculateBoundingBox();
		m_originalWidth = m_boundWidth;
		m_originalHeight = m_boundHeight;
		SetDefaultRegionSize();
	}
}
예제 #5
0
void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
{
    /* Move the reference point of the footprint
     * the footprints elements (pads, outlines, edges .. ) are moved
     * but:
     * - the footprint position is not modified.
     * - the relative (local) coordinates of these items are modified
     */

    wxPoint footprintPos = GetPosition();

    /* Update the relative coordinates:
     * The coordinates are relative to the anchor point.
     * Calculate deltaX and deltaY from the anchor. */
    wxPoint moveVector = aMoveVector;
    RotatePoint( &moveVector, -GetOrientation() );

    // Update of the reference and value.
    m_Reference->SetPos0( m_Reference->GetPos0() + moveVector );
    m_Reference->SetDrawCoord();
    m_Value->SetPos0( m_Value->GetPos0() + moveVector );
    m_Value->SetDrawCoord();

    // Update the pad local coordinates.
    for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
    {
        pad->SetPos0( pad->GetPos0() + moveVector );
        pad->SetPosition( pad->GetPos0() + footprintPos );
    }

    // Update the draw element coordinates.
    for( EDA_ITEM* item = GraphicalItems(); item; item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_EDGE_T:
            {
                EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
                edge->m_Start0 += moveVector;
                edge->m_End0   += moveVector;
                edge->SetDrawCoord();
                break;
            }

        case PCB_MODULE_TEXT_T:
            {
                TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
                text->SetPos0( text->GetPos0() + moveVector );
                text->SetDrawCoord();
                break;
            }

        default:
            break;
        }
    }

    CalculateBoundingBox();
}
예제 #6
0
 void CEmbodiedEntity::AddPhysicsModel(const std::string& str_engine_id,
                                       CPhysicsModel& c_physics_model) {
    if(m_bMovable && GetPhysicsModelsNum() > 0) {
       THROW_ARGOSEXCEPTION(GetContext() << GetId() << " is movable embodied entity and can't have more than 1 physics engine entity associated");
    }
    m_tPhysicsModelMap[str_engine_id] = &c_physics_model;
    m_tPhysicsModelVector.push_back(&c_physics_model);
    CalculateBoundingBox();
 }
예제 #7
0
파일: Mesh.cpp 프로젝트: SinYocto/Siny
void Mesh::Build(VertexType type)
{
	vertexType = type;

	switch(vertexType){
		case XYZ:
			sizeofVertex = 12;
			vertexData = positionData;
			break;
		case XYZ_UV:
			sizeofVertex = 20;
			vertexData = new VertexUV[numVertices];
			for(int i = 0; i < numVertices; ++i){
				VertexUV vert = VertexUV(positionData[i].x, positionData[i].y, positionData[i].z, 
										uvData[i].x, uvData[i].y);
				((VertexUV*)vertexData)[i] = vert;
			}
			break;
		case XYZ_N:
			sizeofVertex = 24;
			vertexData = new VertexN[numVertices];
			for(int i = 0; i < numVertices; ++i){
				VertexN vert = VertexN(positionData[i].x, positionData[i].y, positionData[i].z, 
										normalData[i].x, normalData[i].y, normalData[i].z);
				((VertexN*)vertexData)[i] = vert;
			}
			break;
		case XYZ_UV_N:
			sizeofVertex = 32;
			vertexData = new VertexUVN[numVertices];
			for(int i =0; i < numVertices; ++i){
				VertexUVN vert = VertexUVN(positionData[i].x, positionData[i].y, positionData[i].z, 
										uvData[i].x, uvData[i].y, 
										normalData[i].x, normalData[i].y, normalData[i].z);
				((VertexUVN*)vertexData)[i] = vert;
			}
			break;
		case XYZ_UV_TBN:
			sizeofVertex = 56;
			vertexData = new VertexUVTBN[numVertices];
			for(int i =0; i < numVertices; ++i){
				VertexUVTBN vert = VertexUVTBN(positionData[i].x, positionData[i].y, positionData[i].z, 
										uvData[i].x, uvData[i].y, 
										tangentData[i].x, tangentData[i].y, tangentData[i].z,
										bitangentData[i].x, bitangentData[i].y, bitangentData[i].z,
										normalData[i].x, normalData[i].y, normalData[i].z);
				((VertexUVTBN*)vertexData)[i] = vert;
			}
			break;
	}

	CreateVertexBuffer(numVertices);
	CreateIndexBuffer(3*numTriangles);

	CalculateBoundingBox();

}
예제 #8
0
typename TAPosition::ValueType
CalculateCenter(TVrtIter vrtsBegin, TVrtIter vrtsEnd,
				Grid::AttachmentAccessor<Vertex, TAPosition>& aaPos)
{
	typename TAPosition::ValueType vMin, vMax;
	CalculateBoundingBox(vMin, vMax, vrtsBegin, vrtsEnd, aaPos);
	typename TAPosition::ValueType vRet;
	VecScaleAdd(vRet, 0.5, vMin, 0.5, vMax);
	return vRet;
}
예제 #9
0
void mitk::UnstructuredGrid::UpdateOutputInformation()
{
 if ( this->GetSource() )
  {
    this->GetSource()->UpdateOutputInformation();
  }
  if ( ( m_CalculateBoundingBox ) && ( m_GridSeries.size() > 0 ) )
    CalculateBoundingBox();
  else
    GetTimeGeometry()->Update();
}
예제 #10
0
void mitk::Surface::UpdateOutputInformation()
{
  if ( this->GetSource() )
  {
    this->GetSource()->UpdateOutputInformation();
  }
  if ( ( m_CalculateBoundingBox ) && ( m_PolyDataSeries.size() > 0 ) )
    CalculateBoundingBox();
  else
    GetTimeSlicedGeometry()->UpdateInformation();
}
예제 #11
0
 void CPhysXMultiBodyObjectModel::AddBody(physx::PxRigidDynamic& c_body,
                                          const physx::PxTransform& c_trans) {
    /* Set userData pointer */
    c_body.userData = this;
    /* Add body to aggregate */
    m_pcAggregate->addActor(c_body);
    /* Add body to list */
    m_vecBodies.push_back(SBody(c_body, c_trans));
    /* Calculate the bounding box */
    CalculateBoundingBox();
 }
예제 #12
0
 void CEmbodiedEntity::RemovePhysicsModel(const std::string& str_engine_id) {
    CPhysicsModel::TMap::iterator itMap = m_tPhysicsModelMap.find(str_engine_id);
    if(itMap == m_tPhysicsModelMap.end()) {
       THROW_ARGOSEXCEPTION("Entity \"" << GetContext() << GetId() << "\" has no associated entity in physics engine " << str_engine_id);
    }
    CPhysicsModel::TVector::iterator itVec = std::find(m_tPhysicsModelVector.begin(),
                                                       m_tPhysicsModelVector.end(),
                                                       itMap->second);
    m_tPhysicsModelMap.erase(itMap);
    m_tPhysicsModelVector.erase(itVec);
    CalculateBoundingBox();
 }
 void CDynamics2DSingleBodyObjectModel::SetBody(cpBody* pt_body,
                                                Real f_height) {
    /* Set the body and its data field for ray queries */
    m_ptBody = pt_body;
    m_ptBody->data = this;
    /* Register the origin anchor update method */
    RegisterAnchorMethod(GetEmbodiedEntity().GetOriginAnchor(),
                         &CDynamics2DSingleBodyObjectModel::UpdateOriginAnchor);
    /* Calculate the bounding box */
    GetBoundingBox().MinCorner.SetZ(GetEmbodiedEntity().GetOriginAnchor().Position.GetZ());
    GetBoundingBox().MaxCorner.SetZ(GetEmbodiedEntity().GetOriginAnchor().Position.GetZ() + f_height);
    CalculateBoundingBox();
 }
 void CDynamics2DMultiBodyObjectModel::AddBody(cpBody* pt_body,
                                               const cpVect& t_offset_pos,
                                               cpFloat t_offset_orient,
                                               Real f_height) {
    /* Set the body and its data field for ray queries */
    pt_body->data = this;
    /* Add body to list */
    m_vecBodies.push_back(SBody(pt_body,
                                t_offset_pos,
                                t_offset_orient,
                                f_height));
    /* Calculate the bounding box */
    CalculateBoundingBox();
 }
예제 #15
0
void MODULE::Flip( const wxPoint& aCentre )
{
    // Move module to its final position:
    wxPoint finalPos = m_Pos;

    finalPos.y  = aCentre.y - ( finalPos.y - aCentre.y );     /// Mirror the Y position

    SetPosition( finalPos );

    // Flip layer
    SetLayer( FlipLayer( GetLayer() ) );

    // Reverse mirror orientation.
    NEGATE( m_Orient );
    NORMALIZE_ANGLE_POS( m_Orient );

    // Mirror pads to other side of board about the x axis, i.e. vertically.
    for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
        pad->Flip( m_Pos );

    // Mirror reference.
    m_Reference->FlipWithModule( m_Pos.y );

    // Mirror value.
    m_Value->FlipWithModule( m_Pos.y );

    // Reverse mirror module graphics and texts.
    for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_EDGE_T:
            ( (EDGE_MODULE*) item )->Flip( m_Pos );
            break;

        case PCB_MODULE_TEXT_T:
            static_cast<TEXTE_MODULE*>( item )->FlipWithModule( m_Pos.y );
            break;

        default:
            wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) );
            break;
        }
    }

    CalculateBoundingBox();
}
예제 #16
0
// Rotate about the given axis by the given amount in radians
void wxPolygonShape::Rotate(double x, double y, double theta)
{
	double actualTheta = theta - m_rotation;

	// Rotate attachment points
	double sinTheta = (double)sin(actualTheta);
	double cosTheta = (double)cos(actualTheta);
	wxNode *node = m_attachmentPoints.GetFirst();
	while (node)
	{
		wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData();
		double x1 = point->m_x;
		double y1 = point->m_y;
		point->m_x = x1 * cosTheta - y1 * sinTheta + x * (1.0 - cosTheta) + y * sinTheta;
		point->m_y = x1 * sinTheta + y1 * cosTheta + y * (1.0 - cosTheta) + x * sinTheta;
		node = node->GetNext();
	}

	node = m_points->GetFirst();
	while (node)
	{
		wxRealPoint *point = (wxRealPoint *)node->GetData();
		double x1 = point->x;
		double y1 = point->y;
		point->x = x1 * cosTheta - y1 * sinTheta + x * (1.0 - cosTheta) + y * sinTheta;
		point->y = x1 * sinTheta + y1 * cosTheta + y * (1.0 - cosTheta) + x * sinTheta;
		node = node->GetNext();
	}
	node = m_originalPoints->GetFirst();
	while (node)
	{
		wxRealPoint *point = (wxRealPoint *)node->GetData();
		double x1 = point->x;
		double y1 = point->y;
		point->x = x1 * cosTheta - y1 * sinTheta + x * (1.0 - cosTheta) + y * sinTheta;
		point->y = x1 * sinTheta + y1 * cosTheta + y * (1.0 - cosTheta) + x * sinTheta;
		node = node->GetNext();
	}

	m_rotation = theta;

	CalculatePolygonCentre();
	CalculateBoundingBox();
	ResetControlPoints();
}
 void CDynamics2DSingleBodyObjectModel::Reset() {
    /* Nothing to do for a static body */
    if(cpBodyIsStatic(m_ptBody)) return;
    /* Reset body position */
    const CVector3& cPosition = GetEmbodiedEntity().GetOriginAnchor().Position;
    m_ptBody->p = cpv(cPosition.GetX(), cPosition.GetY());
    /* Reset body orientation */
    CRadians cXAngle, cYAngle, cZAngle;
    GetEmbodiedEntity().GetOriginAnchor().Orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
    cpBodySetAngle(m_ptBody, cZAngle.GetValue());
    /* Zero speed and applied forces */
    m_ptBody->v = cpvzero;
    m_ptBody->w = 0.0f;
    cpBodyResetForces(m_ptBody);
    /* Update bounding box */
    cpSpaceReindexShapesForBody(GetDynamics2DEngine().GetPhysicsSpace(), m_ptBody);
    CalculateBoundingBox();
 }
예제 #18
0
 void CPhysicsModel::UpdateEntityStatus() {
    CalculateAnchors();
    CalculateBoundingBox();
    /*
     * Update entity components
     */
    /* Get a reference to the root entity */
    /* NOTE: here the cast is static because we know that an embodied entity MUST have a parent
     * which, by definition, is a composable entity */
    CComposableEntity& cRoot = static_cast<CComposableEntity&>(m_cEmbodiedEntity.GetRootEntity());
    /* Update its components */
    cRoot.UpdateComponents();
    /*
     * Check whether a transfer is necessary
     */
    if(!m_cEngine.IsPointContained(GetEmbodiedEntity().GetOriginAnchor().Position))
       m_cEngine.ScheduleEntityForTransfer(m_cEmbodiedEntity);
 }
예제 #19
0
void MODULE::SetOrientation( double newangle )
{
    double  angleChange = newangle - m_Orient;  // change in rotation
    wxPoint pt;

    NORMALIZE_ANGLE_POS( newangle );

    m_Orient = newangle;

    for( D_PAD* pad = m_Pads;  pad;  pad = pad->Next() )
    {
        pt = pad->GetPos0();

        pad->SetOrientation( pad->GetOrientation() + angleChange );

        RotatePoint( &pt, m_Orient );

        pad->SetPosition( GetPosition() + pt );
    }

    // Update of the reference and value.
    m_Reference->SetDrawCoord();
    m_Value->SetDrawCoord();

    // Displace contours and text of the footprint.
    for( BOARD_ITEM* item = m_Drawings;  item;  item = item->Next() )
    {
        if( item->Type() == PCB_MODULE_EDGE_T )
        {
            EDGE_MODULE* edge = (EDGE_MODULE*) item;
            edge->SetDrawCoord();
        }

        else if( item->Type() == PCB_MODULE_TEXT_T )
        {
            TEXTE_MODULE* text = (TEXTE_MODULE*) item;
            text->SetDrawCoord();
        }
    }

    CalculateBoundingBox();
}
예제 #20
0
void MODULE::SetPosition( const wxPoint& newpos )
{
    wxPoint delta = newpos - m_Pos;

    m_Pos += delta;
    m_Reference->SetTextPosition( m_Reference->GetTextPosition() + delta );
    m_Value->SetTextPosition( m_Value->GetTextPosition() + delta );

    for( D_PAD* pad = m_Pads;  pad;  pad = pad->Next() )
    {
        pad->SetPosition( pad->GetPosition() + delta );
    }

    for( EDA_ITEM* item = m_Drawings;  item;  item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_EDGE_T:
        {
            EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
            pt_edgmod->SetDrawCoord();
            break;
        }

        case PCB_MODULE_TEXT_T:
        {
            TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
            text->SetTextPosition( text->GetTextPosition() + delta );
            break;
        }

        default:
            wxMessageBox( wxT( "Draw type undefined." ) );
            break;
        }
    }

    CalculateBoundingBox();
}
예제 #21
0
// Create render model structure for rendering an attached model
BOOL CModelObject::CreateAttachment( CRenderModel &rmMain, CAttachmentModelObject &amo)
{
  _pfModelProfile.StartTimer( CModelProfile::PTI_CREATEATTACHMENT);
  _pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_CREATEATTACHMENT);
  CRenderModel &rmAttached = *amo.amo_prm;
  rmAttached.rm_ulFlags = rmMain.rm_ulFlags&(RMF_FOG|RMF_HAZE|RMF_WEAPON) | RMF_ATTACHMENT;

  // get the position
  rmMain.rm_pmdModelData->md_aampAttachedPosition.Lock();
  const CAttachedModelPosition &amp = rmMain.rm_pmdModelData->md_aampAttachedPosition[amo.amo_iAttachedPosition];
  rmMain.rm_pmdModelData->md_aampAttachedPosition.Unlock();

  // copy common values
  rmAttached.rm_vLightDirection = rmMain.rm_vLightDirection;
  rmAttached.rm_fDistanceFactor = rmMain.rm_fDistanceFactor;
  rmAttached.rm_colLight   = rmMain.rm_colLight;
  rmAttached.rm_colAmbient = rmMain.rm_colAmbient;
  rmAttached.rm_colBlend   = rmMain.rm_colBlend;

  // unpack the reference vertices
  FLOAT3D vCenter, vFront, vUp;
  const INDEX iCenter = amp.amp_iCenterVertex;
  const INDEX iFront  = amp.amp_iFrontVertex;
  const INDEX iUp     = amp.amp_iUpVertex;
  UnpackVertex( rmMain, iCenter, vCenter);
  UnpackVertex( rmMain, iFront,  vFront);
  UnpackVertex( rmMain, iUp,     vUp);

  // create front and up direction vectors
  FLOAT3D vY = vUp - vCenter;
  FLOAT3D vZ = vCenter - vFront;
  // project center and directions from object to absolute space
  const FLOATmatrix3D &mO2A = rmMain.rm_mObjectRotation;
  const FLOAT3D &vO2A = rmMain.rm_vObjectPosition;
  vCenter = vCenter*mO2A +vO2A;
  vY = vY *mO2A;
  vZ = vZ *mO2A;

  // make a rotation matrix from the direction vectors
  FLOAT3D vX = vY*vZ;
  vY = vZ*vX;
  vX.Normalize();
  vY.Normalize();
  vZ.Normalize();
  FLOATmatrix3D mOrientation;
  mOrientation(1,1) = vX(1);  mOrientation(1,2) = vY(1);  mOrientation(1,3) = vZ(1);
  mOrientation(2,1) = vX(2);  mOrientation(2,2) = vY(2);  mOrientation(2,3) = vZ(2);
  mOrientation(3,1) = vX(3);  mOrientation(3,2) = vY(3);  mOrientation(3,3) = vZ(3);

  // adjust for relative placement of the attachment
  FLOAT3D vOffset;
  FLOATmatrix3D mRelative;
  MakeRotationMatrixFast( mRelative, amo.amo_plRelative.pl_OrientationAngle);
  vOffset(1) = amo.amo_plRelative.pl_PositionVector(1) * mo_Stretch(1);
  vOffset(2) = amo.amo_plRelative.pl_PositionVector(2) * mo_Stretch(2);
  vOffset(3) = amo.amo_plRelative.pl_PositionVector(3) * mo_Stretch(3);
  FLOAT3D vO = vCenter + vOffset * mOrientation;
  mOrientation *= mRelative; // convert absolute to relative orientation
  rmAttached.SetObjectPlacement( vO, mOrientation);

  // done here if clipping optimizations are not allowed
  extern INDEX gap_iOptimizeClipping;
  if( gap_iOptimizeClipping<1) { 
    gap_iOptimizeClipping = 0;
    _pfModelProfile.StopTimer( CModelProfile::PTI_CREATEATTACHMENT);
    return TRUE;
  }

  // test attachment to frustum and/or mirror
  FLOAT3D vHandle;
  _aprProjection->PreClip( vO, vHandle);
  CalculateBoundingBox( &amo.amo_moModelObject, rmAttached);

  // compose view-space bounding box and sphere of an attacment
  const FLOAT fR = Max( rmAttached.rm_vObjectMinBB.Length(), rmAttached.rm_vObjectMaxBB.Length());
  const FLOATobbox3D boxEntity( FLOATaabbox3D(rmAttached.rm_vObjectMinBB, rmAttached.rm_vObjectMaxBB),
                                vHandle, _aprProjection->pr_ViewerRotationMatrix*mOrientation);
  // frustum test?
  if( gap_iOptimizeClipping>1) {
    // test sphere against frustrum
    INDEX iFrustumTest = _aprProjection->TestSphereToFrustum(vHandle,fR);
    if( iFrustumTest==0) {
      // test box if sphere cut one of frustum planes
      iFrustumTest = _aprProjection->TestBoxToFrustum(boxEntity);
    }
    // mark if attachment is fully inside frustum
         if( iFrustumTest>0) rmAttached.rm_ulFlags |= RMF_INSIDE; 
    else if( iFrustumTest<0) { // if completely outside of frustum
      // signal skip rendering only if doesn't have any attachments
      _pfModelProfile.StopTimer( CModelProfile::PTI_CREATEATTACHMENT);
      return !amo.amo_moModelObject.mo_lhAttachments.IsEmpty(); 
    }
  }
  // test sphere against mirror/warp plane (if any)
  if( _aprProjection->pr_bMirror || _aprProjection->pr_bWarp) {
    INDEX iMirrorPlaneTest;
    const FLOAT fPlaneDistance = _aprProjection->pr_plMirrorView.PointDistance(vHandle);
         if( fPlaneDistance < -fR) iMirrorPlaneTest = -1;
    else if( fPlaneDistance > +fR) iMirrorPlaneTest = +1;
    else { // test box if sphere cut mirror plane
      iMirrorPlaneTest = boxEntity.TestAgainstPlane(_aprProjection->pr_plMirrorView);
    }
    // mark if attachment is fully inside mirror
         if( iMirrorPlaneTest>0) rmAttached.rm_ulFlags |= RMF_INMIRROR; 
    else if( iMirrorPlaneTest<0) { // if completely outside mirror
      // signal skip rendering only if doesn't have any attachments
      _pfModelProfile.StopTimer( CModelProfile::PTI_CREATEATTACHMENT);
      return !amo.amo_moModelObject.mo_lhAttachments.IsEmpty(); 
    }
  } 
  // all done
  _pfModelProfile.StopTimer( CModelProfile::PTI_CREATEATTACHMENT);
  return TRUE;
}
예제 #22
0
파일: Mesh.cpp 프로젝트: Jurredebaare/KISS
void CMesh::SetVertices( SVertex* a_Vertices, const unsigned int a_VertexCount )
{
	m_Vertices = a_Vertices;
	m_VertexCount = a_VertexCount;
	CalculateBoundingBox();
}
예제 #23
0
MODULE::MODULE( const MODULE& aModule ) :
    BOARD_ITEM_CONTAINER( aModule )
{
    m_Pos = aModule.m_Pos;
    m_fpid = aModule.m_fpid;
    m_Attributs = aModule.m_Attributs;
    m_ModuleStatus = aModule.m_ModuleStatus;
    m_Orient = aModule.m_Orient;
    m_BoundaryBox = aModule.m_BoundaryBox;
    m_CntRot90 = aModule.m_CntRot90;
    m_CntRot180 = aModule.m_CntRot180;
    m_LastEditTime = aModule.m_LastEditTime;
    m_Link = aModule.m_Link;
    m_Path = aModule.m_Path;              //is this correct behavior?

    m_LocalClearance = aModule.m_LocalClearance;
    m_LocalSolderMaskMargin = aModule.m_LocalSolderMaskMargin;
    m_LocalSolderPasteMargin = aModule.m_LocalSolderPasteMargin;
    m_LocalSolderPasteMarginRatio = aModule.m_LocalSolderPasteMarginRatio;
    m_ZoneConnection = aModule.m_ZoneConnection;
    m_ThermalWidth = aModule.m_ThermalWidth;
    m_ThermalGap = aModule.m_ThermalGap;

    // Copy reference and value.
    m_Reference = new TEXTE_MODULE( *aModule.m_Reference );
    m_Reference->SetParent( this );
    m_Value = new TEXTE_MODULE( *aModule.m_Value );
    m_Value->SetParent( this );

    // Copy auxiliary data: Pads
    for( D_PAD* pad = aModule.m_Pads;  pad;  pad = pad->Next() )
    {
        Add( new D_PAD( *pad ) );
    }

    // Copy auxiliary data: Drawings
    for( BOARD_ITEM* item = aModule.m_Drawings;  item;  item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
        case PCB_MODULE_EDGE_T:
            Add( static_cast<BOARD_ITEM*>( item->Clone() ) );
            break;

        default:
            wxLogMessage( wxT( "Class MODULE copy constructor internal error: unknown type" ) );
            break;
        }
    }

    // Copy auxiliary data: 3D_Drawings info
    m_3D_Drawings = aModule.m_3D_Drawings;

    m_Doc     = aModule.m_Doc;
    m_KeyWord = aModule.m_KeyWord;

    m_arflag = 0;

    // Ensure auxiliary data is up to date
    CalculateBoundingBox();

    m_initial_comments = aModule.m_initial_comments ?
                            new wxArrayString( *aModule.m_initial_comments ) : 0;
}
예제 #24
0
MODULE& MODULE::operator=( const MODULE& aOther )
{
    BOARD_ITEM::operator=( aOther );

    m_Pos           = aOther.m_Pos;
    m_fpid          = aOther.m_fpid;
    m_Attributs     = aOther.m_Attributs;
    m_ModuleStatus  = aOther.m_ModuleStatus;
    m_Orient        = aOther.m_Orient;
    m_BoundaryBox   = aOther.m_BoundaryBox;
    m_CntRot90      = aOther.m_CntRot90;
    m_CntRot180     = aOther.m_CntRot180;
    m_LastEditTime  = aOther.m_LastEditTime;
    m_Link          = aOther.m_Link;
    m_Path          = aOther.m_Path; //is this correct behavior?

    m_LocalClearance                = aOther.m_LocalClearance;
    m_LocalSolderMaskMargin         = aOther.m_LocalSolderMaskMargin;
    m_LocalSolderPasteMargin        = aOther.m_LocalSolderPasteMargin;
    m_LocalSolderPasteMarginRatio   = aOther.m_LocalSolderPasteMarginRatio;
    m_ZoneConnection                = aOther.m_ZoneConnection;
    m_ThermalWidth                  = aOther.m_ThermalWidth;
    m_ThermalGap                    = aOther.m_ThermalGap;

    // Copy reference and value
    *m_Reference = *aOther.m_Reference;
    m_Reference->SetParent( this );
    *m_Value = *aOther.m_Value;
    m_Value->SetParent( this );

    // Copy auxiliary data: Pads
    m_Pads.DeleteAll();

    for( D_PAD* pad = aOther.m_Pads;  pad;  pad = pad->Next() )
    {
        Add( new D_PAD( *pad ) );
    }

    // Copy auxiliary data: Drawings
    m_Drawings.DeleteAll();

    for( BOARD_ITEM* item = aOther.m_Drawings;  item;  item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
        case PCB_MODULE_EDGE_T:
            Add( static_cast<BOARD_ITEM*>( item->Clone() ) );
            break;

        default:
            wxLogMessage( wxT( "MODULE::operator=() internal error: unknown type" ) );
            break;
        }
    }

    // Copy auxiliary data: 3D_Drawings info
    m_3D_Drawings.clear();
    m_3D_Drawings = aOther.m_3D_Drawings;
    m_Doc         = aOther.m_Doc;
    m_KeyWord     = aOther.m_KeyWord;

    // Ensure auxiliary data is up to date
    CalculateBoundingBox();

    return *this;
}
예제 #25
0
void Location::SetRadius(float radius)
{
    this->radius = radius;

    CalculateBoundingBox();
}
예제 #26
0
void MODULE::Flip( const wxPoint& aCentre )
{
    TEXTE_MODULE* text;

    // Move module to its final position:
    wxPoint finalPos = m_Pos;

    finalPos.y  = aCentre.y - ( finalPos.y - aCentre.y );     /// Mirror the Y position

    SetPosition( finalPos );

    // Flip layer
    SetLayer( FlipLayer( GetLayer() ) );

    // Reverse mirror orientation.
    NEGATE( m_Orient );
    NORMALIZE_ANGLE_POS( m_Orient );

    // Mirror pads to other side of board about the x axis, i.e. vertically.
    for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
        pad->Flip( m_Pos );

    // Mirror reference.
    text = m_Reference;
    text->m_Pos.y -= m_Pos.y;
    NEGATE( text->m_Pos.y );
    text->m_Pos.y += m_Pos.y;
    NEGATE(text->m_Pos0.y);
    NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
    text->SetLayer( FlipLayer( text->GetLayer() ) );
    text->m_Mirror = IsBackLayer( GetLayer() );

    // Mirror value.
    text = m_Value;
    text->m_Pos.y -= m_Pos.y;
    NEGATE( text->m_Pos.y );
    text->m_Pos.y += m_Pos.y;
    NEGATE( text->m_Pos0.y );
    NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
    text->SetLayer( FlipLayer( text->GetLayer() ) );
    text->m_Mirror = IsBackLayer( GetLayer() );

    // Reverse mirror module graphics and texts.
    for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_EDGE_T:
            {
                EDGE_MODULE* em = (EDGE_MODULE*) item;

                wxPoint s = em->GetStart();
                s.y -= m_Pos.y;
                s.y  = -s.y;
                s.y += m_Pos.y;
                em->SetStart( s );

                wxPoint e = em->GetEnd();
                e.y -= m_Pos.y;
                e.y  = -e.y;
                e.y += m_Pos.y;
                em->SetEnd( e );

                NEGATE( em->m_Start0.y );
                NEGATE( em->m_End0.y );

                if( em->GetShape() == S_ARC )
                {
                    em->SetAngle( -em->GetAngle() );
                }

                em->SetLayer( FlipLayer( em->GetLayer() ) );
            }
            break;

        case PCB_MODULE_TEXT_T:
            text = (TEXTE_MODULE*) item;
            text->m_Pos.y -= m_Pos.y;
            NEGATE( text->m_Pos.y );
            text->m_Pos.y += m_Pos.y;
            NEGATE( text->m_Pos0.y );
            NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
            text->SetLayer( FlipLayer( text->GetLayer() ) );
            text->m_Mirror = IsBackLayer( GetLayer() );
            break;

        default:
            wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) );
            break;
        }
    }

    CalculateBoundingBox();
}
예제 #27
0
void MODULE::Copy( MODULE* aModule )
{
    m_Pos           = aModule->m_Pos;
    m_Layer         = aModule->m_Layer;
    m_fpid          = aModule->m_fpid;
    m_Attributs     = aModule->m_Attributs;
    m_ModuleStatus  = aModule->m_ModuleStatus;
    m_Orient        = aModule->m_Orient;
    m_BoundaryBox   = aModule->m_BoundaryBox;
    m_CntRot90      = aModule->m_CntRot90;
    m_CntRot180     = aModule->m_CntRot180;
    m_LastEditTime  = aModule->m_LastEditTime;
    m_Link          = aModule->m_Link;
    m_Path          = aModule->m_Path; //is this correct behavior?
    SetTimeStamp( GetNewTimeStamp() );

    m_LocalClearance                = aModule->m_LocalClearance;
    m_LocalSolderMaskMargin         = aModule->m_LocalSolderMaskMargin;
    m_LocalSolderPasteMargin        = aModule->m_LocalSolderPasteMargin;
    m_LocalSolderPasteMarginRatio   = aModule->m_LocalSolderPasteMarginRatio;
    m_ZoneConnection                = aModule->m_ZoneConnection;
    m_ThermalWidth                  = aModule->m_ThermalWidth;
    m_ThermalGap                    = aModule->m_ThermalGap;

    // Copy reference and value.
    m_Reference->Copy( aModule->m_Reference );
    m_Value->Copy( aModule->m_Value );

    // Copy auxiliary data: Pads
    m_Pads.DeleteAll();

    for( D_PAD* pad = aModule->m_Pads;  pad;  pad = pad->Next() )
    {
        D_PAD* newpad = new D_PAD( this );
        newpad->Copy( pad );
        m_Pads.PushBack( newpad );
    }

    // Copy auxiliary data: Drawings
    m_Drawings.DeleteAll();

    for( BOARD_ITEM* item = aModule->m_Drawings;  item;  item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
        {
            TEXTE_MODULE* textm = new TEXTE_MODULE( this );
            textm->Copy( static_cast<TEXTE_MODULE*>( item ) );
            m_Drawings.PushBack( textm );
            break;
        }

        case PCB_MODULE_EDGE_T:
        {
            EDGE_MODULE * edge;
            edge = new EDGE_MODULE( this );
            edge->Copy( (EDGE_MODULE*) item );
            m_Drawings.PushBack( edge );
            break;
        }

        default:
            wxLogMessage( wxT( "MODULE::Copy() Internal Err:  unknown type" ) );
            break;
        }
    }

    // Copy auxiliary data: 3D_Drawings info
    m_3D_Drawings.DeleteAll();

    // Ensure there is one (or more) item in m_3D_Drawings
    m_3D_Drawings.PushBack( new S3D_MASTER( this ) ); // push a void item

    for( S3D_MASTER* item = aModule->m_3D_Drawings;  item;  item = item->Next() )
    {
        if( item->GetShape3DName().IsEmpty() )           // do not copy empty shapes.
            continue;

        S3D_MASTER* t3d = m_3D_Drawings;

        if( t3d && t3d->GetShape3DName().IsEmpty() )    // The first entry can
        {                                               // exist, but is empty : use it.
            t3d->Copy( item );
        }
        else
        {
            t3d = new S3D_MASTER( this );
            t3d->Copy( item );
            m_3D_Drawings.PushBack( t3d );
        }
    }

    m_Doc     = aModule->m_Doc;
    m_KeyWord = aModule->m_KeyWord;

    // Ensure auxiliary data is up to date
    CalculateBoundingBox();
}
예제 #28
0
void wxPolygonShape::ReadAttributes(wxExpr *clause)
{
	wxShape::ReadAttributes(clause);

	// Read a list of lists
	m_points = new wxList;
	m_originalPoints = new wxList;

	wxExpr *points_list = NULL;
	clause->AssignAttributeValue(wxT("points"), &points_list);

	// If no points_list, don't crash!! Assume a diamond instead.
	double the_height = 100.0;
	double the_width = 100.0;
	if (!points_list)
	{
		wxRealPoint *point = new wxRealPoint(0.0, (-the_height / 2));
		m_points->Append((wxObject *) point);

		point = new wxRealPoint((the_width / 2), 0.0);
		m_points->Append((wxObject *) point);

		point = new wxRealPoint(0.0, (the_height / 2));
		m_points->Append((wxObject *) point);

		point = new wxRealPoint((-the_width / 2), 0.0);
		m_points->Append((wxObject *) point);

		point = new wxRealPoint(0.0, (-the_height / 2));
		m_points->Append((wxObject *) point);
	}
	else
	{
		wxExpr *node = points_list->value.first;

		while (node)
		{
			wxExpr *xexpr = node->value.first;
			long x = xexpr->IntegerValue();

			wxExpr *yexpr = xexpr->next;
			long y = yexpr->IntegerValue();

			wxRealPoint *point = new wxRealPoint((double)x, (double)y);
			m_points->Append((wxObject *) point);

			node = node->next;
		}
	}

	points_list = NULL;
	clause->AssignAttributeValue(wxT("m_originalPoints"), &points_list);

	// If no points_list, don't crash!! Assume a diamond instead.
	if (!points_list)
	{
		wxRealPoint *point = new wxRealPoint(0.0, (-the_height / 2));
		m_originalPoints->Append((wxObject *) point);

		point = new wxRealPoint((the_width / 2), 0.0);
		m_originalPoints->Append((wxObject *) point);

		point = new wxRealPoint(0.0, (the_height / 2));
		m_originalPoints->Append((wxObject *) point);

		point = new wxRealPoint((-the_width / 2), 0.0);
		m_originalPoints->Append((wxObject *) point);

		point = new wxRealPoint(0.0, (-the_height / 2));
		m_originalPoints->Append((wxObject *) point);

		m_originalWidth = the_width;
		m_originalHeight = the_height;
	}
	else
	{
		wxExpr *node = points_list->value.first;
		double min_x = 1000;
		double min_y = 1000;
		double max_x = -1000;
		double max_y = -1000;
		while (node)
		{
			wxExpr *xexpr = node->value.first;
			long x = xexpr->IntegerValue();

			wxExpr *yexpr = xexpr->next;
			long y = yexpr->IntegerValue();

			wxRealPoint *point = new wxRealPoint((double)x, (double)y);
			m_originalPoints->Append((wxObject *) point);

			if (x < min_x)
				min_x = (double)x;
			if (y < min_y)
				min_y = (double)y;
			if (x > max_x)
				max_x = (double)x;
			if (y > max_y)
				max_y = (double)y;

			node = node->next;
		}
		m_originalWidth = max_x - min_x;
		m_originalHeight = max_y - min_y;
	}

	CalculateBoundingBox();
}
예제 #29
0
MODULE::MODULE( const MODULE& aModule ) :
    BOARD_ITEM( aModule )
{
    m_Pos = aModule.m_Pos;
    m_fpid = aModule.m_fpid;
    m_Layer  = aModule.m_Layer;
    m_Attributs = aModule.m_Attributs;
    m_ModuleStatus = aModule.m_ModuleStatus;
    m_Orient = aModule.m_Orient;
    m_BoundaryBox = aModule.m_BoundaryBox;
    m_CntRot90 = aModule.m_CntRot90;
    m_CntRot180 = aModule.m_CntRot180;
    m_LastEditTime = aModule.m_LastEditTime;
    m_Link = aModule.m_Link;
    m_Path = aModule.m_Path;              //is this correct behavior?

    m_LocalClearance = aModule.m_LocalClearance;
    m_LocalSolderMaskMargin = aModule.m_LocalSolderMaskMargin;
    m_LocalSolderPasteMargin = aModule.m_LocalSolderPasteMargin;
    m_LocalSolderPasteMarginRatio = aModule.m_LocalSolderPasteMarginRatio;
    m_ZoneConnection = aModule.m_ZoneConnection;
    m_ThermalWidth = aModule.m_ThermalWidth;
    m_ThermalGap = aModule.m_ThermalGap;

    // Copy reference and value.
    m_Reference = new TEXTE_MODULE( *aModule.m_Reference );
    m_Reference->SetParent( this );

    m_Value = new TEXTE_MODULE( *aModule.m_Value );
    m_Value->SetParent( this );

    // Copy auxiliary data: Pads
    for( D_PAD* pad = aModule.m_Pads;  pad;  pad = pad->Next() )
    {
        D_PAD* newpad = new D_PAD( *pad );
        assert( newpad->GetNet() == pad->GetNet() );
        newpad->SetParent( this );
        m_Pads.PushBack( newpad );
    }

    // Copy auxiliary data: Drawings
    for( BOARD_ITEM* item = aModule.m_Drawings;  item;  item = item->Next() )
    {
        BOARD_ITEM* newItem;

        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
        case PCB_MODULE_EDGE_T:
            newItem = static_cast<BOARD_ITEM*>( item->Clone() );
            newItem->SetParent( this );
            m_Drawings.PushBack( newItem );
            break;

        default:
            wxLogMessage( wxT( "MODULE::Copy() Internal Err:  unknown type" ) );
            break;
        }
    }

    // Copy auxiliary data: 3D_Drawings info
    for( S3D_MASTER* item = aModule.m_3D_Drawings;  item;  item = item->Next() )
    {
        if( item->GetShape3DName().IsEmpty() )           // do not copy empty shapes.
            continue;

        S3D_MASTER* t3d = new S3D_MASTER( this );
        t3d->Copy( item );
        m_3D_Drawings.PushBack( t3d );
    }

    // Ensure there is at least one item in m_3D_Drawings.
    if( m_3D_Drawings.GetCount() == 0 )
        m_3D_Drawings.PushBack( new S3D_MASTER( this ) ); // push a void item

    m_Doc     = aModule.m_Doc;
    m_KeyWord = aModule.m_KeyWord;

    m_arflag = 0;

    // Ensure auxiliary data is up to date
    CalculateBoundingBox();

    m_initial_comments = aModule.m_initial_comments ?
                            new wxArrayString( *aModule.m_initial_comments ) : 0;
}
예제 #30
0
void Cylindrical2dMesh::UpdateTopAndBottom()
{
    ChasteCuboid<2> bounding_box = CalculateBoundingBox();
    mBottom = bounding_box.rGetLowerCorner()[1];
    mTop = bounding_box.rGetUpperCorner()[1];
}